[open-ils-commits] r12553 - in trunk/Open-ILS/web: js/ui/default/acq/common js/ui/default/acq/picklist templates/default/acq/common templates/default/acq/picklist (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Mar 16 23:12:03 EDT 2009
Author: erickson
Date: 2009-03-16 23:12:01 -0400 (Mon, 16 Mar 2009)
New Revision: 12553
Added:
trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
Modified:
trunk/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js
trunk/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2
Log:
moved lineitem table out to generic template for import. this will eventually take the place of jubgrid in most cases. still need to plug some final holes for basica functionality
Added: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js (rev 0)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2009-03-17 03:12:01 UTC (rev 12553)
@@ -0,0 +1,71 @@
+dojo.require('openils.acq.Lineitem');
+
+function AcqLiTable() {
+
+ var self = this;
+ this.liCache = {};
+ this.toggleState = false;
+ this.tbody = dojo.byId('acq-lit-tbody');
+ this.selectors = [];
+ this.rowTemplate = this.tbody.removeChild(dojo.byId('acq-lit-row'));
+ dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()};
+
+ this.reset = function() {
+ while(self.tbody.childNodes[0])
+ self.tbody.removeChild(self.tbody.childNodes[0]);
+ self.selectors = [];
+ };
+
+ this.showTable = function() {
+ dojo.style(dojo.byId('acq-lit-table-div'), 'display', 'block');
+ dojo.style(dojo.byId('acq-lit-info-div'), 'display', 'none');
+ };
+
+ this.hideTable = function() {
+ dojo.style(dojo.byId('acq-lit-table-div'), 'display', 'none');
+ };
+
+ this.showInfo = function() {
+ self.hideTable();
+ dojo.style(dojo.byId('acq-lit-info-div'), 'display', 'block');
+ };
+
+ this.toggleSelect = function() {
+ if(self.toggleState)
+ dojo.forEach(self.selectors, function(i){i.checked = false});
+ else
+ dojo.forEach(self.selectors, function(i){i.checked = true});
+ self.toggleState = !self.toggleState;
+ };
+
+ this.getSelected = function() {
+ var selected = [];
+ dojo.forEach(self.selectors,
+ function(i) {
+ if(!i.checked) return;
+ selected.push(self.liCache[i.parentNode.parentNode.getAttribute('li')]);
+ }
+ );
+ return selected;
+ };
+
+ this.setRowAttr = function(td, liWrapper, field) {
+ var val = liWrapper.findAttr(field, 'lineitem_marc_attr_definition') || '';
+ td.appendChild(document.createTextNode(val));
+ };
+
+ this.addLineitem = function(li) {
+ this.liCache[li.id()] = li;
+ var liWrapper = new openils.acq.Lineitem({lineitem:li});
+ var row = self.rowTemplate.cloneNode(true);
+ row.setAttribute('li', li.id());
+ var tds = dojo.query('[attr]', row);
+ dojo.forEach(tds, function(td) {self.setRowAttr(td, liWrapper, td.getAttribute('attr'));});
+ dojo.query('[name=source_label]', row)[0].appendChild(document.createTextNode(li.source_label()));
+ self.tbody.appendChild(row);
+ self.selectors.push(dojo.query('[name=selectbox]', row)[0]);
+ };
+}
+
+
+
Modified: trunk/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js 2009-03-17 03:09:04 UTC (rev 12552)
+++ trunk/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js 2009-03-17 03:12:01 UTC (rev 12553)
@@ -20,8 +20,10 @@
var user = new openils.User();
var searchLimit = 10;
var liCache = {};
+var liTable;
function drawForm() {
+ liTable = new AcqLiTable();
fieldmapper.standardRequest(
['open-ils.search', 'open-ils.search.z3950.retrieve_services'],
{ async: true,
@@ -82,11 +84,6 @@
function doSearch(values) {
showDiv('oils-acq-pl-loading');
- var tbody = dojo.byId('plist-tbody');
- if(!resultRow)
- resultRow = tbody.removeChild(dojo.byId('plist-row'));
- while(tbody.childNodes[0]) tbody.removeChild(tbody.childNodes[0]);
-
search = {
service : [],
username : [],
@@ -122,26 +119,7 @@
);
}
-var selectState = false;
-function toggleSelect() {
- var inputs = dojo.query('[name=selectbox]', dojo.byId('plist-tbody'));
- if(selectState)
- dojo.forEach(inputs, function(i){i.checked = false});
- else
- dojo.forEach(inputs, function(i){i.checked = true});
- selectState = !selectState;
-}
-function getSelected() {
- var inputs = dojo.query('[name=selectbox]', dojo.byId('plist-tbody'));
- var selected = [];
- dojo.forEach(inputs, function(i) {
- if(i.checked)
- selected.push(liCache[i.parentNode.parentNode.getAttribute('li')]);
- });
- return selected;
-}
-
function setRowAttr(td, liWrapper, field) {
var val = liWrapper.findAttr(field, 'lineitem_marc_attr_definition') || '';
td.appendChild(document.createTextNode(val));
@@ -149,32 +127,22 @@
function handleResult(r) {
var result = openils.Util.readResponse(r);
- dojo.style('oils-acq-pl-search-results', 'display', 'block');
+ liTable.showTable();
+ dojo.style(dojo.byId('oils-acq-pl-search-results'), 'display', 'block');
var tbody = dojo.byId('plist-tbody');
-
- if(result.lineitem) {
- var li = result.lineitem;
- liCache[li.id()] = li;
- var liWrapper = new openils.acq.Lineitem({lineitem:li});
- var row = resultRow.cloneNode(true);
- row.setAttribute('li', li.id());
- var tds = dojo.query('[attr]', row);
- dojo.forEach(tds, function(td) {setRowAttr(td, liWrapper, td.getAttribute('attr'));});
- dojo.query('[name=source_label]', row)[0].appendChild(document.createTextNode(li.source_label()));
- tbody.appendChild(row);
- }
-
+ if(result.lineitem)
+ liTable.addLineitem(result.lineitem);
if(result.complete) // hide the loading image
- showDiv('oils-acq-pl-search-results');
+ dojo.style('oils-acq-pl-loading','display', 'none');
}
function showDiv(div) {
var divs = [
- 'oils-acq-pl-search-results',
'oils-acq-search-block',
'oils-acq-pl-loading' ];
dojo.forEach(divs, function(d) {dojo.style(d,'display', 'none')});
+ liTable.hideTable();
dojo.style(div, 'display', 'block');
}
@@ -203,8 +171,8 @@
selectedLIs = resultLIs;
if(values.which == 'selected')
- selectedLIs = getSelected();
-
+ selectedLIs = liTable.getSelected();
+
if(values.new_name && values.new_name != '') {
// save selected lineitems to a new picklist
if(values.which = 'selected') {
Added: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 (rev 0)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 2009-03-17 03:12:01 UTC (rev 12553)
@@ -0,0 +1,38 @@
+<script src='[% ctx.media_prefix %]/js/ui/default/acq/common/li_table.js'> </script>
+<div id='acq-lit-table-container'>
+ <div id='acq-lit-table-div' class='hidden'>
+ <table id='acq-lit-table'>
+ <thead>
+ <tr>
+ <th colspan='0'><a id='acq-lit-select-toggle' href='javascript:void(0);'>Select</a></th>
+ </tr>
+ </thead>
+ <tbody id='acq-lit-tbody'>
+ <tr id='acq-lit-row' class='acq-lit-row'>
+ <td name='selector'><input type='checkbox' name='selectbox'/></td>
+ <td>
+ <table>
+ <tr><td attr='title' colspan='0'/></tr>
+ <tr class='acq-lit-alt-row'>
+ <td/>
+ <td attr='author'/>
+ <td attr='isbn'/>
+ <td attr='issn'/>
+ <td attr='edition'/>
+ <td attr='pubdate'/>
+ <td attr='publisher'/>
+ </tr>
+ <tr class='acq-lit-alt-row'>
+ <td/>
+ <td name='source_label' colspan='0'/>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id='acq-lit-info-div' class='hidden'>
+ </div>
+</div>
+
Modified: trunk/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2 2009-03-17 03:09:04 UTC (rev 12552)
+++ trunk/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2 2009-03-17 03:12:01 UTC (rev 12553)
@@ -93,29 +93,7 @@
</div>
</div>
<div dojoType='dijit.layout.ContentPane' layoutAlign='client'>
- <table id='oila-acq-picklist-result-table'>
- <thead>
- <tr>
- <th><a href='javascript:toggleSelect();'>Select</a></th>
- <th>Title</th><th>Author</th><th>ISBN</th>
- <th>ISSN</th><th>Edition</th><th>Pubdate</th>
- <th>Publisher</th><th>Source</th>
- </tr>
- </thead>
- <tbody id='plist-tbody'>
- <tr id='plist-row'>
- <td name='selector'><input type='checkbox' name='selectbox'/></td>
- <td attr='title'/>
- <td attr='author'/>
- <td attr='isbn'/>
- <td attr='issn'/>
- <td attr='edition'/>
- <td attr='pubdate'/>
- <td attr='publisher'/>
- <td name='source_label'/>
- </tr>
- </tbody>
- </table>
+ [% INCLUDE 'default/acq/common/li_table.tt2' %]
</div>
</div>
More information about the open-ils-commits
mailing list