From 13acc6a9e4bcd174384039b635dd9d76a51b781e Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Tue, 21 Jun 2011 17:09:58 -0400 Subject: [PATCH] Further clean-up of Serials interfaces When trying to come up with good tests, found a few bugs (imagine!). Some have been nagging for a while now. 1) For 'MFHDDrawn' event, make sure it runs if deleting the last serials data of any kind for that record (to unpopulate the menus properly) 2) Make sure global mfhd member (g.mfhd) is cleared in the same case (i.e. deleting the last serials data for that record) 3) Add a string to better indicate when no MFHD records are available for 'Legacy Record Entry' drop-down 4) Convert submitted empty drop-down values to 'null' as needed in distribution editor 5) Mark subscription 'start date' as a required field 6) Make serial virtual records better handle deleted 'legacy record entries' attached to distributions, and also expose non-deleted record entries even if in 'use_sdist_only' summary mode Signed-off-by: Dan Wells Signed-off-by: Jason Etheridge --- .../lib/OpenILS/Application/Search/Serial.pm | 8 +++++-- Open-ILS/web/opac/skin/default/js/rdetail.js | 25 +++++++++++----------- .../xul/staff_client/chrome/content/cat/opac.js | 8 ++++--- .../server/locale/en-US/serial.properties | 1 + .../xul/staff_client/server/serial/sdist_editor.js | 13 +++++++++-- .../xul/staff_client/server/serial/ssub_editor.js | 3 ++- 6 files changed, 38 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Serial.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Serial.pm index 11c320266e..0617f5ec7a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Serial.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Serial.pm @@ -122,7 +122,7 @@ sub bib_to_svr { my $mfhd_parser = OpenILS::Utils::MFHDParser->new(); foreach (@$sdists) { my $svr; - if (ref $_->record_entry and $_->summary_method ne 'use_sdist_only') { + if ($_->summary_method ne 'use_sdist_only' and ref $_->record_entry and !$U->is_true($_->record_entry->deleted)) { my $skip_all_computable = 0; if ($_->summary_method eq 'merge_with_sre') { # 'computable' (85x/86x combos) are handled by generated_coverage when attempting to merge $skip_all_computable = 1; @@ -130,7 +130,11 @@ sub bib_to_svr { $svr = $mfhd_parser->generate_svr($_->record_entry->id, $_->record_entry->marc, $_->record_entry->owning_lib, $skip_all_computable); } else { $svr = Fieldmapper::serial::virtual_record->new; - $svr->sre_id(-1); + if (ref $_->record_entry and !$U->is_true($_->record_entry->deleted)) { + $svr->sre_id($_->record_entry->id); + } else { + $svr->sre_id(-1); + } $svr->location($_->holding_lib->name); $svr->owning_lib($_->holding_lib); $svr->basic_holdings([]); diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index 5b5004a927..eae2aa0bd2 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -352,19 +352,20 @@ function loadMarcEditor(recId) { */ function _holdingsDraw(h) { holdings = h.getResultObject(); - if (!holdings) { return null; } - - // Only draw holdings within our OU scope - var here = findOrgUnit(getLocation()); - var entryNum = 0; - dojo.forEach(holdings, function (item) { - if (orgIsMine(here, findOrgUnit(item.owning_lib()))) { - _holdingsDrawMFHD(item, entryNum); - entryNum++; - } - }); - // Populate XUL menus + if (holdings) { + // Only draw holdings within our OU scope + var here = findOrgUnit(getLocation()); + var entryNum = 0; + dojo.forEach(holdings, function (item) { + if (orgIsMine(here, findOrgUnit(item.owning_lib()))) { + _holdingsDrawMFHD(item, entryNum); + entryNum++; + } + }); + } + + // Populate (or unpopulate) XUL menus if (isXUL()) { runEvt('rdetail','MFHDDrawn'); } diff --git a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js index ceef976e5d..228f92b00b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js +++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js @@ -490,10 +490,12 @@ function set_opac() { item = mfhd_delete_menu.appendItem(label); item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')'); } - var change_event = document.createEvent("Event"); - change_event.initEvent("MFHDChange",false,false); - window.dispatchEvent(change_event); + } else if (g.mfhd) { // clear from previous runs if deleting last MFHD + delete g.mfhd; } + var change_event = document.createEvent("Event"); + change_event.initEvent("MFHDChange",false,false); + window.dispatchEvent(change_event); } ); }, diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/serial.properties b/Open-ILS/xul/staff_client/server/locale/en-US/serial.properties index dd51ce8bc4..30f348f56f 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/serial.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/serial.properties @@ -30,6 +30,7 @@ staff.serial.sdist_editor.add_to_sre.label=Add to record entry staff.serial.sdist_editor.merge_with_sre.label=Merge with record entry staff.serial.sdist_editor.use_sre_only.label=Use record entry only staff.serial.sdist_editor.use_sdist_only.label=Do not use record entry +staff.serial.sdist_editor.no_mfhd_available.label=No MFHD records for this Holding Lib staff.serial.siss_editor.count=1 issuance staff.serial.siss_editor.count.plural=%1$s issuances staff.serial.siss_editor.create.label=Create Issuance(s) diff --git a/Open-ILS/xul/staff_client/server/serial/sdist_editor.js b/Open-ILS/xul/staff_client/server/serial/sdist_editor.js index 74665d8f82..ab05ba2eaa 100644 --- a/Open-ILS/xul/staff_client/server/serial/sdist_editor.js +++ b/Open-ILS/xul/staff_client/server/serial/sdist_editor.js @@ -72,17 +72,26 @@ serial.sdist_editor.prototype = { 'apply' : function(field,value) { var obj = this; + var field_name_list = ['bind_call_number','receive_call_number','bind_unit_template','receive_unit_template','record_entry']; + // null out call number if the holding lib is changed obj.holding_lib_changed = (field == 'holding_lib'); var loop_func = function(sdist) { if (obj.holding_lib_changed) { - var field_name_list = ['bind_call_number','receive_call_number','bind_unit_template','receive_unit_template','record_entry']; for (var i = 0; i < field_name_list.length; i++) { sdist[field_name_list[i]](null); obj.changed[fieldmapper.IDL.fmclasses.sdist.field_map[field_name_list[i]].label] = true; } } } + + // check for blank drop-down submits + for (var i = 0; i < field_name_list.length; i++) { + if (field == field_name_list[i] && value === '') { + value = null; + break; + } + } obj.editor_base_apply(field, value, loop_func); obj.holding_lib_changed = false; }, @@ -320,7 +329,7 @@ serial.sdist_editor.prototype = { var lib_id = typeof obj.sdists[0].holding_lib() == 'object' ? obj.sdists[0].holding_lib().id() : obj.sdists[0].holding_lib(); var sre_details_list = obj.sres_ou_map[lib_id]; if (sre_details_list == null) { - return []; + return [{'label' : $('serialStrings').getString('staff.serial.sdist_editor.no_mfhd_available.label'), 'id' : ''}]; } else { return sre_details_list; } diff --git a/Open-ILS/xul/staff_client/server/serial/ssub_editor.js b/Open-ILS/xul/staff_client/server/serial/ssub_editor.js index 38b4fe3239..20a0597a81 100644 --- a/Open-ILS/xul/staff_client/server/serial/ssub_editor.js +++ b/Open-ILS/xul/staff_client/server/serial/ssub_editor.js @@ -126,7 +126,8 @@ serial.ssub_editor.prototype = { { render: 'fm.start_date() == null ? "" : util.date.formatted_date( fm.start_date(), "%F");', input: 'c = function(v){ obj.apply("start_date",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.start_date); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);', - value_key: 'start_date' + value_key: 'start_date', + required: true } ], [ -- 2.11.0