dojo.require('openils.PermaCrud');
var circModEditor = null;
+var circModGroupTables = [];
function load(){
cmGrid.loadAll({order_by:{ccmm:'circ_modifier'}});
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)
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',
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);
<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> <span>
+ <a href='javascript:void(0);' onclick='applyCircModChanges()'>Apply Circ Modifier Changes</a>
+ </span>
</div>
</div>