Skip to content

Commit

Permalink
#1844 Allow cancel action request from tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Mar 17, 2021
1 parent 58cfda3 commit fa79c88
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -38,6 +45,7 @@
onUpdateProfile: '&',
onDelete: '&',
onRequireAction: '&',
onCancelRequireAction: '&',
permissions: '='
}
});
Expand Down
28 changes: 25 additions & 3 deletions frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
});
};
Expand Down
5 changes: 4 additions & 1 deletion frontend/app/views/components/sharing/task/sharing-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<th>Organisation</th>
<th width="250">Profile</th>
<th width="160">Shared At</th>
<th width="120" class="text-right" if-permission="manageTask" allowed="{{$ctrl.permissions}}"></th>
<th width="150" class="text-right" if-permission="manageTask" allowed="{{$ctrl.permissions}}"></th>
<th width="80" class="text-right" if-permission="manageShare" allowed="{{$ctrl.permissions}}">Actions</th>
</thead>
<tbody>
Expand Down Expand Up @@ -43,6 +43,9 @@
<span ng-if="!!!share.actionRequired" class="clickable text-primary" ng-click="$ctrl.requireAction(share.organisationName)">
<i class="fa fa-exclamation-triangle"></i> Require Action
</span>
<span ng-if="!!share.actionRequired" class="clickable text-danger" ng-click="$ctrl.cancelRequireAction(share.organisationName)">
<i class="fa fa-exclamation-triangle"></i> Cancel Request
</span>
</td>

<td class="text-right" if-permission="manageShare" allowed="{{$ctrl.permissions}}">
Expand Down
1 change: 1 addition & 0 deletions frontend/app/views/partials/case/case.tasks.item.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ <h4 class="vpad10 text-primary">Task sharing</h4>
shares="shares"
read-only="true"
on-require-action="markShareAsActionRequired(task, org)"
on-cancel-require-action="markShareAsActionDone(task, org)"
on-delete="removeShare(share)"
permissions="userPermissions"
></task-sharing-list>
Expand Down

0 comments on commit fa79c88

Please sign in to comment.