-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate Numbered Children.omnijs
41 lines (35 loc) · 1.11 KB
/
Create Numbered Children.omnijs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* global PlugIn Form Task */
/*{
"type": "action",
"targets": ["omnifocus"],
"author": "Kaitlin Salzke",
"identifier": "com.KaitlinSalzke.createdNumberedChildren",
"version": "1.1.0",
"description": "Add numbered tasks as children of selected",
"label": "Create Numbered Children",
"shortLabel": "Create Numbered Children",
"image": "list.number"
}*/
(() => {
const action = new PlugIn.Action(function (selection, sender) {
const inputForm = new Form()
const textField = new Form.Field.String('textInput', 'Number to Create', null)
inputForm.addField(textField)
const formPrompt = 'How many to add?'
const formPromise = inputForm.show(formPrompt, 'Continue')
formPromise.then(function (formObject) {
const maxNumber = parseInt(formObject.values.textInput)
selection.tasks.forEach(function (task) {
for (let i = 1; i <= maxNumber; i++) {
console.log(i)
/* eslint-disable no-new */
new Task(String(i), task)
}
})
})
})
action.validate = function (selection, sender) {
return selection.tasks.length > 0
}
return action
})()