From a4dfa2342a33227d7bf47202a258e54b362d8778 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Thu, 18 May 2017 18:06:31 -0400 Subject: [PATCH] webstaff: Apply Binding Template for distributions and fix Receiving and Binding Template columns in the Subscription Manager grid Signed-off-by: Jason Etheridge --- Open-ILS/src/templates/staff/serials/index.tt2 | 2 + .../staff/serials/t_apply_binding_template.tt2 | 54 ++++++++++++ .../staff/serials/t_subscription_manager.tt2 | 4 +- .../serials/directives/subscription_manager.js | 97 ++++++++++++++++++++++ .../js/ui/default/staff/serials/services/core.js | 3 + 5 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/templates/staff/serials/t_apply_binding_template.tt2 diff --git a/Open-ILS/src/templates/staff/serials/index.tt2 b/Open-ILS/src/templates/staff/serials/index.tt2 index d21f9838d3..96af178e8a 100644 --- a/Open-ILS/src/templates/staff/serials/index.tt2 +++ b/Open-ILS/src/templates/staff/serials/index.tt2 @@ -23,6 +23,8 @@ angular.module('egCoreMod').run(['egStrings', function(s) { s.SERIALS_ISSUANCE_SUCCESS_SAVE = "[% l('Issuance saved') %]"; s.SERIALS_DISTRIBUTION_SUCCESS_LINK_MFHD = "[% l('Distribution linked to MFHD') %]"; s.SERIALS_DISTRIBUTION_FAIL_LINK_MFHD = "[% l('Failed to link distribution to MFHD') %]"; + s.SERIALS_DISTRIBUTION_SUCCESS_BINDING_TEMPLATE = "[% l('Binding unit template applied to Distribution') %]"; + s.SERIALS_DISTRIBUTION_FAIL_BINDING_TEMPLATE = "[% l('Failed to apply binding unit template to distribution') %]"; 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') %]"; diff --git a/Open-ILS/src/templates/staff/serials/t_apply_binding_template.tt2 b/Open-ILS/src/templates/staff/serials/t_apply_binding_template.tt2 new file mode 100644 index 0000000000..dd0bbc2510 --- /dev/null +++ b/Open-ILS/src/templates/staff/serials/t_apply_binding_template.tt2 @@ -0,0 +1,54 @@ +
+ + + + + + + + +
diff --git a/Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2 b/Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2 index 6d51db78f1..67923798dd 100644 --- a/Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2 @@ -90,12 +90,12 @@ - + - + diff --git a/Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js b/Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js index 50464f4c73..000afacb60 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js +++ b/Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js @@ -312,11 +312,108 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , }); }); } + $scope.apply_binding_template = function(rows) { + if (rows.length == 0) { return; } + var d_rows = rows.filter(function(el) { + return typeof el['sdist.id'] != 'undefined'; + }); + if (d_rows.length == 0) { return; } + var libs = []; var seen_lib = {}; + angular.forEach(d_rows, function(el) { + if (el['sdist.holding_lib.id'] && !seen_lib[el['sdist.holding_lib.id']]) { + seen_lib[el['sdist.holding_lib.id']] = 1; + libs.push({ + id: el['sdist.holding_lib.id'], + name: el['sdist.holding_lib.name'], + }); + } + }); + $uibModal.open({ + templateUrl: './serials/t_apply_binding_template', + controller: 'ApplyBindingTemplateCtrl', + resolve : { + rows : function() { + return d_rows; + }, + libs : function() { + return libs; + } + }, + windowClass: 'app-modal-window', + backdrop: 'static', + keyboard: false + }).result.then(function(args) { + console.log(args); + egCore.pcrud.search('sdist', { + id: d_rows.map(function(el) { return el['sdist.id']; }) + }, {}, { atomic : true } + ).then(function(resp){ + var evt = egCore.evt.parse(resp); + if (evt) { // any way to just throw or return this to the error handler? + console.log('failure',resp); + ngToast.danger(egCore.strings.SERIALS_DISTRIBUTION_FAIL_BINDING_TEMPLATE); + } + var promises = []; + angular.forEach(resp,function(sdist) { + sdist.ischanged(true); + sdist.bind_unit_template( + typeof args.bind_unit_template[sdist.holding_lib()] == 'undefined' + ? null + : args.bind_unit_template[sdist.holding_lib()] + ); + egCore.pcrud.apply(sdist).then( + function(resp2) { // maybe success + console.log('apply',resp2); + var evt = egCore.evt.parse(resp2); + if (evt) { // any way to just throw or return this to the error handler? + console.log('failure',resp2); + ngToast.danger(egCore.strings.SERIALS_DISTRIBUTION_FAIL_BINDING_TEMPLATE); + } else { + console.log('success',resp2); + ngToast.success(egCore.strings.SERIALS_DISTRIBUTION_SUCCESS_BINDING_TEMPLATE); + } + }, + function(resp2) { + console.log('failure',resp2); + ngToast.danger(egCore.strings.SERIALS_DISTRIBUTION_FAIL_LINK_MFHD); + } + ); + }); + $q.all(promises).then(function() { + reload(); + }); + }); + }); + } }] } }) +.controller('ApplyBindingTemplateCtrl', + ['$scope','$q','$uibModalInstance','egCore','egSerialsCoreSvc', + 'rows','libs', +function($scope , $q , $uibModalInstance , egCore , egSerialsCoreSvc , + rows , libs ) { + $scope.ok = function(count) { $uibModalInstance.close($scope.args) } + $scope.cancel = function () { $uibModalInstance.dismiss() } + $scope.libs = libs; + $scope.rows = rows; + $scope.args = { bind_unit_template : {} }; + $scope.templates = {}; + var promises = []; + angular.forEach(libs, function(org) { + promises.push( + egSerialsCoreSvc.fetch_templates(org.id).then(function(list){ + $scope.templates[org.id] = list; + }) + ); + }); + $q.all(promises).then(function() { + //console.log('finis',$scope.receiving_templates); + }); +}]) + .controller('LinkMFHDCtrl', ['$scope','$q','$uibModalInstance','egCore','row','bibId', function($scope , $q , $uibModalInstance , egCore , row , bibId ) { diff --git a/Open-ILS/web/js/ui/default/staff/serials/services/core.js b/Open-ILS/web/js/ui/default/staff/serials/services/core.js index 073fd3a696..3a418fee5e 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/services/core.js +++ b/Open-ILS/web/js/ui/default/staff/serials/services/core.js @@ -110,7 +110,9 @@ function(egCore , orderByFilter , $q , $filter , $uibModal) { 'ssub' : ['owning_lib','distributions', 'scaps', 'notes'], 'sdist' : [ 'record_entry','holding_lib', 'receive_call_number', + 'receive_unit_template', 'bind_call_number', + 'bind_unit_template', 'streams','notes'], 'sstr' : ['routing_list_users'] } @@ -438,6 +440,7 @@ function(egCore , orderByFilter , $q , $filter , $uibModal) { _sdist['sdist.' + fld] = sdist[fld]; }); _sdist['sdist.holding_lib.name'] = sdist.holding_lib.name; + _sdist['sdist.holding_lib.id'] = sdist.holding_lib.id; _sdist['sdist.receive_call_number.label'] = sdist.receive_call_number ? sdist.receive_call_number.label : null; _sdist['sdist.receive_unit_template.name'] = -- 2.11.0