The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Bug in OmniFocus Applescript PBPASTE command Thread Tools Search this Thread Display Modes
PBCOPY and PBPASTE in the OF applescript library operate on nodes in the Content and Sidebar panels of the GUI.

Pasting a node to a position immediately after its parent should simulate an outlining OUTDENT operation.

This usually works correctly, but a bug is seen if an attempt is made to copy and paste an un-nested action (a top-level child of a project) to a position immediately after its parent project.

The task is correctly promoted to project status,

BUT it is placed in the wrong position (outside any folders enclosing its parent, rather than as a following sibling of its parent).

An analogous bug (presumably of the same origin) occurs when using the Edit > Outlining > Outdent command in the OmniFocus menu system. (Kudos to whpalmer4 for spotting this bug, which is presumably located in code which converts tasks to projects, and fails to assign the property which is stored in the cache as ProjectInfo.folder ).

In both cases, outdenting (and the equivalent PBCOPY PBPASTE sequence) works correctly with Folders, Projects, and nested Tasks, and also with Inbox tasks, and Contexts. It only misplaces unnested (top level) project actions and action-groups.

The following is a draft sketch of a replacement for the boxed Outdent operation. (It moves the misplaced / mispasted object back to the orginally specified target, immediately after the parent project).

For a fully working replacement of outdent, PBCOPY and PBPASTE need to be followed by a deletion of the original node. If you wanted to actually use the code below, you would need to uncomment the two DELETE lines. The code is, however, only intended as an illustrative draft.

Code:
-- DRAFT REPLACEMENT FOR BUGGY OMNIFOCUS > EDIT > OUTLINING > OUTDENT

tell application id "OFOC"
	set oDoc to front document
	set oWin to front document window of oDoc
	tell oWin
		set oPanel to content
		set lstNodes to selected trees of oPanel
		if (count of lstNodes) < 1 then
			set oPanel to sidebar
			set lstNodes to selected trees of oPanel
		end if
		if (count of lstNodes) < 1 then return
		
		repeat with oNode in lstNodes
			set oObj to value of oNode
			set cClass to class of oObj
			if cClass is not item then
				if class of container of oObj ≠ document then
					set lstAncestors to ancestor trees of oNode
					
					if (count of lstAncestors) > 1 then
						pbcopy oNode
						set oParent to first item of lstAncestors
						pbpaste at (after oParent) -- SPECIFIED LOCATION MISFIRES WITH TASKS CONVERTED TO PROJECTS
						
						tell oObj
							if (its class is task) then
								set oParentProj to containing project
								if (id of parent task) = (id of oParentProj) then
									-- TOP LEVEL TASK - WILL BECOME A PROJECT ONCE OUTDENTED 
									-- AND WILL HAVE BEEN MISPLACED BY A BUG IN PBPASTE
									if (folder of oParentProj) is not missing value then
										set oProj to value of (last descendant tree of oPanel where class of its value is project)
										move oProj to after oParentProj
									end if
								end if
							end if
						end tell
						tell oPanel to select (first following sibling of oParent)
						
						-- UNCOMMENT THE FOLLOWING LINE IF YOU WISH TO USE THIS IN LIEU OF:  OmniFocus > Edit > Outlining > Outdent
						-- tell oDoc to delete oObj
					end if
				else if cClass = inbox task then
					pbcopy oNode
					-- PASTE AT END OF SIDEBAR LIST OF TOP LEVEL PROJECTS
					-- (for compatibility with boxed Outdent, 
					-- though I prefer it to be at the top for more visibility).
					pbpaste at (after trees of tree 2 of sidebar of oWin)
					
					-- UNCOMMENT THE FOLLOWING LINE IF YOU WISH TO USE THIS IN LIEU OF:  OmniFocus > Edit > Outlining > Outdent
					-- tell oDoc to delete oObj
				end if
			end if
		end repeat
	end tell
end tell

Last edited by RobTrew; 2011-04-14 at 10:25 PM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
AppleScript move command bholveck OmniOutliner 3 for Mac 3 2012-01-19 02:55 PM
AppleScript references with no set or command MLModel OmniOutliner 3 for Mac 1 2010-11-21 11:34 AM
Applescript Duplicate command: how to use it? Lutin OmniFocus Extras 6 2007-10-30 12:56 AM
New 'complete' AppleScript command Tim Wood OmniFocus 1 for Mac 17 2007-07-19 08:19 PM
AppleScript 'do script' command Bcpst OmniWeb Feature Requests 2 2006-05-06 11:08 PM


All times are GMT -8. The time now is 12:28 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.