From 88210deb0363c78bb746ad9d6e66ddfb45645dd4 Mon Sep 17 00:00:00 2001 From: Bhagya Date: Sat, 17 Oct 2020 23:41:42 +0200 Subject: [PATCH] Adding support for unassigned projects --- info.plist | 14 ++++++++++++-- projects.js | 7 +++++++ readme.md | 3 +++ tasks.js | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/info.plist b/info.plist index 81d87da..c174421 100644 --- a/info.plist +++ b/info.plist @@ -171,11 +171,21 @@ script ## Start Task -curl -X "POST" "https://web.timingapp.com/api/v1/time-entries/start" \ +unassigned="Unassigned" + +if [ "$project" != "$unassigned" ]; then + curl -X "POST" "https://web.timingapp.com/api/v1/time-entries/start" \ + -H "Authorization: Bearer ${token}" \ + -H 'Accept: application/json' \ + -H 'Content-Type: application/json' \ + -d "{\"title\": \"${task}\",\"project\": \"${project}\"}" +else + curl -X "POST" "https://web.timingapp.com/api/v1/time-entries/start" \ -H "Authorization: Bearer ${token}" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ - -d "{\"title\": \"${task}\",\"project\": \"${project}\"}" + -d "{\"title\": \"${task}\"}" +fi scriptargtype 1 scriptfile diff --git a/projects.js b/projects.js index 6f7a948..8930f9f 100644 --- a/projects.js +++ b/projects.js @@ -21,6 +21,13 @@ fetch('https://web.timingapp.com/api/v1/projects', { arg: pr.title }; }); + //insert unassigned project at top + data.unshift({ + uid: 0, + title: "Unassigned", + autocomplete: "Unassigned", + arg: "Unassigned" + }); output(inputMatches(data, 'title')); }); diff --git a/readme.md b/readme.md index 4e905a0..36a9b20 100644 --- a/readme.md +++ b/readme.md @@ -27,3 +27,6 @@ You can create a new task or select the existing one (project will be selected a ## License MIT © [skibitsky](http://skibitsky.com) + +## Contributors +- Bhagya Silva (github.com/bhagyas) diff --git a/tasks.js b/tasks.js index e527451..da66b48 100644 --- a/tasks.js +++ b/tasks.js @@ -26,7 +26,7 @@ fetch('https://web.timingapp.com/api/v1/time-entries', { var task = inputMatches( sortedData.map(t => { - const project = t.project.title; + const project = t.project ? t.project.title : "Unassigned"; const title = (t.title) ? t.title : project; return { title: title,