From 12ab9835a8739599a5670f7f6e3eb1be4fe0f3b1 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 31 Aug 2016 14:11:59 -0400 Subject: [PATCH] teach copy editor templates about copy alerts Signed-off-by: Galen Charlton --- .../web/js/ui/default/staff/cat/volcopy/app.js | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index ee0c119496..7d91341f48 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -1029,6 +1029,36 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , statcat_filter: undefined }; + $scope.copyAlertUpdate = function (alerts) { + if (!$scope.in_item_select && + $scope.workingGridControls && + $scope.workingGridControls.selectedItems) { + itemSvc.get_copy_alert_types().then(function(ccat) { + var ccat_map = {}; + $scope.alert_types = ccat; + angular.forEach(ccat, function(t) { + ccat_map[t.id()] = t; + }); + angular.forEach( + $scope.workingGridControls.selectedItems(), + function (cp) { + $scope.dirty = true; + angular.forEach(alerts, function(alrt) { + var a = egCore.idl.fromHash('aca', alrt); + a.isnew(1); + a.create_staff(egCore.auth.user().id()); + a.alert_type(ccat_map[a.alert_type()]); + a.ack_time(null); + a.copy(cp.id()); + cp.copy_alerts().push( a ); + }); + cp.ischanged(1); + } + ); + }); + } + }; + $scope.copyNoteUpdate = function (notes) { if (!$scope.in_item_select && $scope.workingGridControls && @@ -1136,6 +1166,8 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , $scope.working[k] = egCore.org.get(v); } else if (k == 'copy_notes' && v.length) { $scope.copyNoteUpdate(v); + } else if (k == 'copy_alerts' && v.length) { + $scope.copyAlertUpdate(v); } else if (!angular.isObject(v)) { $scope.working[k] = angular.copy(v); } else { @@ -2141,6 +2173,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , $scope.working = { copy_notes: [], + copy_alerts: [], statcats: {}, statcat_filter: undefined }; @@ -2287,6 +2320,75 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , }); } + $scope.copy_alerts_dialog = function() { + var working = $scope.working; + + return $uibModal.open({ + templateUrl: './cat/volcopy/t_copy_alerts', + animation: true, + controller: + ['$scope','$uibModalInstance', + function($scope , $uibModalInstance) { + + itemSvc.get_copy_alert_types().then(function(ccat) { + var ccat_map = {}; + $scope.alert_types = ccat; + angular.forEach(ccat, function(t) { + ccat_map[t.id()] = t; + }); + $scope.copy_alert_list = []; + angular.forEach(working.copy_alerts, function (alrt) { + var aca = egCore.idl.fromHash('aca', alrt); + aca.alert_type(ccat_map[alrt.alert_type]); + aca.ack_time(null); + $scope.copy_alert_list.push(aca); + }); + }); + + $scope.focusNote = true; + $scope.copy_alert = { + note : '', + temp : false + }; + + $scope.ok = function(copy_alert) { + + if (!working.copy_alerts) { + working.copy_alerts = []; + } + // clear slate + working.copy_alerts.length = 0; + + angular.forEach($scope.copy_alert_list, function(alrt) { + if (alrt.ack_time() == null) { + working.copy_alerts.push({ + note : alrt.note(), + temp : alrt.temp(), + alert_type : alrt.alert_type().id() + }); + } + }); + + if (typeof(copy_alert.note) != 'undefined' && + copy_alert.note != '') { + working.copy_alerts.push({ + note : copy_alert.note, + temp : copy_alert.temp ? 't' : 'f', + alert_type : copy_alert.alert_type + }); + } + + $uibModalInstance.close(); + } + + $scope.cancel = function($event) { + $uibModalInstance.dismiss(); + $event.preventDefault(); + } + }] + }); + } + $scope.status_list = []; itemSvc.get_magic_statuses().then(function(list){ $scope.magic_status_list = list; -- 2.11.0