From c6832d599808cc4a6d21f0a8cc72f4ea54a77686 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 23 Aug 2017 13:07:33 -0400 Subject: [PATCH] LP#1373690 EDI attribute set clone operation Support cloning existing attribute sets via a new 'Clone ""' action in the EDI attr set editor. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../src/templates/staff/admin/acq/t_edi_attr_set.tt2 | 4 ++++ Open-ILS/web/js/ui/default/staff/admin/acq/app.js | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Open-ILS/src/templates/staff/admin/acq/t_edi_attr_set.tt2 b/Open-ILS/src/templates/staff/admin/acq/t_edi_attr_set.tt2 index c70baef076..79b2d319e8 100644 --- a/Open-ILS/src/templates/staff/admin/acq/t_edi_attr_set.tt2 +++ b/Open-ILS/src/templates/staff/admin/acq/t_edi_attr_set.tt2 @@ -17,6 +17,10 @@ [% l('New Attribute Set...') %] +
  • + + [% l('Clone "[_1]"', '{{cur_attr_set.label()}}') %] +
  • {{set.label()}} diff --git a/Open-ILS/web/js/ui/default/staff/admin/acq/app.js b/Open-ILS/web/js/ui/default/staff/admin/acq/app.js index de8dddc532..1ff496ad4e 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/acq/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/acq/app.js @@ -144,6 +144,8 @@ function($scope , $q , egCore , ngToast , egConfirmDialog) { angular.forEach($scope.attr_sets, function(set) { console.debug('inspecting attr set ' + set.label()); + if (!set.label()) return; // skip (new) unnamed sets + // find maps that need deleting angular.forEach(set.attr_maps(), function(oldmap) { if (!set._local_map[oldmap.attr()]) { @@ -248,6 +250,23 @@ function($scope , $q , egCore , ngToast , egConfirmDialog) { }); } + $scope.clone_set = function(source_set) { + var set = new egCore.idl.aeas(); + set.isnew(true); + set.attr_maps([]); + set._local_map = {}; + + // Copy attr info from cloned attr set. No need to create the + // maps now, just indicate in the local mapping that attr maps + // are pending. + angular.forEach(source_set.attr_maps(), function(map) { + set._local_map[map.attr()] = true; + }); + + $scope.select_set(set); + $scope.attr_sets.push(set); + } + load_data(); }]) -- 2.11.0