( plugin: TaskNotesPlugin )
| 9 | * Includes both core properties and user-defined fields. |
| 10 | */ |
| 11 | export function getAvailableProperties( |
| 12 | plugin: TaskNotesPlugin |
| 13 | ): Array<{ id: string; label: string }> { |
| 14 | // Helper to create label showing user's configured property name |
| 15 | const makeLabel = (displayName: string, mappingKey: keyof FieldMapping): string => { |
| 16 | const userPropertyName = plugin.fieldMapper.toUserField(mappingKey); |
| 17 | // Only show the property name if it differs from the display name (lowercased) |
| 18 | if (userPropertyName !== displayName.toLowerCase().replace(/\s+/g, "")) { |
| 19 | return `${displayName} (${userPropertyName})`; |
| 20 | } |
| 21 | return displayName; |
| 22 | }; |
| 23 | |
| 24 | // Core properties using FieldMapping keys as IDs |
| 25 | const coreProperties = [ |
| 26 | { id: "status", label: makeLabel("Status", "status") }, |
| 27 | { id: "priority", label: makeLabel("Priority", "priority") }, |
| 28 | { id: "blocked", label: "Blocked Status" }, // Special property, not in FieldMapping |
| 29 | { id: "blocking", label: "Blocking Status" }, // Special property, not in FieldMapping |
| 30 | { id: "due", label: makeLabel("Due Date", "due") }, |
| 31 | { id: "scheduled", label: makeLabel("Scheduled Date", "scheduled") }, |
| 32 | { id: "timeEstimate", label: makeLabel("Time Estimate", "timeEstimate") }, |
| 33 | { id: "totalTrackedTime", label: "Total Tracked Time" }, // Computed property, not in FieldMapping |
| 34 | { id: "checklistProgress", label: "Checklist Progress" }, // Computed from metadata cache listItems |
| 35 | { id: "recurrence", label: makeLabel("Recurrence", "recurrence") }, |
| 36 | { id: "completeInstances", label: makeLabel("Completed Instances", "completeInstances") }, |
| 37 | { id: "skippedInstances", label: makeLabel("Skipped Instances", "skippedInstances") }, |
| 38 | { id: "completedDate", label: makeLabel("Completed Date", "completedDate") }, |
| 39 | { id: "dateCreated", label: makeLabel("Created Date", "dateCreated") }, |
| 40 | { id: "dateModified", label: makeLabel("Modified Date", "dateModified") }, |
| 41 | { id: "projects", label: makeLabel("Projects", "projects") }, |
| 42 | { id: "contexts", label: makeLabel("Contexts", "contexts") }, |
| 43 | { id: "tags", label: "Tags" }, // Special property, not in FieldMapping |
| 44 | ]; |
| 45 | |
| 46 | // Add user-defined fields |
| 47 | const userProperties = |
| 48 | plugin.settings.userFields?.map((field) => ({ |
| 49 | id: `user:${field.id}`, |
| 50 | label: field.displayName, |
| 51 | })) || []; |
| 52 | |
| 53 | return [...coreProperties, ...userProperties]; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Get labels for a list of property IDs |
no test coverage detected