MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / buildTaskEditFormState

Function buildTaskEditFormState

src/modals/taskEditFormState.ts:69–104  ·  view source on GitHub ↗
(input: TaskEditFormStateInput)

Source from the content-addressed store, hash-verified

67}
68
69export function buildTaskEditFormState(input: TaskEditFormStateInput): TaskEditFormState {
70 const rawTags = input.task.tags || [];
71 const visibleTags =
72 input.settings.taskIdentificationMethod === "tag"
73 ? filterTaskIdentificationTags(
74 rawTags,
75 input.settings.taskTag || "",
76 input.settings.hideIdentifyingTagsMode
77 )
78 : rawTags;
79 const tags = rawTags.length > 0 ? sanitizeTags(visibleTags.join(", ")) : "";
80 const details = input.normalizeDetails(input.details);
81 const projectValues = input.task.projects || [];
82
83 return {
84 title: input.task.title,
85 dueDate: input.task.due || "",
86 scheduledDate: input.task.scheduled || "",
87 priority: input.task.priority,
88 status: input.task.status,
89 contexts: input.task.contexts ? input.task.contexts.join(", ") : "",
90 projectValues,
91 hasValidProjects: projectValues.some(
92 (project) => typeof project === "string" && project.trim() !== ""
93 ),
94 tags,
95 initialTags: tags,
96 timeEstimate: input.task.timeEstimate || 0,
97 recurrenceRule: typeof input.task.recurrence === "string" ? input.task.recurrence : "",
98 recurrenceAnchor: input.task.recurrence_anchor || "scheduled",
99 reminders: input.task.reminders ? [...input.task.reminders] : [],
100 details,
101 originalDetails: details,
102 userFields: getTaskEditUserFieldValues(input.frontmatter, input.settings.userFields || []),
103 };
104}
105
106export function getTaskEditUserFieldValues(
107 frontmatter: Record<string, unknown>,

Callers 2

Calls 3

sanitizeTagsFunction · 0.90

Tested by

no test coverage detected