use new event_def name field. added delete buttons for more event_def grids
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Apr 2009 17:09:37 +0000 (17:09 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Apr 2009 17:09:37 +0000 (17:09 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12965 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/actor/user/trigger_events.js
Open-ILS/web/js/ui/default/conify/global/action_trigger/event_definition.js
Open-ILS/web/templates/default/actor/user/trigger_events.tt2
Open-ILS/web/templates/default/conify/global/action_trigger/event_definition.tt2

index 6c46f2a..1f734df 100644 (file)
@@ -3,6 +3,10 @@ dojo.require('dojo.data.ItemFileWriteStore');
 dojo.require('openils.Util');
 dojo.require('openils.User');
 
+// need these to represent the event def name
+dojo.requireLocalization('openils.conify', 'conify');
+var localeStrings = dojo.i18n.getLocalization('openils.conify', 'conify');
+
 var evtCache = {};
 
 function init() {
@@ -38,6 +42,12 @@ function getField(rowIdx, item) {
     var evt = evtCache[this.grid.store.getValue(item, 'id')];
 
     switch(this.field) {
+        case 'event_def':
+            return dojo.string.substitute(
+                localeStrings.EVENT_DEF_LABEL, [
+                    fieldmapper.aou.findOrgUnit(evt.event_def().owner()).shortname(), 
+                    evt.event_def().name()
+                ]);
         case 'reactor':
             return evt.event_def().reactor().module();
         case 'validator':
index 36c2281..7c9c1c5 100644 (file)
@@ -7,7 +7,9 @@ dojo.require('openils.widget.AutoGrid');
 dojo.require('openils.Util');
 dojo.require('openils.PermaCrud');
 dojo.require('openils.widget.ProgressDialog');
+dojo.requireLocalization('openils.conify', 'conify');
 
+var localeStrings = dojo.i18n.getLocalization('openils.conify', 'conify');
 
 function loadEventDef() { 
     edGrid.loadAll({order_by:{atevdef : 'hook'}}); 
@@ -50,8 +52,9 @@ function loadTestTab() {
     circTestHookSelector.startup();
 
     var defs = pcrud.search('atevdef', {hook : hooks.map(function(i){return i.key()})});
-    circTestDefSelector.store = new dojo.data.ItemFileReadStore({data : atevdef.toStoreData(defs)});
-    circTestDefSelector.searchAttr = 'id';
+    var defData = atevdef.toStoreData(defs);
+    circTestDefSelector.store = new dojo.data.ItemFileReadStore({data : defData});
+    circTestDefSelector.searchAttr = 'name';
     circTestDefSelector.startup();
 
     dojo.connect(circTestHookSelector, 'onChange',
@@ -61,6 +64,30 @@ function loadTestTab() {
     );
 }
 
+
+function eventDefGetter(rowIdx, item) {
+    if(!item) return '';
+    var def = this.grid.store.getValue(item, 'event_def');
+    return getDefName(def);
+}
+
+function getDefName(def) {
+
+    if(typeof def != 'object') {
+        edGrid.store.fetchItemByIdentity({
+            identity : def,
+            onItem : function(item) { def = new fieldmapper.atevdef().fromStoreItem(item); }
+        });
+    }
+
+    return dojo.string.substitute(
+        localeStrings.EVENT_DEF_LABEL, [
+            fieldmapper.aou.findOrgUnit(def.owner()).shortname(), 
+            def.name()
+        ]);
+}
+
+
 function evtTestCirc() {
     var def = circTestDefSelector.attr('value');
     var barcode = circTestBarcode.attr('value');
index 7ebc924..da8adfd 100644 (file)
     <table jsId="evtGrid" dojoType="dojox.grid.DataGrid" query="{id: '*'}">
         <thead> 
             <tr> 
-                <th field="state" get='getField' width='12em'>State</th> 
-                <th field="hook" get='getField' width='12em'>Hook</th> 
-                <th field="reactor" get='getField' width='12em'>Reactor</th> 
-                <th field="validator" get='getField' width='12em'>Validator</th> 
-                <th field="target" get='getField' width='12em'>Target</th> 
+                <th field="event_def" get='getField' width='auto'>Event Def.</th> 
+                <th field="hook" get='getField' width='auto'>Hook</th> 
+                <th field="reactor" get='getField' width='auto'>Reactor</th> 
+                <th field="validator" get='getField' width='auto'>Validator</th> 
+                <th field="target" get='getField' width='auto'>Target</th> 
+                <th field="state" get='getField' width='auto'>State</th> 
             </tr> 
         </thead> 
     </table>     
index 47d9300..8610c6d 100644 (file)
@@ -15,7 +15,7 @@
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:90%'>
             <table  jsId="edGrid" 
                     dojoType="openils.widget.AutoGrid" 
-                    fieldOrder="['id', 'owner', 'hook', 'active', 'delay', 'delay_field', 'group_field', 'validator', 'reactor']"
+                    fieldOrder="['owner', 'name', 'hook', 'active', 'delay', 'delay_field', 'group_field', 'validator', 'reactor']"
                     suppressFields="['template', 'cleanup_failure', 'cleanup_success']"
                     query="{id: '*'}" 
                     fmClass='atevdef'
     <div dojoType="dijit.layout.ContentPane" title='Event Parameters' id='tab-atevparam'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
             <div>Trigger Event Parameters</div>
-            <div><button dojoType='dijit.form.Button' onClick='tepGrid.showCreateDialog()'>New</button></div>
+            <div>
+                <button dojoType='dijit.form.Button' onClick='tepGrid.showCreateDialog()'>New</button>
+                <button dojoType='dijit.form.Button' onClick='tepGrid.deleteSelected()'>Delete Selected</button>
+            </div>
         </div>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:90%'>
             <table  jsId="tepGrid" 
@@ -39,6 +42,9 @@
                     fmClass='atevparam'
                     defaultCellWidth='20'
                     editOnEnter='true'>
+                <thead>
+                    <tr><th field='event_def' get='eventDefGetter'/></tr>
+                </thead>
             </table>
         </div>
     </div>
     <div dojoType="dijit.layout.ContentPane" title='Event Environment' id='tab-atenv'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
             <div>Trigger Event Environment</div>
-            <div><button dojoType='dijit.form.Button' onClick='teeGrid.showCreateDialog()'>New</button></div>
+            <div>   
+                <button dojoType='dijit.form.Button' onClick='teeGrid.showCreateDialog()'>New</button>
+                <button dojoType='dijit.form.Button' onClick='teeGrid.deleteSelected()'>Delete Selected</button>
+            </div>
         </div>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:90%'>
             <table  jsId="teeGrid" 
@@ -56,6 +65,9 @@
                     fmClass='atenv'
                     defaultCellWidth='20'
                     editOnEnter='true'>
+                <thead>
+                    <tr><th field='event_def' get='eventDefGetter'/></tr>
+                </thead>
             </table>
         </div>
     </div>
     <div dojoType="dijit.layout.ContentPane" title='Hooks' id='tab-ath'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
             <div>Trigger Hooks</div>
-            <div><button dojoType='dijit.form.Button' onClick='thGrid.showCreateDialog()'>New</button></div>
+            <div>
+                <button dojoType='dijit.form.Button' onClick='thGrid.showCreateDialog()'>New</button>
+                <button dojoType='dijit.form.Button' onClick='thGrid.deleteSelected()'>Delete Selected</button>
+            </div>
         </div>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:90%'>
             <table  jsId="thGrid" 
@@ -72,7 +87,7 @@
                     fieldOrder="['key', 'core_type', 'description', 'passive']"
                     query="{key: '*'}" 
                     fmClass='ath'
-                    defaultCellWidth='12'
+                    defaultCellWidth='20'
                     editOnEnter='true'>
             </table>
         </div>
     <div dojoType="dijit.layout.ContentPane" title='Reactors' id='tab-atreact'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
             <div>Trigger Reactors</div>
-            <div><button dojoType='dijit.form.Button' onClick='trGrid.showCreateDialog()'>New</button></div>
+            <div>
+                <button dojoType='dijit.form.Button' onClick='trGrid.showCreateDialog()'>New</button>
+                <button dojoType='dijit.form.Button' onClick='trGrid.deleteSelected()'>Delete Selected</button>
+            </div>
         </div>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:90%'>
             <table  jsId="trGrid" 
     <div dojoType="dijit.layout.ContentPane" title='Validators' id='tab-atval'>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
             <div>Trigger Validators</div>
-            <div><button dojoType='dijit.form.Button' onClick='tvGrid.showCreateDialog()'>New</button></div>
+            <div>
+                <button dojoType='dijit.form.Button' onClick='tvGrid.showCreateDialog()'>New</button>
+                <button dojoType='dijit.form.Button' onClick='tvGrid.deleteSelected()'>Delete Selected</button>
+            </div>
         </div>
         <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:90%'>
             <table  jsId="tvGrid"