[open-ils-commits] r7778 - in trunk/Open-ILS/web/opac: common/js
locale/en-US skin/default/js skin/default/xml/myopac
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Sep 13 17:42:53 EDT 2007
Author: erickson
Date: 2007-09-13 17:34:52 -0400 (Thu, 13 Sep 2007)
New Revision: 7778
Modified:
trunk/Open-ILS/web/opac/common/js/utils.js
trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
trunk/Open-ILS/web/opac/skin/default/js/myopac.js
trunk/Open-ILS/web/opac/skin/default/xml/myopac/myopac_holds.xml
Log:
added the myopac holds batch select code/unselect UI and code. implemented batch hold cancelling code. later comes freezing/thawing
Modified: trunk/Open-ILS/web/opac/common/js/utils.js
===================================================================
--- trunk/Open-ILS/web/opac/common/js/utils.js 2007-09-13 19:31:32 UTC (rev 7777)
+++ trunk/Open-ILS/web/opac/common/js/utils.js 2007-09-13 21:34:52 UTC (rev 7778)
@@ -681,4 +681,24 @@
}
+function getTableRows(tbody) {
+ var rows = [];
+ if(!tbody) return rows;
+ var children = tbody.childNodes;
+ if(!children) return rows;
+
+ for(var i = 0; i < children.length; i++) {
+ var child = children[i];
+ if(child.nodeName.match(/^tr$/i))
+ rows.push(child);
+ }
+ return rows;
+}
+
+function getObjectKeys(obj) {
+ keys = []
+ for(var k in obj)
+ keys.push(k)
+ return keys;
+}
Modified: trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/opac.dtd 2007-09-13 19:31:32 UTC (rev 7777)
+++ trunk/Open-ILS/web/opac/locale/en-US/opac.dtd 2007-09-13 21:34:52 UTC (rev 7778)
@@ -203,6 +203,15 @@
<!ENTITY myopac.holds.edit "Edit">
<!ENTITY myopac.holds.cancel "Cancel">
<!ENTITY myopac.holds.verify "If you wish to cancel the selected hold, click OK, otherwise click Cancel.">
+<!ENTITY myopac.holds.freeze_selected "Freeze selected holds">
+<!ENTITY myopac.holds.thaw_selected "Un-freeze selected holds">
+<!ENTITY myopac.holds.cancel_selected "Cancel selected holds">
+<!ENTITY myopac.holds.processing "Processing holds... This may take a moment.">
+<!ENTITY myopac.holds.actions 'Actions'>
+<!ENTITY myopac.holds.cancel.confirm 'Are you sure you wish to cancel the selected holds?'>
+<!ENTITY myopac.holds.freeze.confirm 'Are you sure you wish to freeze the selected holds?'>
+<!ENTITY myopac.holds.thaw.confirm 'Are you sure you wish to un-freeze the selected holds?'>
+
<!ENTITY opac.holds.freeze "Freeze this hold">
<!ENTITY opac.holds.freeze.help "A 'frozen' will retain its place in the queue, but will not be fulfilled until it has been unfrozen.">
<!ENTITY opac.holds.freeze.thaw_date "Automatically un-freeze hold on:">
Modified: trunk/Open-ILS/web/opac/skin/default/js/myopac.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/myopac.js 2007-09-13 19:31:32 UTC (rev 7777)
+++ trunk/Open-ILS/web/opac/skin/default/js/myopac.js 2007-09-13 21:34:52 UTC (rev 7778)
@@ -294,14 +294,18 @@
var req = new Request(FETCH_HOLDS, G.user.session, G.user.id());
req.callback(myOPACDrawHolds);
req.send();
+ $('myopac_holds_actions_none').selected = true;
}
var holdsTemplateRowOrig;
var holdsTemplateRow;
+var myopacForceHoldsRedraw = false;
function myOPACDrawHolds(r) {
var tbody = $("myopac_holds_tbody");
- if(holdsTemplateRow) return;
+ if(holdsTemplateRow && !myopacForceHoldsRedraw) return;
+ myopacForceHoldsRedraw = false;
+
if(holdsTemplateRowOrig) {
holdsTemplateRow = holdsTemplateRowOrig;
removeChildren(tbody);
@@ -349,6 +353,8 @@
hideMe($n(row, 'myopac_hold_unfrozen_false'))
}
+ $n(row, 'myopac_holds_selected_chkbx').checked = false;
+
unHideMe(row);
myOPACDrawHoldTitle(h);
@@ -1298,4 +1304,74 @@
}
+/* myopac_holds_checkbx */
+function myopacSelectAllHolds() {
+ var rows = getTableRows($("myopac_holds_tbody"));
+ for(var i = 0; i < rows.length; i++) {
+ cb = $n(rows[i], 'myopac_holds_selected_chkbx');
+ if(cb) cb.checked = true;
+ }
+}
+function myopacSelectNoneHolds() {
+ var rows = getTableRows($("myopac_holds_tbody"));
+ for(var i = 0; i < rows.length; i++) {
+ cb = $n(rows[i], 'myopac_holds_selected_chkbx');
+ if(cb) cb.checked = false;
+ }
+}
+
+function myopacSelectedHoldsRows() {
+ var r = [];
+ var rows = getTableRows($("myopac_holds_tbody"));
+ for(var i = 0; i < rows.length; i++) {
+ cb = $n(rows[i], 'myopac_holds_selected_chkbx');
+ if(cb && cb.checked)
+ r.push(rows[i]);
+ }
+ return r;
+}
+
+var myopacCancelledHolds = 0;
+var myopacTotalHoldsToCancel = 0;
+function myopacDoHoldAction() {
+
+ switch(getSelectorVal($('myopac_holds_actions'))) {
+ case 'cancel':
+ myopacBatchCancelHold();
+ break;
+ }
+}
+
+function myopacBatchCancelHold() {
+ if(!confirmId('myopac.holds.cancel.confirm')) return;
+
+
+ myopacCancelledHolds = 0;
+ var rows = myopacSelectedHoldsRows();
+ myopacTotalHoldsToCancel = rows.length;
+ if(myopacTotalHoldsToCancel == 0) return;
+
+ unHideMe($('myopac_holds_processing'));
+ hideMe($('myopac_holds_main_table'));
+
+ for(var i = 0; i < rows.length; i++) {
+ var row = rows[i];
+ id = row.id.replace(/.*_(\d+)$/, '$1');
+ _debug("cancelling hold " + i);
+ var req = new Request(CANCEL_HOLD, G.user.session, id);
+ req.callback(myopacBatchCancelHoldCallback);
+ req.send();
+ }
+}
+
+function myopacBatchCancelHoldCallback(r) {
+ r.getResultObject();
+ if(++myopacCancelledHolds >= myopacTotalHoldsToCancel) {
+ hideMe($('myopac_holds_processing'));
+ unHideMe($('myopac_holds_main_table'));
+ holdCache = {};
+ myopacForceHoldsRedraw = true;
+ myOPACShowHolds();
+ }
+}
Modified: trunk/Open-ILS/web/opac/skin/default/xml/myopac/myopac_holds.xml
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/xml/myopac/myopac_holds.xml 2007-09-13 19:31:32 UTC (rev 7777)
+++ trunk/Open-ILS/web/opac/skin/default/xml/myopac/myopac_holds.xml 2007-09-13 21:34:52 UTC (rev 7778)
@@ -3,8 +3,28 @@
<script language='javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/holds.js'> </script>
- <table width='100%' class='light_border data_grid data_grid_center'>
+ <table width='100%'>
+ <tbody><tr><td width='100%' align='right'>
+ <select id='myopac_holds_actions' onchange='myopacDoHoldAction();'>
+ <option id='myopac_holds_actions_none' value=''>-- &myopac.holds.actions; --</option>
+ <option value='freeze'>&myopac.holds.freeze_selected;</option>
+ <option value='thaw'>&myopac.holds.thaw_selected;</option>
+ <option value='cancel'>&myopac.holds.cancel_selected;</option>
+ </select>
+ </td></tr></tbody>
+ <script>$('myopac_holds_actions_none').selected = true;</script>
+ </table>
+ <span id='myopac.holds.cancel.confirm' class='hide_me'>&myopac.holds.cancel.confirm;</span>
+ <span id='myopac.holds.freeze.confirm' class='hide_me'>&myopac.holds.freeze.confirm;</span>
+ <span id='myopac.holds.thaw.confirm' class='hide_me'>&myopac.holds.thaw.confirm;</span>
+
+ <table width='100%' id='myopac_holds_processing' class='hide_me'>
+ <tr><td>&myopac.holds.processing;</td></tr>
+ </table>
+
+ <table width='100%' class='light_border data_grid data_grid_center' id='myopac_holds_main_table'>
+
<thead class='color_3'>
<tr>
<td width='30%'>&common.title;</td>
@@ -14,6 +34,12 @@
<td>&common.status;</td>
<td>&myopac.holds.unfrozen;</td>
<td>&myopac.holds.frozen.until;</td>
+ <td width='15%'>&common.select;
+ (<a id='myopac_select_all_holds' onclick='myopacSelectAllHolds();'
+ class='classic_link' href='javascript:void(0);'>&common.all;</a>/<a id='myopac_select_none_holds'
+ onclick='myopacSelectNoneHolds();' class='classic_link' href='javascript:void(0);'>&common.none;</a>)
+ </td>
+
<td>&myopac.holds.edit.cancel;</td>
</tr>
</thead>
@@ -54,6 +80,7 @@
</td>
<td name='myopac_holds_frozen_until'></td>
+ <td><input type='checkbox' name='myopac_holds_selected_chkbx'/></td>
<td name='myopac_holds_cancel' style='border-left: 3px solid #E0E0E0; border-right: 3px solid #E0E0E0;'>
<a href='javascript:void(0);'
More information about the open-ils-commits
mailing list