MCPcopy
hub / github.com/callumalpass/tasknotes / handleSave

Method handleSave

src/modals/TaskCreationModal.ts:623–719  ·  view source on GitHub ↗
(options: { createAnother?: boolean } = {})

Source from the content-addressed store, hash-verified

621 }
622
623 async handleSave(options: { createAnother?: boolean } = {}): Promise<void> {
624 // If NLP is enabled and there's content in the NL field, parse it first
625 if (this.plugin.settings.enableNaturalLanguageInput) {
626 const nlContent = this.getNLPInputValue().trim();
627 if (nlContent && !this.title.trim()) {
628 // Only auto-parse if no title has been manually entered
629 const parsed = this.nlParser.parseInput(nlContent);
630 this.applyParsedData(parsed);
631 }
632 }
633
634 if (!this.validateForm()) {
635 new Notice(this.t("modals.taskCreation.notices.titleRequired"));
636 return;
637 }
638
639 try {
640 const taskData = this.buildTaskData();
641 // Disable defaults since they were already applied to form fields in initializeFormData()
642 const result = await this.plugin.taskService.createTask(taskData, {
643 applyDefaults: false,
644 });
645 let createdTask = result.taskInfo;
646
647 if (
648 shouldShowFilenameShortenedNotice(
649 this.plugin.settings,
650 result.taskInfo.title,
651 result.file.basename
652 )
653 ) {
654 new Notice(
655 this.t("modals.taskCreation.notices.successShortened", {
656 title: createdTask.title,
657 })
658 );
659 } else {
660 new Notice(
661 this.t("modals.taskCreation.notices.success", { title: createdTask.title })
662 );
663 }
664
665 if (this.blockingItems.length > 0) {
666 const blockingUpdates = buildCreationBlockingUpdates(this.blockingItems);
667
668 if (blockingUpdates.added.length > 0) {
669 await this.plugin.taskService.updateBlockingRelationships(
670 createdTask,
671 blockingUpdates.added,
672 [],
673 blockingUpdates.raw
674 );
675 const refreshed = await this.plugin.cacheManager.getTaskInfo(createdTask.path);
676 if (refreshed) {
677 createdTask = refreshed;
678 }
679 }
680

Callers 1

handleSubmitShortcutMethod · 0.95

Calls 15

getNLPInputValueMethod · 0.95
applyParsedDataMethod · 0.95
buildTaskDataMethod · 0.95
errorMethod · 0.80
parseInputMethod · 0.65
createTaskMethod · 0.65

Tested by

no test coverage detected