(js) New action to mark task as completed

Fixes #4531
pull/229/merge
Francis Lachapelle 2018-08-31 16:45:03 -04:00
parent 3881bc408d
commit 7aa3e1f160
3 changed files with 37 additions and 6 deletions

1
NEWS
View File

@ -3,6 +3,7 @@
Enhancements
- [web] prohibit subscribing a user with no rights
- [web] new button to mark a task as completed (#4531)
Bug fixes
- [web] include mail account name in form validation (#4532)

View File

@ -30,6 +30,11 @@
</md-menu-item>
</md-menu-content>
</md-menu>
<md-button class="sg-icon-button"
ng-show="editor.component.status != 'completed'"
ng-click="editor.component.markAsCompleted()">
<md-icon label:aria-label="Mark Completed">check</md-icon>
</md-button>
<md-button class="sg-icon-button" ng-click="editor.close()">
<md-icon label:aria-label="Close">close</md-icon>
</md-button>
@ -74,19 +79,19 @@
</div>
</md-list-item>
<!-- status -->
<md-list-item ng-show="::(editor.component.status == 'completed')">
<md-list-item ng-show="editor.component.status == 'completed'">
<md-icon>check</md-icon>
<p>{{::editor.component.localizedCompletedDate}} {{::editor.component.localizedCompletedTime}}</p>
<p>{{editor.component.localizedCompletedDate}} {{editor.component.localizedCompletedTime}}</p>
</md-list-item>
<md-list-item ng-show="::editor.component.showPercentComplete()">
<md-list-item ng-show="editor.component.showPercentComplete()">
<md-icon>timelapse</md-icon>
<p>{{::editor.component.percentComplete}} %</p>
<p>{{editor.component.percentComplete}} %</p>
</md-list-item>
<md-list-item ng-show="::(editor.component.status == 'cancelled')">
<md-list-item ng-show="editor.component.status == 'cancelled'">
<md-icon>close</md-icon>
<p><var:string label:value="status_CANCELLED"/></p>
</md-list-item>
<md-list-item ng-show="::(editor.component.status == 'needs-action')">
<md-list-item ng-show="editor.component.status == 'needs-action'">
<md-icon>error_outline</md-icon>
<p><var:string label:value="status_NEEDS-ACTION"/></p>
</md-list-item>

View File

@ -758,6 +758,31 @@
this.status != 'cancelled');
};
/**
* @function markAsCompleted
* @memberof Component.prototype
* @desc Mark the task as completed.
* @returns a promise of the HTTP operation
*/
Component.prototype.markAsCompleted = function() {
var _this = this, dlp;
if (this.type == 'task') {
dlp = Component.$Preferences.$mdDateLocaleProvider;
this.percentComplete = 100;
this.completed = new Date();
this.completed.$dateFormat = Component.$Preferences.defaults.SOGoLongDateFormat;
this.status = 'completed';
this.localizedCompletedDate = dlp.formatDate(this.completed);
this.localizedCompletedTime = dlp.formatTime(this.completed);
return this.$save().catch(function() {
_this.$reset();
});
}
else {
return Component.$q.reject('Only tasks can be mark as completed');
}
};
/**
* @function coversFreeBusy
* @memberof Component.prototype