dojo.connect(eventDefTabs,'selectChild', tabLoader);
}
+/**
+ * After an event def is cloned, see if the user wants to also clone the event def environment
+ * @param {Object} oldItem Grid store item that was cloned
+ * @param {Object} newObject Newly created fieldmapper object
+ */
+function cloneEventEnv(oldItem, newObject) {
+ if(!confirm('Clone event definition environment as well?')) return; // TODO i18n
+ progressDialog.show(true);
+ var pcrud = new openils.PermaCrud();
+
+ // fetch the env list for the cloned object
+ var env_list = pcrud.search('atenv', {event_def : edGrid.store.getValue(oldItem, 'id')});
+
+ if(env_list && env_list.length) {
+
+ // clone the environment
+ env_list = env_list.map(
+ function(item) {
+ item.id(null);
+ item.event_def(newObject.id());
+ return item;
+ }
+ );
+
+ // create the cloned environment list
+ pcrud.create(env_list);
+ }
+
+ progressDialog.hide();
+}
+
function loadEventDefData() {
var pcrud = new openils.PermaCrud();
eventDef = pcrud.retrieve('atevdef', eventDefId);
[% WRAPPER default/base.tt2 %]
+[% ctx.page_title = 'Event Definitions' %]
<script src='[% ctx.media_prefix %]/js/ui/default/conify/global/action_trigger/event_definition.js'> </script>
<script>openils.Util.addOnLoad(loadEventDef)</script>
+
<div dojoType="dijit.layout.TabContainer" style='height:100%;' jsId='eventDefTabs'>
<div dojoType="dijit.layout.ContentPane" title='Event Definitions' id='tab-atevdef'>
<div>Trigger Event Definitions</div>
<div>
<button dojoType='dijit.form.Button' onClick='edGrid.showCreatePane()'>New</button>
- <button dojoType='dijit.form.Button' onClick='edGrid.showClonePane()'>Clone Selected</button>
+ <button dojoType='dijit.form.Button' onClick='edGrid.showClonePane(cloneEventEnv)'>Clone Selected</button>
<button dojoType='dijit.form.Button' onClick='edGrid.deleteSelected()'>Delete Selected</button>
</div>
</div>
</div>
</div>
+</div>
+
+<div jsId='progressDialog' dojoType='openils.widget.ProgressDialog' indeterminate='true'></div>
[% END %]