Toggling a folder between On Hold and Active
Discussion in [URL="http://forums.omnigroup.com/showthread.php?t=16299"]another thread[/URL] suggests that OmniFocus Ver 2 will allow us to set the status of a Folder to [B]On Hold[/B].
In the meanwhile, here is a draft applescript which toggles the contents and descendants of the selected folder between [B]On Hold[/B] and [B]Active[/B] (leaving the status of Completed and Dropped projects unchanged). [CODE]-- Ver 0.4 -- Toggles contents and descendants of the selected folder between ON HOLD and ACTIVE -- The status of any COMPLETED and DROPPED projects is left unchanged -- Any DROPPED subfolders are also left unchanged tell application id "com.omnigroup.OmniFocus" tell front window set lstFolders to value of (selected trees of sidebar where class of value is folder) set refProjects to a reference to value of (selected trees of sidebar where ¬ (class of value is project) and ((status of value is active) or (status of value is on hold))) end tell repeat with oFolder in lstFolders my ToggleFolderStatus(oFolder) end repeat set lstStatus to status of refProjects if length of lstStatus > 0 then if first item of lstStatus is active then set status of refProjects to on hold else set status of refProjects to active end if end if end tell on ToggleFolderStatus(oFolder) using terms from application "OmniFocus" set refProjects to a reference to (projects of oFolder where (status is active) or (status is on hold)) set lstStatus to status of refProjects if length of lstStatus > 0 then if first item of lstStatus is active then set status of refProjects to on hold else set status of refProjects to active end if end if set lstFolders to folders of oFolder where hidden is false repeat with oSubFolder in lstFolders my ToggleFolderStatus(oSubFolder) end repeat end using terms from end ToggleFolderStatus[/CODE] [COLOR="White"]--[/COLOR] |
If you are running OF 1.8, this toggling version is a little faster:
[CODE]-- Ver 0.9 (OF 1.8 only) -- Toggles status of contents and descendants of the selected folder(s) and project(s) between ON HOLD and ACTIVE -- The status of any COMPLETED and DROPPED projects is left unchanged -- Any DROPPED subfolders are also left unchanged property pActive : "Active" property pOnHold : "On Hold" tell application id "com.omnigroup.OmniFocus" tell front window set oPanel to sidebar if (count of selected trees of oPanel) < 1 then set oPanel to content set lstFolders to {} else set lstFolders to value of (selected trees of oPanel where ¬ (class of value is folder) and (hidden of value is false)) end if set refProjects to a reference to value of (selected trees of oPanel where ¬ (class of value is project) and ((status of value is active) or (status of value is on hold))) end tell -- Find the first project in (or contained by) the selection set oProj to missing value set lstProjects to contents of refProjects if length of lstProjects > 0 then set oProj to first item of lstProjects else repeat with oFolder in lstFolders set lstProj to (flattened projects of oFolder where ((status is active) or (status is on hold)) and (hidden of its folder is false or its folder is missing value)) if length of lstProj > 0 then set oProj to first item of lstProj exit repeat end if end repeat end if if oProj is missing value then return -- Determine the next toggle direction status of oProj if status of oProj is active then set eNewStatus to on hold else set eNewStatus to active end if -- and set the new status set status of refProjects to eNewStatus repeat with oFolder in lstFolders set (status of flattened projects of oFolder where ((status is active) or (status is on hold)) and (hidden of its folder is false)) to eNewStatus end repeat end tell [/CODE] [COLOR="White"]--[/COLOR] |
All times are GMT -8. The time now is 05:47 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.