Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit dd30f64

Browse files
committed
Added 'add to project' and 'add label to task features'
1 parent 07a1567 commit dd30f64

File tree

9 files changed

+225
-66
lines changed

9 files changed

+225
-66
lines changed

CHANGELOG.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
### 3.0.0
4+
- [FEATURE] Add labels to your tasks
5+
- [FEATURE] Add a task to an existing project
6+
- [BREAKING] Changed the API
7+
38
### 2.0.1
49
- [FIX] Auto create missing workflow directory, thanks etaming!
510

@@ -13,13 +18,14 @@
1318
- [FEATURE]: Updated to Todoist API v7
1419

1520
### 1.0.1
16-
* [FIX] Undo bundle id change, since it's needed for updating packal
21+
- [FIX] Undo bundle id change, since it's needed for updating packal
1722

18-
### 1.0.0_  * [BREAKING]: changed bundle id from `com.alfred-workflow-todoist` tot `com.moranje.alfred-workflow-todoist`
19-
* [FEATURE]: Easier configuration with `todo:config {api token}, {language}, {max list items}`, see README.md for further reference
23+
### 1.0.0 
24+
- [BREAKING]: changed bundle id from `com.alfred-workflow-todoist` tot `com.moranje.alfred-workflow-todoist`
25+
- [FEATURE]: Easier configuration with `todo:config {api token}, {language}, {max list items}`, see README.md for further reference
2026

2127
### 0.6.0
22-
* [FEATURE]: List tasks using `todo` and mark a task done using navigation + ENTER
28+
- [FEATURE]: List tasks using `todo` and mark a task done using navigation + ENTER
2329

2430
### 0.5.0
25-
* initial release
31+
- initial release

README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ALFRED TODOIST WORKFLOW
2-
Add tasks to your [Todoist](https://todoist.com/ "Todoist") inbox or list upcoming tasks straight from [Alfred](https://www.alfredapp.com "Alfred"). I nicked the idea from [Ruben Schmidtmann](https://github.com/rubenschmidtmann "Ruben Schmidtmann")'s [todoist-alfred-workflow](https://github.com/rubenschmidtmann/todoist-alfred-workflow "todoist-alfred-workflow"), and further expanded on it. It uses Todoist `v7` API.
2+
Add tasks to your [Todoist](https://todoist.com/ "Todoist") inbox or list upcoming tasks straight from [Alfred](https://www.alfredapp.com "Alfred"). I nicked the idea from [Ruben Schmidtmann](https://github.com/rubenschmidtmann "Ruben Schmidtmann")'s [todoist-alfred-workflow](https://github.com/rubenschmidtmann/todoist-alfred-workflow "todoist-alfred-workflow"), and further expanded on it. It uses Todoist `v7` API. For this workflow to work you need version `3.x` of Alfred.
33

4-
The task listing feature relies on javascript (sorry no PHP, perl of ruby foo) which means it needs node.js to function (OSX javascript proved to be clunky for modules and file io). The task adding feature should work on any Mac OSX version.
4+
The task listing feature, adding project and labels to tasks relies on javascript (sorry no PHP, perl of ruby foo) which means it needs node.js to function (OSX javascript proved to be clunky for modules and file io). The task adding feature should work on any Mac OSX version.
55

66
## Installation
77
[Download](https://github.com/moranje/alfred-workflow-todoist/raw/master/dist/Alfred%20Workflow%20Todoist.alfredworkflow) and import workflow.
@@ -40,25 +40,42 @@ Uninstall Homebrew (terminal): _ruby -e "$(curl -fsSL https://raw.githubusercont
4040
![](https://raw.githubusercontent.com/moranje/alfred-workflow-todoist/master/images/add-task.png "Add a task to your Todoist Inbox")
4141

4242
**Add a task**
43-
`todo {task}, {date}, {priority}`
44-
Example: _todo Get milk, tomorrow @ 9, 3_
43+
`todo {task}, {date}, {project}` _{priority} and {labels} can go anywhere_
44+
Example: _todo Get stuff done, tomorrow @ 9, work_
45+
Example: _todo Build tree house, tomorrow @ 9, home !!2_
46+
Example: _todo Get milk, tomorrow @ 9, home @on_road @5min
4547

4648
### Task
4749
Can be any string as long as there are no comma's in it. Markdown in the string will be parsed, but anything else won't.
4850

4951
### Date
5052
See the [Todoist documentation](https://support.todoist.com/hc/en-us/articles/205325931-Dates-and-Times "Todoist documentation") for supported date formats.
5153

54+
### Project*
55+
Add task to an existing project. If no project is selected the task will be added to your inbox.
56+
57+
### Labels*
58+
You can now add labels to your tasks. Any string that has a `@` before it will be checked against your existing labels. If it matches (case insensitive) the label will be added. The labels can be added anywhere in the todo command so these are all valid:
59+
Example: _todo Get stuff done, tomorrow @ 9, work @delayed_
60+
Example: _todo Get stuff done , tomorrow @ 9 @delayed, work_
61+
Example: _todo Get stuff done @delayed, tomorrow @ 9, work @delayed_
62+
5263
### Priority
53-
A number between 1 and 4, where 1 is the lowest and 4 would be the highest priority.
64+
A number between 1 and 4, where 1 is the lowest and 4 would be the highest priority. The priority tags can be added anywhere in the todo command so these are all valid:
65+
Example: _todo Get stuff done, tomorrow @ 9, work !!2_
66+
Example: _todo Get stuff done , tomorrow @ 9 !!2, work_
67+
Example: _todo Get stuff done !!2, tomorrow @ 9, work_
68+
69+
*_Relies on node.js to work_
5470

71+
### Hacks
5572
Use a comma to separate the parameters, leading or trailing whitespace is ignored. If you wish to change the delimiter with which the parameters (task, date and priority) are separated, you'll need to change a line in the bash script. For instance if you'd like to use ';' as a delimiter, change:
5673
```bash
57-
IFS=',' read -r -a items <<< "{query}"
74+
IFS=',' read -r -a items <<< "query"
5875
```
5976
to:
6077
```bash
61-
IFS=':' read -r -a items <<< "{query}"
78+
IFS=':' read -r -a items <<< "query"
6279
```
6380

6481
![](https://raw.githubusercontent.com/moranje/alfred-workflow-todoist/master/images/list-tasks.png "List your Todoist tasks ")
461 Bytes
Binary file not shown.

images/add-task.png

2.24 KB
Loading

src/index.js

100644100755
Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,11 @@ var calls = {
5151
* Get a list of projects from Todoist.
5252
*
5353
* @author moranje <martieno@gmail.com>
54+
* @param {String} name The project's name.
5455
* @since 2016-07-04
5556
* @return {Object}
5657
*/
57-
getProjects: function() {
58-
var list = {
59-
items: []
60-
};
61-
58+
getProjects: function( name ) {
6259
todoist.getProjects( settings.token, function( res ) {
6360
var response = JSON.parse( res );
6461
var projects = {};
@@ -67,9 +64,41 @@ var calls = {
6764
projects[ project.name.toLowerCase() ] = project.id;
6865
} );
6966

70-
settings.projects = projects;
67+
if ( name ) {
68+
return echo( projects[ name ] );
69+
}
70+
71+
return echo( projects );
72+
}, function( err ) {
73+
// The 'Error' suffix signals something has failed to the notification
74+
// handler
75+
console.log( 'Error', err );
76+
} );
77+
},
78+
79+
/**
80+
* Get a list of labels from Todoist.
81+
*
82+
* @author moranje <martieno@gmail.com>
83+
* @param {String} string The label names string.
84+
* @since 2016-07-04
85+
* @return {Object}
86+
*/
87+
getLabels: function( string ) {
88+
todoist.getLabels( settings.token, function( res ) {
89+
var response = JSON.parse( res );
90+
var names = string.split( ',' );
91+
var labels = [];
92+
93+
response.labels.forEach( function( label, index ) {
94+
names.forEach( function ( name ) {
95+
if ( string && name === label.name ) {
96+
labels.push( label.id );
97+
}
98+
});
99+
} );
71100

72-
return echo( 'Projects updated' );
101+
return echo( labels );
73102
}, function( err ) {
74103
// The 'Error' suffix signals something has failed to the notification
75104
// handler
@@ -81,11 +110,12 @@ var calls = {
81110
* Mark a todo item 'done'.
82111
*
83112
* @author moranje <martieno@gmail.com>
113+
* @param {String|Number} id The task's id.
84114
* @since 2016-07-03
85115
* @return {String}
86116
*/
87-
markDone: function() {
88-
todoist.markTaskDone( arg, settings.token, function( res ) {
117+
markDone: function( id ) {
118+
todoist.markTaskDone( id, settings.token, function( res ) {
89119
// Notification message.
90120
echo( 'Done, done and done!' );
91121
}, function( err ) {
@@ -111,4 +141,4 @@ function echo( response ) {
111141
/**
112142
* This returns the call to the Todoist API
113143
*/
114-
calls[ call ]();
144+
calls[ call ]( arg );

0 commit comments

Comments
 (0)