JBAS-216 clear cat date button
authorBill Erickson <berickxx@gmail.com>
Tue, 16 Dec 2014 22:55:47 +0000 (17:55 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Adds a button to MARC edit UI to clear the cat date value for a
record.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/server/cat/marcedit.js
Open-ILS/xul/staff_client/server/cat/marcedit.xul

index b24780e..3a248df 100644 (file)
 <!ENTITY staff.cat.marcedit.phys_char_wizard.accesskey "W">
 <!ENTITY staff.cat.marcedit.catalogdate.caption "Cataloging Date:">
 <!ENTITY staff.cat.marcedit.catalogdate.submit.label "Update date">
+<!ENTITY staff.cat.marcedit.catalogdate.clear.label "Clear date">
 <!ENTITY staff.cat.marcedit.catalogdate.submit.accesskey "U">
 <!ENTITY staff.cat.marc_new.load.label "Load">
 <!ENTITY staff.cat.marc_new.load.accesskey "L">
index a1cb691..600fb9e 100644 (file)
@@ -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 = <subfield code="0" xmlns="http://www.loc.gov/MARC21/slim">({xulG.marc_control_number_identifier}){authority.id()}</subfield>;
     sf.parent().appendChild(id_sf);
index 8df82a0..783e40a 100644 (file)
@@ -46,6 +46,7 @@
                 <caption id="cat-date-caption" hidden="true" align="center">&staff.cat.marcedit.catalogdate.caption;</caption>
                 <datepicker id="cat-date-value" hidden="true" type="popup" onselect='onCatDateSelect();' oncommand='onCatDateSelect();' onchange='onCatDateSelect();' onblur='onCatDateSelect();'/>
                 <button id="cat-date-button" label="&staff.cat.marcedit.catalogdate.submit.label;" accesskey="&staff.cat.marcedit.catalogdate.submit.accesskey;" disabled="true" oncommand="updateCatDate();" hidden="true"/>
+                <button id="clear-cat-date-button" label="&staff.cat.marcedit.catalogdate.clear.label;" accesskey="&staff.cat.marcedit.catalogdate.clear.accesskey;" oncommand="clearCatDate();" hidden="true"/>
     </hbox>
     <hbox id="fastItemAdd_textboxes">
         <label control="fastItemAdd_callnumber" accesskey="&staff.cat.marcedit.fastItemAdd_callnumber.accesskey;" value="&staff.cat.marcedit.fastItemAdd_callnumber.label;" />