From: Galen Charlton Date: Wed, 31 Aug 2016 16:53:05 +0000 (-0400) Subject: teach copy templates how to manage copy notes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a949d1a06913591189da759eb3216fb74349e474;p=working%2FEvergreen.git teach copy templates how to manage copy notes Signed-off-by: Galen Charlton Conflicts: Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js --- 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 f2b67385af..dda5caa719 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 @@ -947,6 +947,28 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , statcat_filter: undefined }; + $scope.copyNoteUpdate = function (notes) { + if (!$scope.in_item_select && + $scope.workingGridControls && + $scope.workingGridControls.selectedItems) { + angular.forEach( + $scope.workingGridControls.selectedItems(), + function (cp) { + $scope.dirty = true; + angular.forEach(notes, function(note) { + var n = egCore.idl.fromHash('acpn', note); + n.isnew(1); + n.creator(egCore.auth.user().id()); + n.owning_copy(cp.id()); + cp.notes().push( n ); + }); + cp.ischanged(1); + } + ); + + } + } + $scope.statcatUpdate = function (id) { var newval = $scope.working.statcats[id]; @@ -1030,6 +1052,8 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , angular.forEach($scope.templates[n], function (v,k) { if (k == 'circ_lib') { $scope.working[k] = egCore.org.get(v); + } else if (k == 'copy_notes' && v.length) { + $scope.copyNoteUpdate(v); } else if (!angular.isObject(v)) { $scope.working[k] = angular.copy(v); } else { @@ -1700,8 +1724,8 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , scope: { editTemplates: '=', }, - controller : ['$scope','$window','itemSvc','egCore','ngToast', - function ( $scope , $window , itemSvc , egCore , ngToast) { + controller : ['$scope','$window','itemSvc','egCore','ngToast','$uibModal', + function ( $scope , $window , itemSvc , egCore , ngToast , $uibModal) { $scope.defaults = { // If defaults are not set at all, allow everything barcode_checkdigit : false, @@ -1781,7 +1805,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , angular.forEach($scope.templates[n], function (v,k) { if (k == 'circ_lib') { $scope.working[k] = egCore.org.get(v); - } else if (!angular.isObject(v)) { + } else if (angular.isArray(v) || !angular.isObject(v)) { $scope.working[k] = angular.copy(v); } else { angular.forEach(v, function (sv,sk) { @@ -1832,7 +1856,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , } ngToast.create(egCore.strings.VOL_COPY_TEMPLATE_SUCCESS_SAVE); } - + $scope.templates = {}; $scope.imported_templates = { data : '' }; $scope.template_name = ''; @@ -1884,6 +1908,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , } $scope.working = { + copy_notes: [], statcats: {}, statcat_filter: undefined }; @@ -1963,6 +1988,72 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , createStatcatUpdateWatcher(s.id()); }); }); + + $scope.copy_notes_dialog = function() { + var default_pub = Boolean($scope.defaults.copy_notes_pub); + var working = $scope.working; + + return $uibModal.open({ + templateUrl: './cat/volcopy/t_copy_notes', + animation: true, + controller: + ['$scope','$uibModalInstance', + function($scope , $uibModalInstance) { + $scope.focusNote = true; + $scope.note = { + title : '', + value : '', + pub : default_pub, + }; + + $scope.require_initials = false; + egCore.org.settings([ + 'ui.staff.require_initials.copy_notes' + ]).then(function(set) { + $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']); + }); + + $scope.note_list = []; + angular.forEach(working.copy_notes, function(note) { + var acpn = egCore.idl.fromHash('acpn', note); + $scope.note_list.push(acpn); + }); + + $scope.ok = function(note) { + + if (!working.copy_notes) { + working.copy_notes = []; + } + + // clear slate + working.copy_notes.length = 0; + angular.forEach($scope.note_list, function(existing_note) { + if (!existing_note.isdeleted()) { + working.copy_notes.push({ + pub : existing_note.pub() ? 't' : 'f', + title : existing_note.title(), + value : existing_note.value() + }); + } + }); + + // add new note, if any + if (note.initials) note.value += ' [' + note.initials + ']'; + note.pub = note.pub ? 't' : 'f'; + if (note.title.length && note.value.length) { + working.copy_notes.push(note); + } + + $uibModalInstance.close(); + } + + $scope.cancel = function($event) { + $uibModalInstance.dismiss(); + $event.preventDefault(); + } + }] + }); + } $scope.status_list = []; itemSvc.get_statuses().then(function(list){