Skip to content

Commit c91067d

Browse files
committed
Add command to change the priority of the note on active tab
1 parent dd58faf commit c91067d

File tree

2 files changed

+46
-22
lines changed

2 files changed

+46
-22
lines changed

src/front-matter-manager.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,4 @@ export class FrontMatterManager {
131131

132132
editor.setCursor({ line: targetLine, ch: 0 });
133133
}
134-
135-
async changeStatus(status: string): Promise<void> {
136-
const activeFile = this.app.workspace.getActiveFile();
137-
if (!activeFile) {
138-
new Notice("No active file found.");
139-
return;
140-
}
141-
await this.frontMatterManager.updateProperty(
142-
activeFile,
143-
(frontmatter) => {
144-
frontmatter.status = status;
145-
return frontmatter;
146-
}
147-
);
148-
new Notice(`Updated status to ${status}`);
149-
}
150134
}

src/main.ts

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,63 @@ export default class TimeTreePlugin extends Plugin {
6060
id: "change-status-todo",
6161
name: "Change status to todo",
6262
callback: async () => {
63-
await this.changeStatus("todo");
63+
await this.updateNoteProperty("status", "todo");
6464
},
6565
});
6666

6767
this.addCommand({
6868
id: "change-status-doing",
6969
name: "Change status to doing",
7070
callback: async () => {
71-
await this.changeStatus("doing");
71+
await this.updateNoteProperty("status", "doing");
7272
},
7373
});
7474

7575
this.addCommand({
7676
id: "change-status-done",
7777
name: "Change status to done",
7878
callback: async () => {
79-
await this.changeStatus("done");
79+
await this.updateNoteProperty("status", "done");
80+
},
81+
});
82+
83+
this.addCommand({
84+
id: "change-priority-lowest",
85+
name: "Change priority to Lowest",
86+
callback: async () => {
87+
await this.updateNoteProperty("priority", "Lowest");
88+
},
89+
});
90+
91+
this.addCommand({
92+
id: "change-priority-low",
93+
name: "Change priority to Low",
94+
callback: async () => {
95+
await this.updateNoteProperty("priority", "Low");
96+
},
97+
});
98+
99+
this.addCommand({
100+
id: "change-priority-medium",
101+
name: "Change priority to Medium",
102+
callback: async () => {
103+
await this.updateNoteProperty("priority", "Medium");
104+
},
105+
});
106+
107+
this.addCommand({
108+
id: "change-priority-high",
109+
name: "Change priority to High",
110+
callback: async () => {
111+
await this.updateNoteProperty("priority", "High");
112+
},
113+
});
114+
115+
this.addCommand({
116+
id: "change-priority-highest",
117+
name: "Change priority to Highest",
118+
callback: async () => {
119+
await this.updateNoteProperty("priority", "Highest");
80120
},
81121
});
82122

@@ -220,7 +260,7 @@ export default class TimeTreePlugin extends Plugin {
220260
editor.setCursor({ line: cursor.line, ch: cursor.ch + 4 });
221261
}
222262

223-
async changeStatus(status: string): Promise<void> {
263+
async updateNoteProperty(property: string, value: string): Promise<void> {
224264
const activeFile = this.app.workspace.getActiveFile();
225265
if (!activeFile) {
226266
new Notice("No active file found.");
@@ -229,11 +269,11 @@ export default class TimeTreePlugin extends Plugin {
229269
await this.frontMatterManager.updateProperty(
230270
activeFile,
231271
(frontmatter) => {
232-
frontmatter.status = status;
272+
frontmatter[property] = value;
233273
return frontmatter;
234274
}
235275
);
236-
new Notice(`Updated status to ${status}`);
276+
new Notice(`Updated ${property} to ${value}`);
237277
}
238278

239279
scheduleComputeTimeTree(): void {

0 commit comments

Comments
 (0)