From 61174a10b8341250943d7451594a6bd966959422 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 16 Dec 2014 17:55:47 -0500 Subject: [PATCH] JBAS-216 clear cat date button Adds a button to MARC edit UI to clear the cat date value for a record. Signed-off-by: Bill Erickson --- Open-ILS/web/opac/locale/en-US/lang.dtd | 1 + Open-ILS/xul/staff_client/server/cat/marcedit.js | 35 ++++++++++++++++++++++- Open-ILS/xul/staff_client/server/cat/marcedit.xul | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index b24780efac..3a248df83c 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -3053,6 +3053,7 @@ + diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.js b/Open-ILS/xul/staff_client/server/cat/marcedit.js index a1cb691ca6..600fb9eb45 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.js +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.js @@ -2404,8 +2404,10 @@ function fillCatDate(authtoken, recId) { //If cataloging_date is already set use the incoming date, else use the current system time if(bib.cataloging_date() != null) { catDate = new Date(bib.cataloging_date()); + dojo.byId('clear-cat-date-button').disabled = false; } else { - catDate = new Date(); + catDate = new Date(); + dojo.byId('clear-cat-date-button').disabled = true; } // Show the current value of the bib source for this record @@ -2418,6 +2420,7 @@ function fillCatDate(authtoken, recId) { dojo.byId('cat-date-value').hidden = false; dojo.byId('cat-date-button').disabled = false; dojo.byId('cat-date-button').hidden = false; + dojo.byId('clear-cat-date-button').hidden = false; } @@ -2435,6 +2438,7 @@ function updateCatDate() { current_bib.ischanged = true; pcrud.update(current_bib); dojo.byId('cat-date-button').disabled = true; + dojo.byId('clear-cat-date-button').disabled = false; } } @@ -2460,6 +2464,35 @@ function onCatDateSelect(){ } } +// Fired when the "Clear date" button is clicked +// Sets the bib record catatalog_date to null. +function clearCatDate() { + + dojo.byId('clear-cat-date-button').disabled = true; + var pcrud = new openils.PermaCrud({authtoken : ses()}); + + if (!current_bib) { + current_bib = pcrud.retrieve('bre', xulG.record.id); + } + + // already clear.. nothing to do. We should never get here. + if (current_bib.cataloging_date() === null) return; + + current_bib.cataloging_date(null); + pcrud.update(current_bib); + + // set the UI back to the today + catDate = new Date(); + var catDateField = dojo.byId('cat-date-value'); + catDateField.date = catDate.getDate(); + catDateField.month = catDate.getMonth() + catDateField.year = catDate.getFullYear(); + + // re-enable the set-cat-date button + dojo.byId('cat-date-button').disabled = false; +} + + function addNewAuthorityID(authority, sf, target) { var id_sf = ({xulG.marc_control_number_identifier}){authority.id()}; sf.parent().appendChild(id_sf); diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.xul b/Open-ILS/xul/staff_client/server/cat/marcedit.xul index 8df82a0aa9..783e40a7c6 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.xul +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.xul @@ -46,6 +46,7 @@ &staff.cat.marcedit.catalogdate.caption;