more work toword support circ mod groups
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 26 May 2009 21:39:54 +0000 (21:39 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 26 May 2009 21:39:54 +0000 (21:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13240 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/conify/global/config/circ_matrix_matchpoint.js
Open-ILS/web/templates/default/conify/global/config/circ_matrix_matchpoint.tt2

index c7a643f..6e24496 100644 (file)
@@ -5,6 +5,7 @@ dojo.require('openils.widget.AutoFieldWidget');
 dojo.require('openils.PermaCrud');
 
 var circModEditor = null;
+var circModGroupTables = [];
 
 function load(){
     cmGrid.loadAll({order_by:{ccmm:'circ_modifier'}});
@@ -19,6 +20,7 @@ function byName(name, ctxt) {
 function buildEditPaneAdditions(editPane) {
     var node = circModEditor.cloneNode(true);
     var tableTmpl = node.removeChild(byName('circ-mod-group-table', node));
+    circModGroupTables = [];
 
     byName('add-circ-mod-group', node).onclick = function() {
         addCircModGroup(node, tableTmpl)
@@ -32,26 +34,24 @@ function buildEditPaneAdditions(editPane) {
     editPane.domNode.appendChild(node);
 }
 
+
 function addCircModGroup(node, tableTmpl, group) {
 
     var table = tableTmpl.cloneNode(true);
     var circModRowTmpl = byName('circ-mod-entry-tbody', table).removeChild(byName('circ-mod-entry-row', table));
+    circModGroupTables.push(table);
 
-    // loop over mods
-    //
-    
-    function addMod(mod) {
+    function addMod(code, name) {
         var row = circModRowTmpl.cloneNode(true);
-        byName('circ-mod', row).innerHTML = mod;
+        byName('circ-mod', row).innerHTML = name;
+        byName('circ-mod', row).setAttribute('code', code);
         byName('circ-mod-entry-tbody', table).appendChild(row);
+        byName('remove-circ-mod', row).onclick = function() {
+            byName('circ-mod-entry-tbody', table).removeChild(row);
+        }
     }
 
-    new openils.widget.AutoFieldWidget({
-        fmClass : 'ccmcmt',
-        fmField : 'items_out',
-        fmObject : group,
-        parentNode : byName('circ-mod-count', table)
-    }).build();
+    byName('circ-mod-count', table).value = (group) ? group.items_out() : 0;
 
     var selector = new openils.widget.AutoFieldWidget({
         fmClass : 'ccmcmtm',
@@ -61,11 +61,26 @@ function addCircModGroup(node, tableTmpl, group) {
     selector.build();
 
     byName('add-circ-mod', table).onclick = function() {
-        addMod(selector.widget.attr('value'));
+        addMod(selector.widget.attr('value'), selector.widget.attr('displayedValue'));
     }
 
-    node.insertBefore(table, byName('add-circ-mod-group', node));
-    node.insertBefore(dojo.create('hr'), byName('add-circ-mod-group', node));
+    node.insertBefore(table, byName('add-circ-mod-group-span', node));
+    node.insertBefore(dojo.create('hr'), byName('add-circ-mod-group-span', node));
+}
+
+function applyCircModChanges() {
+
+    for(var idx in circModGroupTables) {
+        var table = circModGroupTables[idx];
+
+        var count = byName('circ-mod-count', table).value;
+        var mods = [];
+        dojo.forEach(dojo.query('[name=circ-mod]', table), function(td) { 
+            mods.push(td.getAttribute('code'));
+        });
+
+        alert(count + ' : ' + mods);
+    }
 }
 
 openils.Util.addOnLoad(load);
index 5884f15..cd6fece 100644 (file)
 
 <div class='hidden'>
     <div id='circ-mod-editor' style='border:1px solid #aaa'>
-        <h3>Circ Mod Count Groups</h3>
+        <h3>Circ Modifier Count Groups</h3>
         <table class='oils-generic-table' name='circ-mod-group-table'>
             <tbody><tr>
                 <td>Total items out</td>
-                <td><div name='circ-mod-count'></div></td>
+                <td><input type='text' size='3' name='circ-mod-count'></div></td>
             </tr><tbody>
             <tbody name='circ-mod-entry-tbody'>
                 <tr name='circ-mod-entry-row'>
-                    <td colspan='2' name='circ-mod'/>
+                    <td name='circ-mod'/>
+                    <td><a name='remove-circ-mod' href='javascript:void(0);'>Remove</a></td>
                 </tr>
             </tbody>
             <tbody>
                 </tr>
             </tbody>
         </table>
+        <span name='add-circ-mod-group-span'>
         <a href='javascript:void(0);' name='add-circ-mod-group'>Create New Group</a>
+        </span>&nbsp;&nbsp;<span>
+        <a href='javascript:void(0);' onclick='applyCircModChanges()'>Apply Circ Modifier Changes</a>
+        </span>
     </div>
 </div>