From 4ad75897480e663ef812412f7ddaf25d79df2543 Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Fri, 12 Mar 2021 09:19:50 +0100 Subject: [PATCH] #1831 Add bulk delete and use task flags in waiting/my tasks pages --- .../scripts/controllers/case/CaseTasksCtrl.js | 32 +++++-- .../views/partials/case/tasks/toolbar.html | 4 +- .../views/partials/main/index-mytasks.html | 86 ++++++++++--------- .../partials/main/index-waitingtasks.html | 20 +++-- 4 files changed, 85 insertions(+), 57 deletions(-) diff --git a/frontend/app/scripts/controllers/case/CaseTasksCtrl.js b/frontend/app/scripts/controllers/case/CaseTasksCtrl.js index f9140f7abc..039b1aafaa 100755 --- a/frontend/app/scripts/controllers/case/CaseTasksCtrl.js +++ b/frontend/app/scripts/controllers/case/CaseTasksCtrl.js @@ -110,12 +110,7 @@ temp = _.uniq(_.pluck($scope.selection, 'status')); $scope.menu.reopen = temp.length === 1 && temp[0] === 'Completed'; - // Handle close menu item - // temp = _.uniq(_.pluck($scope.selection, 'status')); - // $scope.menu.close = temp.length === 1 && temp[0] === 'Open'; - // $scope.menu.reopen = temp.length === 1 && temp[0] === 'Resolved'; - - // $scope.menu.delete = $scope.selection.length > 0; + $scope.menu.delete = $scope.selection.length > 0; }; $scope.select = function(task) { @@ -312,6 +307,31 @@ return $scope.bulkUpdate(ids, {status: status}); } + $scope.bulkRemove = function() { + var ids = _.pluck($scope.selection, '_id'); + + ModalUtilsSrv.confirm('Delete selected tasks', 'Are you sure you want to delete the selected tasks?', { + okText: 'Yes, proceed', + flavor: 'danger' + }).then(function() { + return CaseTaskSrv.bulkUpdate(ids, {status: 'Cancel'}) + .then(function(/*responses*/) { + NotificationSrv.log('Selected tasks have been successfully removed', 'success'); + + _.each($scope.selection, function(task) { + $scope.$emit('tasks:task-removed', task); + }); + }) + .catch(function(err) { + NotificationSrv.error('Bulk remove tasks', err.data, err.status); + }); + }).catch(function(err) { + if(err && !_.isString(err)) { + NotificationSrv.error('Bulk remove tasks', err.data, err.status); + } + }) + } + // open task tab with its details $scope.startTask = function(task) { var taskId = task._id; diff --git a/frontend/app/views/partials/case/tasks/toolbar.html b/frontend/app/views/partials/case/tasks/toolbar.html index 7e3628d0c4..8fe46997a2 100644 --- a/frontend/app/views/partials/case/tasks/toolbar.html +++ b/frontend/app/views/partials/case/tasks/toolbar.html @@ -23,10 +23,10 @@
  • Close
  • - + diff --git a/frontend/app/views/partials/main/index-mytasks.html b/frontend/app/views/partials/main/index-mytasks.html index 61fb289b55..32aba54502 100644 --- a/frontend/app/views/partials/main/index-mytasks.html +++ b/frontend/app/views/partials/main/index-mytasks.html @@ -3,49 +3,53 @@
    No records
    - - - - - - - - + + + + + + + + + - - - - - + + + + + - - - + + + + + {{item.title}} + + +
    + Started +
    +
    + +
    + + + +
    SeverityGroupTaskDate
    SeverityGroupTaskDate
    - - {{value.group}} -
    - - - +
    + + + + {{item.group}} + -
    - Started -
    -
    - -
    -
    - {{value.startDate | shortDate}} -
    + {{item.startDate | shortDate}} +
    diff --git a/frontend/app/views/partials/main/index-waitingtasks.html b/frontend/app/views/partials/main/index-waitingtasks.html index 37c18e1d0f..15265aa687 100644 --- a/frontend/app/views/partials/main/index-waitingtasks.html +++ b/frontend/app/views/partials/main/index-waitingtasks.html @@ -5,6 +5,7 @@ + @@ -14,26 +15,29 @@ + ng-repeat="item in $vm.list.values"> + - +
    Severity Group Task
    + + - + {{value.group}}{{item.group}}
    - +