From: Galen Charlton Date: Fri, 7 Jul 2017 20:06:31 +0000 (-0400) Subject: webstaff: implement deleting multiple spts X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bb790908131c704d130d64c5fa66c2801edd0605;p=working%2FEvergreen.git webstaff: implement deleting multiple spts Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/templates/staff/admin/serials/pattern_template.tt2 b/Open-ILS/src/templates/staff/admin/serials/pattern_template.tt2 index cf90693db9..8ff79289c4 100644 --- a/Open-ILS/src/templates/staff/admin/serials/pattern_template.tt2 +++ b/Open-ILS/src/templates/staff/admin/serials/pattern_template.tt2 @@ -27,12 +27,11 @@ id-field="id" idl-class="spt" grid-controls="gridControls" - features="-multiselect" persist-key="admin.serials.pattern_template"> - - + + diff --git a/Open-ILS/src/templates/staff/serials/share/serials_strings.tt2 b/Open-ILS/src/templates/staff/serials/share/serials_strings.tt2 index f4ccc7070f..80f32ae3c5 100644 --- a/Open-ILS/src/templates/staff/serials/share/serials_strings.tt2 +++ b/Open-ILS/src/templates/staff/serials/share/serials_strings.tt2 @@ -18,6 +18,10 @@ angular.module('egCoreMod').run(['egStrings', function(s) { s.CHRON_LABEL_WEEK = "[% l('Week') %]"; s.CHRON_LABEL_DAY = "[% l('Day') %]"; s.CHRON_LABEL_HOUR = "[% l('Hour') %]"; + s.EG_CONFIRM_DELETE_PATTERN_TEMPLATE_TITLE = "[% l('Confirm Prediction Pattern Template Deletion') %]"; + s.EG_CONFIRM_DELETE_PATTERN_TEMPLATE_BODY = "[% l('Delete {{count}} template(s)?') %]"; + s.PATTERN_TEMPLATE_SUCCESS_DELETE = "[% l('Deleted prediation pattern template(s)') %]"; + s.PATTERN_TEMPLATE_FAIL_DELETE = "[% l('Failed to delete prediction template(s)') %]"; }]); diff --git a/Open-ILS/web/js/ui/default/staff/admin/serials/pattern_template.js b/Open-ILS/web/js/ui/default/staff/admin/serials/pattern_template.js index 603ecc3349..c20956fae1 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/serials/pattern_template.js +++ b/Open-ILS/web/js/ui/default/staff/admin/serials/pattern_template.js @@ -3,9 +3,9 @@ angular.module('egAdminConfig', .controller('PatternTemplate', ['$scope','$q','$timeout','$location','$window','$uibModal','egCore','egGridDataProvider', - 'egConfirmDialog', + 'egConfirmDialog','ngToast', function($scope , $q , $timeout , $location , $window , $uibModal , egCore , egGridDataProvider , - egConfirmDialog) { + egConfirmDialog , ngToast) { egCore.startup.go(); // standalone mode requires manual startup @@ -13,6 +13,12 @@ function($scope , $q , $timeout , $location , $window , $uibModal , egCore , egG spawn_editor(); } + $scope.need_one_selected = function() { + var items = $scope.gridControls.selectedItems(); + if (items.length == 1) return false; + return true; + }; + $scope.edit_record = function(items) { if (items.length != 1) return; spawn_editor(items[0].id); @@ -79,17 +85,31 @@ function($scope , $q , $timeout , $location , $window , $uibModal , egCore , egG }); } - $scope.delete_record = function(selected) { + $scope.delete_selected = function(selected) { if (!selected || !selected.length) return; + var ids = selected.map(function(rec) { return rec.id }); - egCore.pcrud.retrieve('spt', selected[0].id).then(function(rec) { - egConfirmDialog.open( - egCore.strings.EG_CONFIRM_DELETE_RECORD_TITLE, - egCore.strings.EG_CONFIRM_DELETE_RECORD_BODY, - { id : rec.id() } // TODO replace with selector if available? - ).result.then(function() { - egCore.pcrud.remove(rec).then(function() { + egConfirmDialog.open( + egCore.strings.EG_CONFIRM_DELETE_PATTERN_TEMPLATE_TITLE, + egCore.strings.EG_CONFIRM_DELETE_PATTERN_TEMPLATE_BODY, + { count : ids.length } + ).result.then(function() { + var promises = []; + var list = []; + angular.forEach(selected, function(rec) { + promises.push( + egCore.pcrud.retrieve('spt', rec.id).then(function(r) { + list.push(r); + }) + ); + }) + $q.all(promises).then(function() { + egCore.pcrud.remove(list).then(function() { + ngToast.success(egCore.strings.PATTERN_TEMPLATE_SUCCESS_DELETE); $scope.gridControls.refresh(); + }, + function() { + ngToast.success(egCore.strings.PATTERN_TEMPLATE_FAIL_DELETE); }); }); });