MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / renderTaskModalSubtasksList

Function renderTaskModalSubtasksList

src/modals/taskModalSubtasks.ts:56–108  ·  view source on GitHub ↗
({
	app,
	listEl,
	files,
	sourcePath,
	getCachedTaskInfo,
	createTaskCard,
	translate,
	onRemove,
}: RenderTaskModalSubtasksListOptions)

Source from the content-addressed store, hash-verified

54}
55
56export async function renderTaskModalSubtasksList({
57 app,
58 listEl,
59 files,
60 sourcePath,
61 getCachedTaskInfo,
62 createTaskCard,
63 translate,
64 onRemove,
65}: RenderTaskModalSubtasksListOptions): Promise<void> {
66 if (!listEl) {
67 return;
68 }
69
70 listEl.empty();
71 if (files.length === 0) {
72 return;
73 }
74
75 const linkServices: LinkServices = {
76 metadataCache: app.metadataCache,
77 workspace: app.workspace,
78 };
79
80 for (const file of files) {
81 if (!(file instanceof TFile)) {
82 return;
83 }
84
85 const subtaskItem = listEl.createDiv({
86 cls: "task-project-item task-project-item--task-card",
87 });
88 const cardHost = subtaskItem.createDiv({ cls: "task-project-card-host" });
89
90 const taskInfo = await getCachedTaskInfo(file.path);
91 if (taskInfo) {
92 cardHost.appendChild(createTaskCard(taskInfo));
93 } else {
94 renderSubtaskFallback(app, cardHost, file, sourcePath, linkServices);
95 }
96
97 const removeBtn = subtaskItem.createEl("button", {
98 cls: "task-project-remove",
99 text: "×",
100 });
101 setTooltip(removeBtn, translate("modals.task.organization.removeSubtaskTooltip"), {
102 placement: "top",
103 });
104 removeBtn.addEventListener("click", () => {
105 onRemove(file);
106 });
107 }
108}
109
110function renderSubtaskFallback(
111 app: App,

Callers 2

renderSubtasksListFunction · 0.90

Calls 4

setTooltipFunction · 0.90
renderSubtaskFallbackFunction · 0.85
createTaskCardFunction · 0.50
translateFunction · 0.50

Tested by

no test coverage detected