From: dbs Date: Sun, 2 Jan 2011 18:30:02 +0000 (+0000) Subject: Improve see from / see also handling in MARC editor authority menu X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9c43e9df3484aa7002232ea6b8f33f1d089fbc65;p=evergreen%2Fbjwebb.git Improve see from / see also handling in MARC editor authority menu The 2.0-style authorities use a browse menu that currently consists of matches against the 1XX entries, which makes working with see from / see also entries rather difficult. To prepare for an authority browse method that does surface matches against 4xx and 5xx entries, we will now display the 4xx and 5xx entries for a given authority record immediately below the 1xx entry in the browse menu, with the entry text italicized, aligned to the right, and prefixed with "See also" or "See from" appropriately. This won't provide a perfect alphabetized solution - we won't know which field provided the alphabetical browse match, so the best we can do is present the 1xx in the main browse menu and the 4xx / 5xx below - but it will provide access to the other references. We now display the 4xx fields in the authority summary / selector menu along with the 5xx fields. As part of making the 4xx and 5xx fields first-class entries in the context menu, 5xx subfields are no longer appended to their 1xx field menu entry with a "/" in the context menu. $0 subfields are no longer added to the 4xx and 5xx fields from the authority summary / selector menu; if a user had selected a 5xx and the $0 that had been added by the menu, the field would have incorrectly been linked to the 1xx authority record. To link to a 5xx entry, for now the workaround is for the user to select the 5xx subfield(s), "Apply Selected", then right-click on the new subfield to generate a new authority context menu. To improve the 5xx handling, we need to make the "See also" entry fire a new authority context menu based on the 5xx contents so that the actual 1xx authority record can be inserted and linked against. Consider an authority record containing the following fields: 150 $a Infants 450 $a Babies 550 $a Children The ASCII-ized authority context menu will now display: Infants -> See from: Babies -> See also: Children -> The submenu in each case will currently lead to the authority record for "Infants". If we teach the underlying authority browse and startswith methods to return matches based on 4xx and 5xx fields instead of just 1xx fields, then the menu triggered by a right-click on "Childs" might look like: Chickens -> Infants -> See from: Babies -> See also: Children -> Choking -> The main entry will be out of alphabetical order, which is not ideal, but the linkage from the 5xx should at least be evident. (Also, this suggests that when clicking on a 5xx entry in the authority menu is changed to launch a new authority menu, it should use the 1xx-only browse variant to avoid showing the record from which the user was referred...) git-svn-id: svn://svn.open-ils.org/ILS/trunk@19091 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.js b/Open-ILS/xul/staff_client/server/cat/marcedit.js index fa8678047..4e597aa07 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.js +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.js @@ -2446,10 +2446,13 @@ function browseAuthority (sf_popup, menu_id, target, sf, limit, page) { dojo.query('record', records).forEach(function(record) { var main_text = ''; + var see_from = []; + var see_also = []; var auth_id = dojox.xml.parser.textContent(dojo.query('datafield[tag="901"] subfield[code="c"]', record)[0]); var auth_org = dojox.xml.parser.textContent(dojo.query('controlfield[tag="003"]', record)[0]); - // we have grabbed the fields with tags beginning with 1 or 5 and iterate through the subfields - dojo.query('datafield[tag^="1"], datafield[tag^="5"]', record).forEach(function(field) { + + // Grab the fields with tags beginning with 1 (main entries) and iterate through the subfields + dojo.query('datafield[tag^="1"]', record).forEach(function(field) { dojo.query('subfield', field).forEach(function(subfield) { if (main_text) { main_text += ' / '; @@ -2458,85 +2461,42 @@ function browseAuthority (sf_popup, menu_id, target, sf, limit, page) { }); }); - /* - * - if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) return; - */ - - var grid = dojo.query('[name="authority-marc-template"]')[0].cloneNode(true); - grid.setAttribute('name','-none-'); - grid.setAttribute('style','overflow:scroll'); - - var submenu = createMenu( { label : main_text } ); - - var popup = createMenuPopup({ flex : "1" }); - submenu.appendChild(popup); - - dojo.query('datafield[tag^="1"], datafield[tag^="5"]', record).forEach(function(field) { - var row = createRow( - { }, - createLabel( { "value" : dojo.attr(field, 'tag') } ), - createLabel( { "value" : dojo.attr(field, 'ind1') } ), - createLabel( { "value" : dojo.attr(field, 'ind2') } ) - ); - - var sf_box = createHbox(); + // Grab the fields with tags beginning with 4 (see from entries) and iterate through the subfields + dojo.query('datafield[tag^="4"]', record).forEach(function(field) { + var see_text = ''; dojo.query('subfield', field).forEach(function(subfield) { - sf_box.appendChild( - createCheckbox( - { "label" : '\u2021' + dojo.attr(subfield, 'code') + ' ' + dojox.xml.parser.textContent(subfield), - "subfield" : dojo.attr(subfield, 'code'), - "tag" : dojo.attr(field, 'tag'), - "value" : dojox.xml.parser.textContent(subfield) - } - ) - ); - row.appendChild(sf_box); + if (see_text) { + see_text += ' / '; + } + see_text += dojox.xml.parser.textContent(subfield); }); - - // Append the authority linking subfield - sf_box.appendChild( - createCheckbox( - { "label" : '\u2021' + '0' + ' (' + auth_org + ')' + auth_id, - "subfield" : '0', - "tag" : dojo.attr(field, 'tag'), - "value" : '(' + auth_org + ')' + auth_id - } - ) - ); - row.appendChild(sf_box); - - grid.lastChild.appendChild(row); + see_from.push($('catStrings').getFormattedString('staff.cat.marcedit.authority_see_from', [see_text])); }); - grid.hidden = false; - popup.appendChild( grid ); - - popup.appendChild( - createMenuitem( - { label : $('catStrings').getString('staff.cat.marcedit.apply_selected.label'), - command : function (event) { - applySelectedAuthority(event.target.previousSibling, target, sf); - return true; - } + // Grab the fields with tags beginning with 5 (see also entries) and iterate through the subfields + dojo.query('datafield[tag^="5"]', record).forEach(function(field) { + var see_text = ''; + dojo.query('subfield', field).forEach(function(subfield) { + if (see_text) { + see_text += ' / '; } - ) - ); + see_text += dojox.xml.parser.textContent(subfield); + }); + see_also.push($('catStrings').getFormattedString('staff.cat.marcedit.authority_see_also', [see_text])); + }); - popup.appendChild( createComplexXULElement( 'menuseparator' ) ); + buildAuthorityPopup(main_text, record, auth_org, auth_id, sf_popup, target, sf); - popup.appendChild( - createMenuitem( - { label : $('catStrings').getString('staff.cat.marcedit.apply_full.label'), - command : function (event) { - applyFullAuthority(event.target.previousSibling.previousSibling.previousSibling, target, sf); - return true; - } - } - ) - ); + dojo.forEach(see_from, function(entry_text) { + buildAuthorityPopup(entry_text, record, auth_org, auth_id, sf_popup, target, sf, "font-style: italic; text-align: right; margin-left: 2em;"); + }); + + // To-do: instead of launching the standard selector menu, invoke + // a new authority search using the 5XX entry text + dojo.forEach(see_also, function(entry_text) { + buildAuthorityPopup(entry_text, record, auth_org, auth_id, sf_popup, target, sf, "font-style: italic; text-align: right; margin-left: 2em;"); + }); - sf_popup.appendChild( submenu ); }); if (sf_popup.childNodes.length == 0) { @@ -2560,6 +2520,93 @@ function browseAuthority (sf_popup, menu_id, target, sf, limit, page) { } +function buildAuthorityPopup (entry_text, record, auth_org, auth_id, sf_popup, target, sf, style) { + var grid = dojo.query('[name="authority-marc-template"]')[0].cloneNode(true); + grid.setAttribute('name','-none-'); + grid.setAttribute('style','overflow:scroll'); + + var submenu = createMenu( { "label": entry_text } ); + + var popup = createMenuPopup({ "flex": "1" }); + if (style) { + submenu.setAttribute('style', style); + popup.setAttribute('style', 'font-style: normal; text-align: left; margin-left: 0em;'); + } + submenu.appendChild(popup); + + dojo.query('datafield[tag^="1"], datafield[tag^="4"], datafield[tag^="5"]', record).forEach(function(field) { + buildAuthorityPopupSelector(field, grid, auth_org, auth_id); + }); + + grid.hidden = false; + popup.appendChild( grid ); + + popup.appendChild( + createMenuitem( + { label : $('catStrings').getString('staff.cat.marcedit.apply_selected.label'), + command : function (event) { + applySelectedAuthority(event.target.previousSibling, target, sf); + return true; + } + } + ) + ); + + popup.appendChild( createComplexXULElement( 'menuseparator' ) ); + + popup.appendChild( + createMenuitem( + { label : $('catStrings').getString('staff.cat.marcedit.apply_full.label'), + command : function (event) { + applyFullAuthority(event.target.previousSibling.previousSibling.previousSibling, target, sf); + return true; + } + } + ) + ); + + sf_popup.appendChild( submenu ); +} + +function buildAuthorityPopupSelector (field, grid, auth_org, auth_id) { + var row = createRow( + { }, + createLabel( { "value" : dojo.attr(field, 'tag') } ), + createLabel( { "value" : dojo.attr(field, 'ind1') } ), + createLabel( { "value" : dojo.attr(field, 'ind2') } ) + ); + + var sf_box = createHbox(); + dojo.query('subfield', field).forEach(function(subfield) { + sf_box.appendChild( + createCheckbox( + { "label" : '\u2021' + dojo.attr(subfield, 'code') + ' ' + dojox.xml.parser.textContent(subfield), + "subfield" : dojo.attr(subfield, 'code'), + "tag" : dojo.attr(field, 'tag'), + "value" : dojox.xml.parser.textContent(subfield) + } + ) + ); + row.appendChild(sf_box); + }); + + // Append the authority linking subfield only for main entries + if (dojo.attr(field, 'tag').charAt(0) == '1') { + sf_box.appendChild( + createCheckbox( + { "label" : '\u2021' + '0' + ' (' + auth_org + ')' + auth_id, + "subfield" : '0', + "tag" : dojo.attr(field, 'tag'), + "value" : '(' + auth_org + ')' + auth_id + } + ) + ); + } + row.appendChild(sf_box); + + grid.lastChild.appendChild(row); +} + function summarizeField(sf) { var source_f= { "tag": '', diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index 9181ba2e1..79dd23709 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -222,6 +222,8 @@ staff.cat.copy_summary.yes=Yes staff.cat.copy_summary.no=No staff.cat.copy_summary.unset= staff.cat.copy_summary.not_cataloged=Not Cataloged +staff.cat.marcedit.authority_see_also=See also: %1$s +staff.cat.marcedit.authority_see_from=See from: %1$s staff.cat.marcedit.help.add_row=Add Row: CTRL+Enter staff.cat.marcedit.help.insert_row=Insert Row: CTRL+Shift+Enter staff.cat.marcedit.help.copy_row_up=Copy Current Row Above: CTRL+Up