[open-ils-commits] r17435 - in branches/rel_2_0/Open-ILS: src/perlmods/OpenILS/Application src/perlmods/OpenILS/Application/Cat web/js/ui/default/acq/common web/js/ui/default/vandelay xul/staff_client/chrome/content/cat xul/staff_client/server/cat (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 1 23:06:35 EDT 2010
Author: dbs
Date: 2010-09-01 23:06:33 -0400 (Wed, 01 Sep 2010)
New Revision: 17435
Modified:
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
branches/rel_2_0/Open-ILS/web/js/ui/default/acq/common/li_table.js
branches/rel_2_0/Open-ILS/web/js/ui/default/vandelay/vandelay.js
branches/rel_2_0/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.js
branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.xul
branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/z3950.js
Log:
Backport biblio source enhancements from trunk:
* Make biblio source selection in Vandelay set the source for imported
bib records.
* Place a biblio source editor widget on the MARC Editor when invoked
with a biblio record that already exists in the database ("rtype": "bre"
with a specific ID).
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm 2010-09-02 02:35:37 UTC (rev 17434)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm 2010-09-02 03:06:33 UTC (rev 17435)
@@ -89,6 +89,9 @@
return $evt if $evt;
}
+ # Silence warnings when _find_tcn_info() fails
+ $tcn ||= '';
+ $tcn_source ||= '';
$logger->info("user ".$e->requestor->id.
" creating new biblio entry with tcn=$tcn and tcn_source $tcn_source");
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2010-09-02 02:35:37 UTC (rev 17434)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2010-09-02 03:06:33 UTC (rev 17435)
@@ -44,6 +44,7 @@
x => 'holdings',
y => 'holdings',
z => 'auth',
+ ' ' => 'bib',
);
sub initialize {}
@@ -624,6 +625,13 @@
my $update_queue_func = 'update_vandelay_bib_queue';
my $rec_class = 'vqbr';
+ my %bib_sources;
+ my $editor = new_editor();
+ my $sources = $editor->search_config_bib_source({id => {'!=' => undef}});
+ foreach my $src (@$sources) {
+ $bib_sources{$src->id} = $src->source;
+ }
+
if($type eq 'auth') {
$overlay_func =~ s/bib/auth/o;
$auto_overlay_func = s/bib/auth/o;
@@ -737,8 +745,7 @@
# No overlay / merge occurred. Do a traditional record import by creating a new record
if($type eq 'bib') {
- $record = OpenILS::Application::Cat::BibCommon->biblio_record_xml_import($e, $rec->marc); #$rec->bib_source
-
+ $record = OpenILS::Application::Cat::BibCommon->biblio_record_xml_import($e, $rec->marc, $bib_sources{$rec->bib_source});
} else {
$record = OpenILS::Application::Cat::AuthCommon->import_authority_record($e, $rec->marc); #$source);
Modified: branches/rel_2_0/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/ui/default/acq/common/li_table.js 2010-09-02 02:35:37 UTC (rev 17434)
+++ branches/rel_2_0/Open-ILS/web/js/ui/default/acq/common/li_table.js 2010-09-02 03:06:33 UTC (rev 17435)
@@ -2308,7 +2308,7 @@
}
var self = this;
win.xulG = {
- record : {marc : li.marc()},
+ record : {marc : li.marc(), "rtype": "bre"},
save : {
label: 'Save Record', // XXX I18N
func: function(xmlString) {
Modified: branches/rel_2_0/Open-ILS/web/js/ui/default/vandelay/vandelay.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/ui/default/vandelay/vandelay.js 2010-09-02 02:35:37 UTC (rev 17434)
+++ branches/rel_2_0/Open-ILS/web/js/ui/default/vandelay/vandelay.js 2010-09-02 03:06:33 UTC (rev 17435)
@@ -1055,6 +1055,13 @@
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
+ var type;
+ if (currentType == 'bib') {
+ type = 'bre';
+ } else {
+ type = 'are';
+ }
+
function onsave(r) {
// after the record is saved, reload the HTML display
var stat = r.recv().content();
@@ -1066,7 +1073,7 @@
}
win.xulG = {
- record : {marc : rec.marc()},
+ record : {marc : rec.marc(), "rtype": type},
save : {
label: dojo.byId('vl-marc-edit-save-label').innerHTML,
func: function(xmlString) {
Modified: branches/rel_2_0/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/chrome/content/cat/opac.js 2010-09-02 02:35:37 UTC (rev 17434)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/chrome/content/cat/opac.js 2010-09-02 03:06:33 UTC (rev 17435)
@@ -121,7 +121,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_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.js 2010-09-02 02:35:37 UTC (rev 17434)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.js 2010-09-02 03:06:33 UTC (rev 17435)
@@ -140,11 +140,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',
'if ($("xul-editor").hidden) swap_editors(); ' +
@@ -288,6 +307,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);
}
@@ -1865,11 +1897,19 @@
var fields = xml.datafield;
for (var j in fields) {
+ /* Restrict options to Heading Information fields (1xx)
+ * and See Also From fields (5xx) rather than displaying
+ * every field in the authority record */
+ var tag = fields[j]. at tag;
+ if (tag.substr(0,1) != 1 && tag.substr(0,1) != 5) {
+ continue;
+ }
+
var row = createRow(
{},
- createLabel( { value : fields[j]. at tag } ),
- createLabel( { value : fields[j]. at ind1 } ),
- createLabel( { value : fields[j]. at ind2 } )
+ createLabel( { "value" : tag } ),
+ createLabel( { "value" : fields[j]. at ind1 } ),
+ createLabel( { "value" : fields[j]. at ind2 } )
);
var sf_box = createHbox();
@@ -1878,10 +1918,10 @@
for (var k in subfields) {
sf_box.appendChild(
createCheckbox(
- { label : '\u2021' + subfields[k]. at code + ' ' + subfields[k],
- subfield : subfields[k]. at code,
- tag : subfields[k].parent(). at tag,
- value : subfields[k]
+ { "label" : '\u2021' + subfields[k]. at code + ' ' + subfields[k],
+ "subfield" : subfields[k]. at code,
+ "tag" : subfields[k].parent(). at tag,
+ "value" : subfields[k]
}
)
);
@@ -2295,3 +2335,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_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.xul
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.xul 2010-09-02 02:35:37 UTC (rev 17434)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.xul 2010-09-02 03:06:33 UTC (rev 17435)
@@ -236,6 +236,12 @@
</grid>
</vbox>
</groupbox>
+
+ <vbox>
+ <caption id="bib-source-list-caption" hidden="true">&staff.cat.marcedit.source.caption;</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="&staff.cat.marcedit.source.submit.label;" disabled="true" oncommand="updateBibSource();" hidden="true"/>
+ </vbox>
</hbox>
<grid id="recGrid" flex="1">
Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/z3950.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/z3950.js 2010-09-02 02:35:37 UTC (rev 17434)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/z3950.js 2010-09-02 03:06:33 UTC (rev 17435)
@@ -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