Tasks
Curabitur blandit tempus porttitor. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Donec id elit non mi porta gravida at eget metus. Donec id elit non mi porta gravida at eget metus.
| Move Selected Tasks into New Project | ||
| 01 | /*{ | |
| 02 | "type": "action", | |
| 03 | "targets": ["omnifocus"], | |
| 04 | "author": "Otto Automator", | |
| 05 | "identifier": "com.omni-automation.move-selected-tasks-into-project", | |
| 06 | "version": "1.0", | |
| 07 | "description": "Move the selected tasks into a new top-level project.", | |
| 08 | "label": "Move Selected Tasks into New Project", | |
| 09 | "shortLabel": "Move Tasks" | |
| 10 | }*/ | |
| 11 | var _ = function(){ | |
| 12 | var action = new PlugIn.Action(function(selection, sender){ | |
| 13 | // selection options: tasks, projects, folders, tags | |
| 14 | ||
| 15 | // CONSTRUCT THE FORM | |
| 16 | var inputForm = new Form() | |
| 17 | ||
| 18 | // CREATE FORM ELEMENT: TEXT INPUT | |
| 19 | textField = new Form.Field.String("projectName", "Project Name", null) | |
| 20 | ||
| 21 | // CREATE FORM ELEMENT: OPTION MENU | |
| 22 | popupMenu = new Form.Field.Option( | |
| 23 | "projectType", | |
| 24 | "Project Type", | |
| 25 | [0, 1, 2], | |
| 26 | ["Parallel","Sequential","Single Actions"], | |
| 27 | 0 | |
| 28 | ) | |
| 29 | ||
| 30 | // ADD THE ELEMENTS TO THE FORM | |
| 31 | inputForm.addField(textField) | |
| 32 | inputForm.addField(popupMenu) | |
| 33 | ||
| 34 | // DIALOG PROMPT AND OK BUTTON TITLE | |
| 35 | let formPrompt = "Enter the name for the new top-level project and select its project type:" | |
| 36 | let buttonTitle = "Continue" | |
| 37 | ||
| 38 | // DISPLAY THE FORM DIALOG | |
| 39 | formPromise = inputForm.show(formPrompt, buttonTitle) | |
| 40 | ||
| 41 | // VALIDATE FORM CONTENT | |
| 42 | inputForm.validate = function(formObject){ | |
| 43 | // EXTRACT VALUES FROM THE FORM’S VALUES OBJECT | |
| 44 | textValue = formObject.values['projectName'] | |
| 45 | return ((textValue) ? true:false) | |
| 46 | } | |
| 47 | ||
| 48 | // PERFORM PROCESSES USING FORM DATA | |
| 49 | formPromise.then(function(formObject){ | |
| 50 | textValue = formObject.values['projectName'] | |
| 51 | menuItemIndex = formObject.values['projectType'] | |
| 52 | // CREATE PROJECT AND MOVE TASKS | |
| 53 | project = new Project(textValue) | |
| 54 | moveTasks(selection.tasks, project) | |
| 55 | // SET THE PROJECT TYPE | |
| 56 | if (menuItemIndex === 1){ | |
| 57 | project.task.sequential = true | |
| 58 | } else if (menuItemIndex === 2){ | |
| 59 | project.containsSingletonActions = true | |
| 60 | } | |
| 61 | // SHOW THE PROJECT | |
| 62 | projID = project.id.primaryKey | |
| 63 | urlStr = "omnifocus:///task/" + projID | |
| 64 | URL.fromString(urlStr).call(reply => {}) | |
| 65 | }) | |
| 66 | ||
| 67 | // PROCESS FORM CANCELLATION | |
| 68 | formPromise.catch(function(err){ | |
| 69 | console.log("form cancelled", err.message) | |
| 70 | }) | |
| 71 | ||
| 72 | }); | |
| 73 | ||
| 74 | action.validate = function(selection, sender){ | |
| 75 | // selection options: tasks, projects, folders, tags | |
| 76 | return (selection.tasks.length > 0) | |
| 77 | }; | |
| 78 | ||
| 79 | return action; | |
| 80 | }(); | |
| 81 | _; | |
| Move Selected Tasks into New Action Group | ||
| 01 | /*{ | |
| 02 | "type": "action", | |
| 03 | "targets": ["omnifocus"], | |
| 04 | "author": "Otto Automator", | |
| 05 | "identifier": "com.omni-automation.move-selected-tasks-into-new-action", | |
| 06 | "version": "1.0", | |
| 07 | "description": "Move the selected tasks into a new top-level action group.", | |
| 08 | "label": "Move Selected Tasks into New Action Group", | |
| 09 | "shortLabel": "Move Tasks" | |
| 10 | }*/ | |
| 11 | var _ = function(){ | |
| 12 | var action = new PlugIn.Action(function(selection, sender){ | |
| 13 | // selection options: tasks, projects, folders, tags | |
| 14 | ||
| 15 | // CONSTRUCT THE FORM | |
| 16 | var inputForm = new Form() | |
| 17 | ||
| 18 | // CREATE FORM ELEMENTS: TEXT INPUT | |
| 19 | textField = new Form.Field.String("groupName", null, null) | |
| 20 | ||
| 21 | // CREATE FORM ELEMENT: OPTION MENU | |
| 22 | popupMenu = new Form.Field.Option( | |
| 23 | "actionType", | |
| 24 | "Action Type", | |
| 25 | [0, 1], | |
| 26 | ["Parallel","Sequential"], | |
| 27 | 0 | |
| 28 | ) | |
| 29 | ||
| 30 | // ADD THE ELEMENTS TO THE FORM | |
| 31 | inputForm.addField(textField) | |
| 32 | inputForm.addField(popupMenu) | |
| 33 | ||
| 34 | // DIALOG PROMPT AND OK BUTTON TITLE | |
| 35 | let formPrompt = "Enter the name for the new top-level action group and select its type:" | |
| 36 | let buttonTitle = "Continue" | |
| 37 | ||
| 38 | // DISPLAY THE FORM DIALOG | |
| 39 | formPromise = inputForm.show(formPrompt, buttonTitle) | |
| 40 | ||
| 41 | // VALIDATE FORM CONTENT | |
| 42 | inputForm.validate = function(formObject){ | |
| 43 | // EXTRACT VALUES FROM THE FORM’S VALUES OBJECT | |
| 44 | textValue = formObject.values['groupName'] | |
| 45 | return ((textValue) ? true:false) | |
| 46 | } | |
| 47 | ||
| 48 | // PERFORM PROCESSES USING FORM DATA | |
| 49 | formPromise.then(function(formObject){ | |
| 50 | textValue = formObject.values['groupName'] | |
| 51 | menuItemIndex = formObject.values['actionType'] | |
| 52 | ||
| 53 | taskGroup = new Task(textValue) | |
| 54 | moveTasks(selection.tasks, taskGroup) | |
| 55 | ||
| 56 | // SET THE PROJECT TYPE | |
| 57 | if (menuItemIndex === 1){ | |
| 58 | taskGroup.sequential = true | |
| 59 | } | |
| 60 | ||
| 61 | // SHOW THE ACTION | |
| 62 | taskID = taskGroup.id.primaryKey | |
| 63 | urlStr = "omnifocus:///task/" + taskID | |
| 64 | URL.fromString(urlStr).call(reply => {}) | |
| 65 | }) | |
| 66 | ||
| 67 | // PROCESS FORM CANCELLATION | |
| 68 | formPromise.catch(function(err){ | |
| 69 | console.log("form cancelled", err.message) | |
| 70 | }) | |
| 71 | ||
| 72 | }); | |
| 73 | ||
| 74 | action.validate = function(selection, sender){ | |
| 75 | // selection options: tasks, projects, folders, tags | |
| 76 | return (selection.tasks.length > 0) | |
| 77 | }; | |
| 78 | ||
| 79 | return action; | |
| 80 | }(); | |
| 81 | _; | |
This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.