Skip to content

Commit

Permalink
make a view that shows projects with flagged tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Jan 27, 2023
1 parent c0e56f2 commit b7fa0f9
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Picker.omnifocusjs/Resources/en.lproj/showFlagged.strings
@@ -0,0 +1,5 @@
"label" = "Show Flagged Projects";
"shortLabel" = "Flagged";
"mediumLabel" = "Show Flagged";
"longLabel" = "Show Flagged Projects";
"paletteLabel" = "Flagged";
Binary file added Picker.omnifocusjs/Resources/index-cards.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions Picker.omnifocusjs/Resources/showFlagged.js
@@ -0,0 +1,27 @@
"use strict";
(() => {
var action = new PlugIn.Action(async () => {
try {
let toFocus = [];
flattenedProjects
.filter((p) => p.status == Project.Status.Active)
.flatMap((p) => p.flattenedTasks.filter((t) => t.flagged &&
(t.taskStatus == Task.Status.Available ||
t.taskStatus == Task.Status.DueSoon ||
t.taskStatus == Task.Status.Next ||
t.taskStatus == Task.Status.Overdue)))
.forEach((task) => {
if (task.containingProject && toFocus.indexOf(task.containingProject) === -1) {
toFocus.push(task.containingProject);
}
});
document.windows[0].perspective = Perspective.BuiltIn.Projects;
document.windows[0].focus = toFocus;
}
catch (err) {
console.error(err);
throw err;
}
});
return action;
})();
33 changes: 33 additions & 0 deletions Picker.omnifocusjs/Resources/showFlagged.ts
@@ -0,0 +1,33 @@
(() => {
var action = new PlugIn.Action(async () => {
try {
let toFocus: Project[] = [];

flattenedProjects
.filter((p) => p.status == Project.Status.Active)
.flatMap((p) =>
p.flattenedTasks.filter(
(t: Task) =>
t.flagged &&
(t.taskStatus == Task.Status.Available ||
t.taskStatus == Task.Status.DueSoon ||
t.taskStatus == Task.Status.Next ||
t.taskStatus == Task.Status.Overdue)
)
)
.forEach((task: Task) => {
if (task.containingProject && toFocus.indexOf(task.containingProject) === -1) {
toFocus.push(task.containingProject);
}
});

document.windows[0].perspective = Perspective.BuiltIn.Projects;
document.windows[0].focus = toFocus as SectionArray;
} catch (err) {
console.error(err);
throw err;
}
});

return action;
})();
4 changes: 4 additions & 0 deletions Picker.omnifocusjs/manifest.json
Expand Up @@ -8,6 +8,10 @@
{
"identifier": "pick",
"image": "arrow-clockwise.png"
},
{
"identifier": "showFlagged",
"image": "index-cards.png",
}
]
}

0 comments on commit b7fa0f9

Please sign in to comment.