From fa79c88e4b23deaa988477e3c550d6a83a861694 Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Wed, 17 Mar 2021 12:21:43 +0100 Subject: [PATCH] #1844 Allow cancel action request from tasks --- .../components/sharing/task/SharingListCmp.js | 8 ++++++ .../controllers/case/CaseTasksItemCtrl.js | 28 +++++++++++++++++-- .../components/sharing/task/sharing-list.html | 5 +++- .../views/partials/case/case.tasks.item.html | 1 + 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/frontend/app/scripts/components/sharing/task/SharingListCmp.js b/frontend/app/scripts/components/sharing/task/SharingListCmp.js index fc3930fc38..39378a0be7 100644 --- a/frontend/app/scripts/components/sharing/task/SharingListCmp.js +++ b/frontend/app/scripts/components/sharing/task/SharingListCmp.js @@ -25,6 +25,13 @@ org: org }); }; + + this.cancelRequireAction = function(org) { + this.onCancelRequireAction({ + task: self.task, + org: org + }); + } }, controllerAs: '$ctrl', templateUrl: 'views/components/sharing/task/sharing-list.html', @@ -38,6 +45,7 @@ onUpdateProfile: '&', onDelete: '&', onRequireAction: '&', + onCancelRequireAction: '&', permissions: '=' } }); diff --git a/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js b/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js index d214fec5a3..1812852b8c 100644 --- a/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js +++ b/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js @@ -382,7 +382,7 @@ }; $scope.markShareAsActionRequired = function(task, org) { - CaseTaskSrv.promtForActionRequired('Require Action', 'Would you like to add a task log before requesting action?') + CaseTaskSrv.promtForActionRequired('Require Action', 'Would you like to add a task log before marking the required action as DONE?') .then(function(response) { if(response === 'skip-log') { return $q.resolve(); @@ -394,11 +394,33 @@ return CaseTaskSrv.markAsActionRequired(task._id, org); }) .then(function() { - NotificationSrv.log('The task\'s required action flag has been set for organisation ' + org, 'success'); + NotificationSrv.log('The task\'s required action is completed', 'success'); }) .catch(function(err) { if(err && !_.isString(err)) { - NotificationSrv.error('Error', 'Task request action failed', err.status); + NotificationSrv.error('Error', 'Task required action failed to be marked as done', err.status); + } + }); + }; + + $scope.markShareAsActionDone = function(task, org) { + CaseTaskSrv.promtForActionRequired('Require Action', 'Would you like to add a task log before marking the required action as DONE?') + .then(function(response) { + if(response === 'skip-log') { + return $q.resolve(); + } else { + return $scope.showAddLog('Please add a task log'); + } + }) + .then(function() { + return CaseTaskSrv.markAsDone(task._id, org); + }) + .then(function() { + NotificationSrv.log('The task\'s required action is completed', 'success'); + }) + .catch(function(err) { + if(err && !_.isString(err)) { + NotificationSrv.error('Error', 'Task required action failed to be marked as done', err.status); } }); }; diff --git a/frontend/app/views/components/sharing/task/sharing-list.html b/frontend/app/views/components/sharing/task/sharing-list.html index a500758f41..51d11f7547 100644 --- a/frontend/app/views/components/sharing/task/sharing-list.html +++ b/frontend/app/views/components/sharing/task/sharing-list.html @@ -11,7 +11,7 @@ Organisation Profile Shared At - + Actions @@ -43,6 +43,9 @@ Require Action + + Cancel Request + diff --git a/frontend/app/views/partials/case/case.tasks.item.html b/frontend/app/views/partials/case/case.tasks.item.html index 4edd2e65d3..6190531c0e 100644 --- a/frontend/app/views/partials/case/case.tasks.item.html +++ b/frontend/app/views/partials/case/case.tasks.item.html @@ -256,6 +256,7 @@

Task sharing

shares="shares" read-only="true" on-require-action="markShareAsActionRequired(task, org)" + on-cancel-require-action="markShareAsActionDone(task, org)" on-delete="removeShare(share)" permissions="userPermissions" >