11module = angular . module ( 'App.Task' ) ;
22module . factory ( 'Task' , ( BaseObject , $http ) => {
33 class Task extends BaseObject {
4+ /**
5+ * Retrieve tasks from a project
6+ * @param {mixed } projectId
7+ * @returns {Promise<task[]> }
8+ */
49 static list ( projectId ) {
510 return $http . get ( '/api/tasks' , { params : { project_id : projectId } } )
611 . then ( response => response . data . map ( task => new Task ( task ) ) ) ;
712 }
813
914
1015 /**
11- * task.create() - Creates a new task
16+ * Creates a new task
1217 *
1318 * @note Demonstrates how to have the create wait until uploading is complete
1419 * Normally you might have to wait until the attachment is done before enabling
@@ -18,6 +23,7 @@ module.factory( 'Task', (BaseObject, $http) => {
1823 * You could check either the `task.saving`, `task.creating`, or `task.uploading`
1924 * properties for truthy value when the user tries to navigate away from the page.
2025 *
26+ * @returns {Promise }
2127 */
2228 create ( ) {
2329 // wraps `this.uploading` in a promise that resolves immediately if it is `null` or waits for the promise
@@ -28,19 +34,26 @@ module.factory( 'Task', (BaseObject, $http) => {
2834 ) ;
2935 }
3036
37+ /**
38+ * Update the task
39+ *
40+ * @returns {Promise }
41+ */
3142 update ( ) {
3243 // wraps `this.uploading` in a promise that resolves immediately if it is `null` or waits for the promise
3344 return this . cache ( 'updating' , ( ) =>
3445 $q . when ( this . uploading )
35- . then ( ( ) => $http . post ( `/api/tasks/${ this . id } ` , this ) ) // uploading callback
46+ . then ( ( ) => $http . put ( `/api/tasks/${ this . id } ` , this ) ) // uploading callback
3647 . then ( response => Object . assign ( this , response . data ) ) // creating callback
3748 ) ;
3849 }
3950
4051 /**
41- * task.upload() - Allow you to upload attachments to issues
52+ * Allow you to upload attachments to tasks
4253 *
4354 * @note Added to demonstrate clean ways to have 1 method wait for another method to finish
55+ * @param {mixed } attachment
56+ * @returns {Promise }
4457 */
4558 upload ( attachment ) {
4659 return this . cache ( 'uploading' , ( ) =>
0 commit comments