( state: TaskCreationFormState, values: TaskCreationPrepopulatedValues, taskTag: string )
| 109 | } |
| 110 | |
| 111 | function applyPrePopulatedValues( |
| 112 | state: TaskCreationFormState, |
| 113 | values: TaskCreationPrepopulatedValues, |
| 114 | taskTag: string |
| 115 | ): void { |
| 116 | if (values.title !== undefined) state.title = values.title; |
| 117 | if (values.due !== undefined) state.dueDate = values.due; |
| 118 | if (values.scheduled !== undefined) state.scheduledDate = values.scheduled; |
| 119 | if (values.priority !== undefined) state.priority = values.priority; |
| 120 | if (values.status !== undefined) state.status = values.status; |
| 121 | if (values.contexts !== undefined) { |
| 122 | state.contexts = values.contexts.join(", "); |
| 123 | } |
| 124 | if (values.projects !== undefined) { |
| 125 | state.projectStrings = values.projects.filter( |
| 126 | (project) => project && typeof project === "string" && project.trim() !== "" |
| 127 | ); |
| 128 | } |
| 129 | if (values.tags !== undefined) { |
| 130 | state.tags = sanitizeTags( |
| 131 | values.tags.filter((tag) => tag !== taskTag).join(", ") |
| 132 | ); |
| 133 | } |
| 134 | if (values.timeEstimate !== undefined) state.timeEstimate = values.timeEstimate; |
| 135 | if (values.recurrence !== undefined && typeof values.recurrence === "string") { |
| 136 | state.recurrenceRule = values.recurrence; |
| 137 | } |
| 138 | if (values.recurrence_anchor !== undefined) { |
| 139 | state.recurrenceAnchor = values.recurrence_anchor; |
| 140 | } |
| 141 | if (values.customFrontmatter) { |
| 142 | for (const [fieldKey, fieldValue] of Object.entries(values.customFrontmatter)) { |
| 143 | state.userFields[fieldKey] = fieldValue; |
| 144 | } |
| 145 | } |
| 146 | } |
no test coverage detected