( plugin: TaskNotesPlugin, parentFile: TFile, subtask: TaskInfo )
| 102 | } |
| 103 | |
| 104 | export async function assignTaskAsSubtask( |
| 105 | plugin: TaskNotesPlugin, |
| 106 | parentFile: TFile, |
| 107 | subtask: TaskInfo |
| 108 | ): Promise<TaskInfo | null> { |
| 109 | const projectReference = generateLink( |
| 110 | plugin.app, |
| 111 | parentFile, |
| 112 | subtask.path, |
| 113 | "", |
| 114 | "", |
| 115 | plugin.settings.useFrontmatterMarkdownLinks |
| 116 | ); |
| 117 | const legacyReference = `[[${parentFile.basename}]]`; |
| 118 | const subtaskProjects = Array.isArray(subtask.projects) ? subtask.projects : []; |
| 119 | |
| 120 | if (subtaskProjects.includes(projectReference) || subtaskProjects.includes(legacyReference)) { |
| 121 | publishUserNotice( |
| 122 | plugin.emitter, |
| 123 | translate(plugin, "contextMenus.task.organization.notices.alreadySubtask") |
| 124 | ); |
| 125 | return null; |
| 126 | } |
| 127 | |
| 128 | const sanitizedProjects = subtaskProjects.filter((entry) => entry !== legacyReference); |
| 129 | const updatedProjects = [...sanitizedProjects, projectReference]; |
| 130 | const updatedSubtask = await plugin.updateTaskProperty(subtask, "projects", updatedProjects); |
| 131 | |
| 132 | publishUserNotice( |
| 133 | plugin.emitter, |
| 134 | translate(plugin, "contextMenus.task.organization.notices.addedAsSubtask", { |
| 135 | subtask: subtask.title, |
| 136 | parent: parentFile.basename, |
| 137 | }) |
| 138 | ); |
| 139 | return updatedSubtask; |
| 140 | } |
| 141 | |
| 142 | export function buildSubtaskCreationPrePopulatedValues( |
| 143 | plugin: TaskNotesPlugin, |
no test coverage detected