From dfc51dcab1c9f77a31276af84ac92eb99bc0f7ef Mon Sep 17 00:00:00 2001 From: Tuomas Pesola Date: Thu, 7 Apr 2022 15:27:00 +0300 Subject: [PATCH 1/5] Multi-select rows in instances grid --- .../scripts/process-instances-controllers.js | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/scripts/process-instances-controllers.js b/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/scripts/process-instances-controllers.js index bd1a81cfc30..b4b7c7cc431 100644 --- a/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/scripts/process-instances-controllers.js +++ b/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/scripts/process-instances-controllers.js @@ -1,5 +1,5 @@ /* Copyright 2005-2015 Alfresco Software, Ltd. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,7 +20,7 @@ flowableAdminApp.controller('ProcessInstancesController', ['$rootScope', '$scope function ($rootScope, $scope, $http, $timeout, $location, $translate, $q, gridConstants) { $rootScope.navigation = {main: 'process-engine', sub: 'instances'}; - + $scope.filter = {}; $scope.processInstances = {}; $scope.definitionCacheLoaded = false; @@ -28,6 +28,14 @@ flowableAdminApp.controller('ProcessInstancesController', ['$rootScope', '$scope $scope.variableFilterTypes = FlowableAdmin.Utils.variableFilterTypes; $scope.variableFilterOperators = FlowableAdmin.Utils.variableFilterOperators; + $scope.moveToInstanceButtonTemplate = ` +
+ +
+ ` + var filterConfig = { url: FlowableAdmin.Config.adminContextRoot + 'rest/admin/process-instances', method: 'POST', @@ -58,7 +66,7 @@ flowableAdminApp.controller('ProcessInstancesController', ['$rootScope', '$scope {name: 'PROCESS-INSTANCES.SORT.ID', id: 'processInstanceId'}, {name: 'PROCESS-INSTANCES.SORT.START-TIME', id: 'startTime'} ], - + options: { finished: [ {name: 'PROCESS-INSTANCES.FILTER.STATUS-ANY', value: ''}, @@ -101,10 +109,10 @@ flowableAdminApp.controller('ProcessInstancesController', ['$rootScope', '$scope $rootScope.filters.instanceFilter = $scope.filter; } - $scope.processInstanceSelected = function(processInstance) { - if (processInstance && processInstance.getProperty('id')) { - $location.path('/process-instance/' + processInstance.getProperty('id')); - } + $scope.processInstanceSelected = function(id) { + if(!id) return; + + $location.path('/process-instance/' + id); }; if(!$scope.filter.properties.variables) { @@ -225,16 +233,18 @@ flowableAdminApp.controller('ProcessInstancesController', ['$rootScope', '$scope data: 'processInstances.data', enableRowReordering: true, enableColumnResize: true, - multiSelect: false, - keepLastSelected : false, + showSelectionCheckbox: true, + selectWithCheckboxOnly: false, + selectedItems: [], rowHeight: 36, - afterSelectionChange: $scope.processInstanceSelected, columnDefs: [ { field: 'id', displayName: headers[0], cellTemplate: gridConstants.defaultTemplate}, { field: 'businessKey', displayName: headers[1], cellTemplate: gridConstants.defaultTemplate}, { field: 'processDefinition.name', displayName: headers[2], cellTemplate: gridConstants.defaultTemplate}, { field: 'startTime', displayName: headers[3], cellTemplate: gridConstants.dateTemplate}, - { field: 'endTime', displayName: headers[4], cellTemplate: gridConstants.dateTemplate}] + { field: 'endTime', displayName: headers[4], cellTemplate: gridConstants.dateTemplate}, + { field: 'actions', displayName: "", cellTemplate: $scope.moveToInstanceButtonTemplate, width: 40} + ] }; }); @@ -256,7 +266,7 @@ flowableAdminApp.controller('ProcessInstancesController', ['$rootScope', '$scope if ($scope.filter.processDefinition && $scope.filter.processDefinition !== '-1') { $scope.filter.properties.processDefinitionId = $scope.filter.processDefinition; $scope.filter.refresh(); - + } else { var tempProcessDefinitionId = $scope.filter.properties.processDefinitionId; $scope.filter.properties.processDefinitionId = null; From cc229f2f22fe9c7bd793dc4e25b9f55fbbf5e9ae Mon Sep 17 00:00:00 2001 From: Tuomas Pesola Date: Thu, 7 Apr 2022 15:29:42 +0300 Subject: [PATCH 2/5] Delete multiple processes from instances grid --- .../scripts/process-instances-controllers.js | 94 ++++++++++++++++++- .../views/process-instances-delete-popup.html | 25 +++++ .../static/admin/views/process-instances.html | 6 ++ 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/views/process-instances-delete-popup.html diff --git a/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/scripts/process-instances-controllers.js b/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/scripts/process-instances-controllers.js index b4b7c7cc431..7531092e49c 100644 --- a/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/scripts/process-instances-controllers.js +++ b/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/scripts/process-instances-controllers.js @@ -16,8 +16,8 @@ /* Controllers */ -flowableAdminApp.controller('ProcessInstancesController', ['$rootScope', '$scope', '$http', '$timeout', '$location', '$translate', '$q', 'gridConstants', - function ($rootScope, $scope, $http, $timeout, $location, $translate, $q, gridConstants) { +flowableAdminApp.controller('ProcessInstancesController', ['$rootScope', '$scope', '$http','$route', '$timeout', '$location', '$modal', '$translate', '$q', 'gridConstants', + function ($rootScope, $scope, $http, $route, $timeout, $location, $modal, $translate, $q, gridConstants) { $rootScope.navigation = {main: 'process-engine', sub: 'instances'}; @@ -280,4 +280,92 @@ flowableAdminApp.controller('ProcessInstancesController', ['$rootScope', '$scope $scope.filter.refresh(); }); - }]); + // Dialogs + $scope.deleteProcessInstances = function () { + var action = "delete"; + + var modalInstance = $modal.open({ + templateUrl: 'views/process-instances-delete-popup.html', + controller: 'DeleteProcessesModalInstanceCtrl', + resolve: { + processes: function () { + return $scope.gridInstances.selectedItems; + }, + action: function () { + return action; + } + } + }); + + modalInstance.result.then(function (deleteProcessInstances) { + if (deleteProcessInstances) { + $scope.addAlert($translate.instant('ALERT.PROCESS-INSTANCES.DELETED', $scope.gridInstances.selectedItems.length), 'info'); + $route.reload(); + } + }); + }; +}]); + +flowableAdminApp.controller('DeleteProcessesModalInstanceCtrl', + ['$rootScope', '$scope', '$modalInstance', '$http', 'processes', 'action', function ($rootScope, $scope, $modalInstance, $http, processes, action) { + + $scope.processes = processes; + $scope.action = action; + $scope.status = { + loading: false, + successfullyTerminated: [], + successfullyDeleted: [], + failed: [] + }; + $scope.model = {}; + + $scope.ok = async function () { + $scope.status.loading = true; + var dataForPost = {action: "terminate", deleteReason: $translate.instant('PROCESS-INSTANCES.POPUP.DELETE.DELETE-REASON')}; + + // terminate + var terminatedPromises = Promise.all( + $scope.processes.map( async process => { + await $http({ + method: 'POST', url: FlowableAdmin.Config.adminContextRoot + 'rest/admin/process-instances/' + process.id, + data: dataForPost + }).success(function (data, status, headers, config) { + $scope.status.successfullyTerminated.push(process); + }).error(function (data, status, headers, config) { + $scope.status.failed.push(process); + }); + }) + ) + await terminatedPromises; + + // delete all succesfully terminated + dataForPost.action = "delete" + var deletedPromises = Promise.all( + $scope.status.successfullyTerminated.map(async process => { + await $http({ + method: 'POST', url: FlowableAdmin.Config.adminContextRoot + 'rest/admin/process-instances/' + process.id, + data: dataForPost + }).success(function (data, status, headers, config) { + $scope.status.successfullyDeleted.push(process); + }).error(function (data, status, headers, config) { + $scope.status.failed.push(process) + }); + }) + ) + await deletedPromises; + $scope.status.loading = false + + if($scope.status.failed.length > 0){ + $modalInstance.close(false); + } + else{ + $modalInstance.close(true); + } + }; + + $scope.cancel = function () { + if (!$scope.status.loading) { + $modalInstance.dismiss('cancel'); + } + }; +}]); diff --git a/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/views/process-instances-delete-popup.html b/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/views/process-instances-delete-popup.html new file mode 100644 index 00000000000..d7b29bd5d96 --- /dev/null +++ b/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/views/process-instances-delete-popup.html @@ -0,0 +1,25 @@ + + + + \ No newline at end of file diff --git a/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/views/process-instances.html b/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/views/process-instances.html index 1cb52f7845d..244e3dd2c85 100644 --- a/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/views/process-instances.html +++ b/modules/flowable-ui/flowable-ui-admin-frontend/src/main/resources/static/admin/views/process-instances.html @@ -4,6 +4,12 @@
+
+ +
+