LP#1373690 EDI attribute set clone operation
authorBill Erickson <berickxx@gmail.com>
Wed, 23 Aug 2017 17:07:33 +0000 (13:07 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 1 Sep 2017 17:13:31 +0000 (13:13 -0400)
Support cloning existing attribute sets via a new 'Clone "<existing set
name>"' action in the EDI attr set editor.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/staff/admin/acq/t_edi_attr_set.tt2
Open-ILS/web/js/ui/default/staff/admin/acq/app.js

index c70baef..79b2d31 100644 (file)
             <a href='' ng-click="new_set()">
               [% l('New Attribute Set...') %]</a>
           </li>
+          <li ng-if="!cur_attr_set.isnew()">
+            <a href='' ng-click="clone_set(cur_attr_set)">
+              [% l('Clone "[_1]"', '{{cur_attr_set.label()}}') %]</a>
+          </li>
           <li class="divider"></li>
           <li ng-repeat="set in attr_sets">
             <a href='' ng-click="select_set(set)">{{set.label()}}</a>
index de8dddc..1ff496a 100644 (file)
@@ -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();
 }])