From 7aa3e1f1609ce744a4cb3557c3a6af9f1fc4f59c Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 31 Aug 2018 16:45:03 -0400 Subject: [PATCH] (js) New action to mark task as completed Fixes #4531 --- NEWS | 1 + .../SchedulerUI/UIxTaskViewTemplate.wox | 17 ++++++++----- .../js/Scheduler/Component.service.js | 25 +++++++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index eea797913..e1c14cc53 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/UI/Templates/SchedulerUI/UIxTaskViewTemplate.wox b/UI/Templates/SchedulerUI/UIxTaskViewTemplate.wox index 575292e13..975bd7202 100644 --- a/UI/Templates/SchedulerUI/UIxTaskViewTemplate.wox +++ b/UI/Templates/SchedulerUI/UIxTaskViewTemplate.wox @@ -30,6 +30,11 @@ + + check + close @@ -74,19 +79,19 @@ - + check -

{{::editor.component.localizedCompletedDate}} {{::editor.component.localizedCompletedTime}}

+

{{editor.component.localizedCompletedDate}} {{editor.component.localizedCompletedTime}}

- + timelapse -

{{::editor.component.percentComplete}} %

+

{{editor.component.percentComplete}} %

- + close

- + error_outline

diff --git a/UI/WebServerResources/js/Scheduler/Component.service.js b/UI/WebServerResources/js/Scheduler/Component.service.js index eef155864..1971527c4 100644 --- a/UI/WebServerResources/js/Scheduler/Component.service.js +++ b/UI/WebServerResources/js/Scheduler/Component.service.js @@ -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