From e2f42eca432eb1d3317eab11d2d5869b2105931b Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 31 Mar 2017 18:31:52 -0400 Subject: [PATCH 1/1] LP#1673857: interface for applying tags from copy buckets The copy buckets interface now includes an 'Apply Tags' action that can be used to map tags to a set of selected copies. Note that interface cannot be used to remove tag mappings; the volume/copy editor is needed to do that. Signed-off-by: Galen Charlton Signed-off-by: Josh Stompro Signed-off-by: Galen Charlton --- .../staff/cat/bucket/copy/t_apply_tags.tt2 | 39 ++++++++++ .../staff/cat/bucket/copy/t_view.tt2 | 2 + .../ui/default/staff/cat/bucket/copy/app.js | 78 +++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 Open-ILS/src/templates/staff/cat/bucket/copy/t_apply_tags.tt2 diff --git a/Open-ILS/src/templates/staff/cat/bucket/copy/t_apply_tags.tt2 b/Open-ILS/src/templates/staff/cat/bucket/copy/t_apply_tags.tt2 new file mode 100644 index 0000000000..00d6db7810 --- /dev/null +++ b/Open-ILS/src/templates/staff/cat/bucket/copy/t_apply_tags.tt2 @@ -0,0 +1,39 @@ +
+ + + +
diff --git a/Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2 b/Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2 index 655e7858e0..c2daf27426 100644 --- a/Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2 +++ b/Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2 @@ -20,6 +20,8 @@ handler="transferCopies"> + diff --git a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js index fc78a77fe6..7eea044ddc 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js @@ -656,6 +656,84 @@ function($scope, $q , $routeParams , $timeout , $window , $uibModal , bucketSvc } } + $scope.applyTags = function(copies) { + return $uibModal.open({ + templateUrl: './cat/bucket/copy/t_apply_tags', + animation: true, + controller: + ['$scope','$uibModalInstance', + function($scope , $uibModalInstance) { + + $scope.tag_map = []; + + egCore.pcrud.retrieveAll('cctt', {order_by : { cctt : 'label' }}, {atomic : true}).then(function(list) { + $scope.tag_types = list; + $scope.tag_type = $scope.tag_types[0].code(); // just pick a default + }); + + $scope.getTags = function(val) { + return egCore.pcrud.search('acpt', + { + owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true), + label : { 'startwith' : { + transform: 'evergreen.lowercase', + value : [ 'evergreen.lowercase', val ] + }}, + tag_type : $scope.tag_type + }, + { order_by : { 'acpt' : ['label'] } }, { atomic: true } + ).then(function(list) { + return list.map(function(item) { + return item.label(); + }); + }); + } + + $scope.addTag = function() { + var tagLabel = $scope.selectedLabel; + // clear the typeahead + $scope.selectedLabel = ""; + + egCore.pcrud.search('acpt', + { + owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true), + label : tagLabel, + tag_type : $scope.tag_type + }, + { order_by : { 'acpt' : ['label'] } }, { atomic: true } + ).then(function(list) { + if (list.length > 0) { + var newMap = new egCore.idl.acptcm(); + newMap.isnew(1); + newMap.tag(egCore.idl.Clone(list[0])); + $scope.tag_map.push(newMap); + } + }); + } + + $scope.ok = function() { + var promises = []; + angular.forEach($scope.tag_map, function(map) { + if (map.isdeleted()) return; + angular.forEach(copies, function (cp) { + var m = new egCore.idl.acptcm(); + m.isnew(1); + m.copy(cp.id); + m.tag(map.tag().id()); + promises.push(egCore.pcrud.create(m)); + }); + }); + return $q.all(promises).then(function(){$uibModalInstance.close()}); + } + + $scope.cancel = function($event) { + $uibModalInstance.dismiss(); + $event.preventDefault(); + } + }] + }); + } + // fetch the bucket; on error show the not-allowed message if ($scope.bucketId) drawBucket()['catch'](function() { $scope.forbidden = true }); -- 2.43.2