From 168f5c9b535b33cc41d7b539a5254b20c71dddfd Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 25 Feb 2014 15:27:58 -0500 Subject: [PATCH] LP#1284864 coded value map cloning Added a "clone selected" option to the coded value map grid. For CCVMs which have composite definitions, clone the composite definition as well. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../conify/global/config/coded_value_map.tt2 | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Open-ILS/src/templates/conify/global/config/coded_value_map.tt2 b/Open-ILS/src/templates/conify/global/config/coded_value_map.tt2 index 329a432b48..75e1a558ba 100644 --- a/Open-ILS/src/templates/conify/global/config/coded_value_map.tt2 +++ b/Open-ILS/src/templates/conify/global/config/coded_value_map.tt2 @@ -6,6 +6,7 @@
+
@@ -37,6 +38,7 @@ dojo.require('dijit.form.FilteringSelect'); dojo.require('openils.widget.AutoGrid'); dojo.require('openils.widget.AutoFieldWidget'); + dojo.require('openils.PermaCrud'); function getCompositeDefLink(rowId, item) { if (!item) return ''; @@ -56,6 +58,42 @@ var cradName = '[% ctx.page_args.0 %]'; + function handleClone(oldObj, newObj) { + if (!isComposite) return; // vanilla, non-composite clone + + // fetch the composite def for the clone source object + var pcrud = new openils.PermaCrud(); + pcrud.search('ccraed', {coded_value : oldObj.id}, { + + oncomplete : function(r) { + composite_def = openils.Util.readResponse(r).pop(); + + // after cloning, jump to the composite def page + var dest = oilsBasePath + + '/conify/global/config/composite_attr_entry_definition/' + + newObj.id(); + + if (!composite_def || !composite_def.definition()) { + // nothing to copy + location.href = dest; + return; + } + + // copy the composite definition from the clone + // source object into the clone destination object + var new_def = new fieldmapper.ccraed(); + new_def.coded_value(newObj.id()); + new_def.definition(composite_def.definition()); + pcrud.create(new_def, { + oncomplete : function(r) { + openils.Util.readResponse(r); // test for alerts + location.href = dest; + } + }); + } + }); + } + openils.Util.addOnLoad( function() { -- 2.43.2