From: Mike Rylander Date: Tue, 16 May 2017 18:40:02 +0000 (-0400) Subject: webstaff: Confirm before deleting; Allow prediction from empty list X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1e6a314d4488396a254080b428e9002ef4412729;p=working%2FEvergreen.git webstaff: Confirm before deleting; Allow prediction from empty list Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/templates/staff/serials/index.tt2 b/Open-ILS/src/templates/staff/serials/index.tt2 index 0555ed4cf6..efa0b0a025 100644 --- a/Open-ILS/src/templates/staff/serials/index.tt2 +++ b/Open-ILS/src/templates/staff/serials/index.tt2 @@ -26,6 +26,9 @@ angular.module('egCoreMod').run(['egStrings', function(s) { s.SERIALS_EDIT_SISS_HC = "[% l('Edit issue information') %]"; s.SERIALS_ISSUANCE_PREDICT = "[% l('Predict New Issues: Initial Values') %]"; s.SERIALS_ISSUANCE_ADD = "[% l('Add folloing issue') %]"; + s.CONFIRM_DELETE_ITEMS = "[% l('Delete selected items?') %]"; + s.CONFIRM_DELETE_ITEMS_MESSAGE = "[% l('Will delete {{items}} items') %]"; + }]); [% END %] diff --git a/Open-ILS/src/templates/staff/serials/t_view_items_grid.tt2 b/Open-ILS/src/templates/staff/serials/t_view_items_grid.tt2 index 0fed1a1924..22afd4a059 100644 --- a/Open-ILS/src/templates/staff/serials/t_view_items_grid.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_view_items_grid.tt2 @@ -17,7 +17,10 @@ - + {{item.issuance.date_published|date:'shortDate'}} + + {{item.date_expected|date:'shortDate'}} + {{item.date_received|date:'shortDate'}} diff --git a/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js b/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js index 9b854bdd45..745d2dc650 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js +++ b/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js @@ -11,9 +11,9 @@ angular.module('egSerialsAppDep') templateUrl: './serials/t_view_items_grid', controller: ['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider', - '$uibModal','ngToast', + '$uibModal','ngToast','egConfirmDialog', function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , - $uibModal , ngToast) { + $uibModal , ngToast , egConfirmDialog) { $scope.svc = egSerialsCoreSvc; // just for debugging @@ -37,6 +37,38 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , } }); + $scope.delete_items = function (items) { + var list = []; + + angular.forEach(items, function (i) { + var obj = egCore.idl.fromHash('sitem',i); + obj.isdeleted(1); + obj.stream(obj.stream().id); // API wants scalar or FM object + list.push(obj); + }); + + egConfirmDialog.open( + egCore.strings.CONFIRM_DELETE_ITEMS, + egCore.strings.CONFIRM_DELETE_ITEMS_MESSAGE, + {items : list.length} + ).result.then(function () { + return egCore.net.request( + 'open-ils.serial', + 'open-ils.serial.item.fleshed.batch.update', + egCore.auth.token(), + list + ).then( function(resp) { + var evt = egCore.evt.parse(resp); + if (evt) { // any way to just throw or return this to the error handler? + ngToast.danger(egCore.strings.SERIALS_ISSUANCE_FAIL_SAVE); + } else { + ngToast.success(egCore.strings.SERIALS_ISSUANCE_SUCCESS_SAVE); + return reload($scope.ssubId); + } + }); + }); + } + $scope.edit_issuance_holding_code = function (items) { var promises = []; var edits = []; @@ -140,19 +172,7 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , $scope.add_issuances = function () { var lastItem = egSerialsCoreSvc.itemList[egSerialsCoreSvc.itemList.length - 1]; - var base_iss; - if (lastItem) { - lastItem = egCore.idl.fromHash('siss', lastItem.issuance); - } else { - base_iss = new egCore.idl.siss(); - base_iss.creator( egCore.auth.user().id() ); - base_iss.editor( egCore.auth.user().id() ); - base_iss.date_published( hc.date ); - base_iss.subscription( $scope.ssubId ); - base_iss.caption_and_pattern( hc.scap ); - base_iss.holding_code( JSON.stringify(hc.holding_code) ); - base_iss.holding_type( hc.type ); - } + if (lastItem) lastItem = egCore.idl.fromHash('siss', lastItem.issuance); return egSerialsCoreSvc.new_holding_code({ title : egCore.strings.SERIALS_ISSUANCE_PREDICT, @@ -160,6 +180,22 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , prev_iss : lastItem }).then(function(hc) { console.log(hc) + + var base_iss; + if (!lastItem) { + base_iss = new egCore.idl.siss(); + base_iss.creator( egCore.auth.user().id() ); + base_iss.editor( egCore.auth.user().id() ); + base_iss.date_published( hc.date ); + base_iss.subscription( $scope.ssubId ); + base_iss.caption_and_pattern( hc.scap ); + base_iss.holding_code( JSON.stringify(hc.holding_code) ); + base_iss.holding_type( hc.type ); + } + + // if we're predicting without a preexisting holding, reduce the count + if (!lastItem) hc.count--; + return egCore.net.request( 'open-ils.serial', 'open-ils.serial.make_predictions',