Convert task priority to enum so it is now sortable

This commit is contained in:
2025-01-15 15:50:50 +01:00
parent 31c309aecc
commit 464262d46d
2 changed files with 27 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ export class LazyTask implements Task {
.map(x => x.value);
}
get priority(): TaskPriority {
get priorityStr(): string {
const priority = this.#parsed.meta.find(x => x.feature === 'priority')?.priority;
if(!priority) {
@@ -49,6 +49,22 @@ export class LazyTask implements Task {
'🔼': 'medium',
'⏫': 'high',
'🔺': 'highest'
}[priority];
}
get priority(): TaskPriority {
const priority = this.#parsed.meta.find(x => x.feature === 'priority')?.priority;
if(!priority) {
return TaskPriority.NORMAL;
}
return {
'⏬': TaskPriority.LOWEST,
'🔽': TaskPriority.LOW,
'🔼': TaskPriority.MEDIUM,
'⏫': TaskPriority.HIGH,
'🔺': TaskPriority.HIGHEST
}[priority] as TaskPriority;
}
@@ -110,7 +126,7 @@ export class LazyTask implements Task {
const o = (name: string, value?: string) => value && value.length > 0 ? `${name}=${value}` : "";
const items = [
o("priority", this.priority),
o("priority", this.priorityStr),
o("created", this.createdDate?.format("YYYY-MM-DD")),
o("start", this.startDate?.format("YYYY-MM-DD")),
o("scheduled", this.scheduledDate?.format("YYYY-MM-DD")),

View File

@@ -6,6 +6,7 @@ export type Task = {
fullLabel: string;
tags: string[];
priority: TaskPriority;
priorityStr: string;
createdDate?: Dayjs;
startDate?: Dayjs;
scheduledDate?: Dayjs;
@@ -19,10 +20,11 @@ export type Task = {
reminder?: string;
}
export type TaskPriority =
| 'lowest'
| 'low'
| 'normal'
| 'medium'
| 'high'
| 'highest';
export enum TaskPriority {
LOWEST,
LOW,
NORMAL,
MEDIUM,
HIGH,
HIGHEST,
};