Created
January 18, 2017 18:49
-
-
Save astyagun/9eb4a39c67258e3067b86db27b7894d9 to your computer and use it in GitHub Desktop.
Flags or unflags project of selected action(s) in OmniFocus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
# DESCRIPTION # | |
Based on: http://bylr.net/3/2015/05/omnifocus-view-project-in-new-window/ | |
Flags or unflags project of selected action. | |
# LICENSE # | |
Copyright © 2015 Dan Byler (contact: [email protected]) | |
Licensed under MIT License (http://www.opensource.org/licenses/mit-license.php) | |
(TL;DR: no warranty, do whatever you want with it.) | |
# INSTALLATION # | |
1. Copy script to OmniFocus script folder (OmniFocus -> Help -> Open Scripts Folder) | |
2. (Optional) Update to use the icon in this repo | |
3. Add script to the OmniFocus toolbar using View -> Customize Toolbar... | |
*) | |
on main() | |
tell application "OmniFocus" | |
set my_containers to {} | |
-- Get selection | |
tell content of front document window of front document | |
set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder) | |
set totalItems to count of validSelectedItemsList | |
if totalItems is 0 then | |
my notifyWithoutGrowl("No valid task(s) selected") | |
return | |
end if | |
repeat with validSelectedItem in validSelectedItemsList | |
validSelectedItem | |
if (containing project of validSelectedItem) is not missing value then | |
set end of my_containers to (containing project of validSelectedItem) | |
else if (assigned container of validSelectedItem) is not missing value then | |
set end of my_containers to (assigned container of validSelectedItem) | |
end if | |
end repeat | |
end tell | |
-- No valid projects to focus on | |
if length of my_containers is 0 then | |
my notifyWithoutGrowl("No projects to focus") | |
return | |
end if | |
-- Flag or unflag projects | |
repeat with container_index from 1 to count of my_containers | |
set my_container to item container_index of my_containers | |
set flagged of my_container to not flagged of my_container | |
end repeat | |
end tell | |
end main | |
on notifyWithoutGrowl(alertText) | |
tell application "OmniFocus" to display dialog alertText with icon 1 buttons {"OK"} default button "OK" | |
end notifyWithoutGrowl | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment