Working file loading!
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m22s

This commit is contained in:
2026-03-09 09:57:05 -05:00
parent 1c8e8b1d54
commit 092e139f6e
2 changed files with 42 additions and 7 deletions
+19 -4
View File
@@ -11,19 +11,34 @@ export const JobFileSelector = (props: JobFileSelectorProps) => {
const [query, setQuery] = createSignal(""); const [query, setQuery] = createSignal("");
const [selectedJobId, setSelectedJobId] = createSignal<string | null>(null); const [selectedJobId, setSelectedJobId] = createSignal<string | null>(null);
// Auto-detect job ID from active note tags // Auto-detect job ID from active note tags (traversing up hierarchy)
onMount(() => { onMount(() => {
const currentNoteId = activeNoteId(); const currentNoteId = activeNoteId();
if (currentNoteId) { if (currentNoteId) {
const currentNote = store.notes.find(n => n.id === currentNoteId); let currentId = currentNoteId;
if (currentNote) { let currentNote = store.notes.find(n => n.id === currentId);
const jobIdTag = currentNote.tags.find(t => t.startsWith("job_id:")); let depth = 0;
// Traverse up "child-of-" tags to find the root or any ancestor with a job_id
while (currentNote && depth < 10) {
const jobIdTag = currentNote.tags?.find(t => t.startsWith("job_id:"));
if (jobIdTag) { if (jobIdTag) {
const id = jobIdTag.split(":")[1]; const id = jobIdTag.split(":")[1];
if (id) { if (id) {
setSelectedJobId(id); setSelectedJobId(id);
return; // Found it!
} }
} }
const parentTag = currentNote.tags?.find(t => t.startsWith("child-of-"));
if (!parentTag) break;
const parentId = parentTag.replace("child-of-", "");
const parent = store.notes.find(n => n.id === parentId);
if (!parent) break;
currentNote = parent;
depth++;
} }
} }
}); });
+23 -3
View File
@@ -33,9 +33,29 @@ export const FileViewer = Node.create<FileViewerOptions>({
addAttributes() { addAttributes() {
return { return {
jobId: { default: null }, jobId: {
collectionId: { default: 'Job_Info_Prod' }, default: null,
filename: { default: null }, parseHTML: element => element.getAttribute('data-job-id'),
renderHTML: attributes => {
if (!attributes.jobId) return {};
return { 'data-job-id': attributes.jobId };
},
},
collectionId: {
default: 'Job_Info_Prod',
parseHTML: element => element.getAttribute('data-collection-id') || 'Job_Info_Prod',
renderHTML: attributes => {
return { 'data-collection-id': attributes.collectionId || 'Job_Info_Prod' };
},
},
filename: {
default: null,
parseHTML: element => element.getAttribute('data-filename'),
renderHTML: attributes => {
if (!attributes.filename) return {};
return { 'data-filename': attributes.filename };
},
},
}; };
}, },