[open-ils-commits] r17402 - in branches/rel_1_6/Open-ILS: web/opac/skin/default/js xul/staff_client/chrome/content/cat xul/staff_client/server/cat (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Aug 31 10:54:25 EDT 2010
Author: dbs
Date: 2010-08-31 10:54:23 -0400 (Tue, 31 Aug 2010)
New Revision: 17402
Modified:
branches/rel_1_6/Open-ILS/web/opac/skin/default/js/rdetail.js
branches/rel_1_6/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/marcedit.js
branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/marcedit.xul
branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/z3950.js
Log:
Backport bib-source selector from trunk (r13793)
Enables one to edit the bib source of a given MARC record in the MARC editor
Modified: branches/rel_1_6/Open-ILS/web/opac/skin/default/js/rdetail.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/skin/default/js/rdetail.js 2010-08-31 12:48:32 UTC (rev 17401)
+++ branches/rel_1_6/Open-ILS/web/opac/skin/default/js/rdetail.js 2010-08-31 14:54:23 UTC (rev 17402)
@@ -212,7 +212,7 @@
dojo.require('openils.PermaCrud');
win.xulG = {
- "record": {"marc": rec.marc()},
+ "record": {"marc": rec.marc(), "rtype": "sre"},
"save": {
"label": opac_strings.SAVE_MFHD_LABEL,
"func": function(xmlString) {
Modified: branches/rel_1_6/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
===================================================================
--- branches/rel_1_6/Open-ILS/xul/staff_client/chrome/content/cat/opac.js 2010-08-31 12:48:32 UTC (rev 17401)
+++ branches/rel_1_6/Open-ILS/xul/staff_client/chrome/content/cat/opac.js 2010-08-31 14:54:23 UTC (rev 17402)
@@ -72,7 +72,7 @@
var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
var b = {};
var c = {
- 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid },
+ 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid, "id": docid, "rtype": "bre" },
'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
try {
var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
Modified: branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/marcedit.js
===================================================================
--- branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/marcedit.js 2010-08-31 12:48:32 UTC (rev 17401)
+++ branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/marcedit.js 2010-08-31 14:54:23 UTC (rev 17402)
@@ -100,11 +100,30 @@
var cgi = new CGI();
var _rid = cgi.param('record');
if (_rid) {
+ window.xulG.record.id = _rid;
window.xulG.record.url = '/opac/extras/supercat/retrieve/marcxml/record/' + _rid;
}
}
+
// End faking part...
+ /* Check for an explicitly passed record type
+ * This is not the same as the fixed-field record type; we can't trust
+ * the fixed fields when making modifications to the attributes for a
+ * given record (in particular, config.bib_source only applies for bib
+ * records, but an auth or MFHD record with the same ID and bad fixed
+ * fields could trample the config.bib_source value for the
+ * corresponding bib record if we're not careful.
+ *
+ * are = authority record
+ * sre = serial record (MFHD)
+ * bre = bibliographic record
+ */
+ if (!window.xulG.record.rtype) {
+ var cgi = new CGI();
+ window.xulG.record.rtype = cgi.param('rtype') || false;
+ }
+
document.getElementById('save-button').setAttribute('label', window.xulG.save.label);
document.getElementById('save-button').setAttribute('oncommand',
'mangle_005(); ' +
@@ -247,6 +266,19 @@
}
document.getElementById('fastItemAdd_textboxes').hidden = document.getElementById('fastItemAdd_checkbox').hidden || !document.getElementById('fastItemAdd_checkbox').checked;
+ // Only show bib sources for bib records that already exist in the database
+ if (xulG.record.rtype == 'bre' && xulG.record.id) {
+ dojo.require('openils.PermaCrud');
+ var authtoken = ses();
+ // Retrieve the current record attributes
+ var bib = new openils.PermaCrud({"authtoken": authtoken}).retrieve('bre', xulG.record.id);
+
+ // Remember the current bib source of the record
+ xulG.record.bre = bib;
+
+ buildBibSourceList(authtoken, xulG.record.id);
+ }
+
} catch(E) {
alert('FIXME, MARC Editor, my_init: ' + E);
}
@@ -2091,3 +2123,65 @@
}
+function buildBibSourceList (authtoken, recId) {
+ /* TODO: Work out how to set the bib source of the bre that does not yet
+ * exist - this is specifically in the case of Z39.50 imports. Right now
+ * we just avoid populating and showing the config.bib_source list
+ */
+ if (!recId) {
+ return false;
+ }
+
+ var bib = xulG.record.bre;
+
+ dojo.require('openils.PermaCrud');
+
+ // cbsList = the XUL menulist that contains the available bib sources
+ var cbsList = dojo.byId('bib-source-list');
+
+ // bibSources = an array containing all of the bib source objects
+ var bibSources = new openils.PermaCrud({"authtoken": authtoken}).retrieveAll('cbs');
+
+ // A tad ugly, but gives us the index of the bib source ID in cbsList
+ var x = 0;
+ var cbsListArr = [];
+ dojo.forEach(bibSources, function (item) {
+ cbsList.appendItem(item.source(), item.id());
+ cbsListArr[item.id()] = x;
+ x++;
+ });
+
+ // Show the current value of the bib source for this record
+ cbsList.selectedIndex = cbsListArr[bib.source()];
+
+ // Display the bib source selection widget
+ dojo.byId('bib-source-list-caption').hidden = false;
+ dojo.byId('bib-source-list').hidden = false;
+ dojo.byId('bib-source-list-button').disabled = true;
+ dojo.byId('bib-source-list-button').hidden = false;
+}
+
+// Fired when the "Update Source" button is clicked
+// Updates the value of the bib source for the current record
+function updateBibSource() {
+ var authtoken = ses();
+ var cbs = dojo.byId('bib-source-list').selectedItem.value;
+ var recId = xulG.record.id;
+ var pcrud = new openils.PermaCrud({"authtoken": authtoken});
+ var bib = pcrud.retrieve('bre', recId);
+ if (bib.source() != cbs) {
+ bib.source(cbs);
+ bib.ischanged = true;
+ pcrud.update(bib);
+ }
+}
+
+function onBibSourceSelect() {
+ var cbs = dojo.byId('bib-source-list').selectedItem.value;
+ var bib = xulG.record.bre;
+ if (bib.source() != cbs) {
+ dojo.byId('bib-source-list-button').disabled = false;
+ } else {
+ dojo.byId('bib-source-list-button').disabled = true;
+ }
+}
Modified: branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/marcedit.xul
===================================================================
--- branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/marcedit.xul 2010-08-31 12:48:32 UTC (rev 17401)
+++ branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/marcedit.xul 2010-08-31 14:54:23 UTC (rev 17402)
@@ -15,6 +15,8 @@
<scripts id="openils_util_scripts"/>
<script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+<script>var djConfig = { 'baseUrl' : '/js/dojo/dojo/',parseOnLoad: true,isDebug:false };</script>
+<script type="text/javascript" src="/js/dojo/dojo/dojo.js" />
<script src="marcedit.js" type="application/x-javascript; e4x=1"/>
@@ -183,6 +185,12 @@
</grid>
</vbox>
</groupbox>
+
+ <vbox>
+ <caption id="bib-source-list-caption" hidden="true">Bibliographic source</caption>
+ <menulist id="bib-source-list" rows="3" hidden="true" onselect='onBibSourceSelect();'><menupopup id='bib-source-list-popup'></menupopup></menulist>
+ <button id="bib-source-list-button" label="Update source" disabled="true" oncommand="updateBibSource();" hidden="true"/>
+ </vbox>
</hbox>
<grid id="recGrid" flex="1">
Modified: branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/z3950.js
===================================================================
--- branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/z3950.js 2010-08-31 12:48:32 UTC (rev 17401)
+++ branches/rel_1_6/Open-ILS/xul/staff_client/server/cat/z3950.js 2010-08-31 14:54:23 UTC (rev 17402)
@@ -709,7 +709,7 @@
xulG.url_prefix(urls.XUL_MARC_EDIT),
{ 'tab_name' : 'MARC Editor' },
{
- 'record' : { 'marc' : my_marcxml },
+ 'record' : { 'marc' : my_marcxml, "rtype": "bre" },
'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
try {
JSAN.use('cat.util'); return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
More information about the open-ils-commits
mailing list