LP#1320048: correctly display closures in the closed dates editor
authorGalen Charlton <gmc@esilibrary.com>
Fri, 16 May 2014 17:03:45 +0000 (10:03 -0700)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 19 May 2014 12:55:17 +0000 (08:55 -0400)
This patch fixes a problem introduced by the patch for bug 1187035
that caused the closed dates editor to display all closures as if
they started and ended at the current time.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/xul/staff_client/server/admin/closed_dates.js
Open-ILS/xul/staff_client/server/admin/closed_dates.xhtml

index d784ff6..45a9a6a 100644 (file)
@@ -1,3 +1,4 @@
+var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
 var FETCH_CLOSED_DATES    = 'open-ils.actor:open-ils.actor.org_unit.closed.retrieve.all';
 var FETCH_CLOSED_DATE    = 'open-ils.actor:open-ils.actor.org_unit.closed.retrieve';
 var CREATE_CLOSED_DATE    = 'open-ils.actor:open-ils.actor.org_unit.closed.create';
@@ -23,6 +24,19 @@ var myPerms = [
 
 function cdEditorInit() {
 
+    try {
+        if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+        JSAN.errorLevel = "die"; // none, warn, or die
+        JSAN.addRepository('..');
+        JSAN.use('util.error'); g.error = new util.error();
+        JSAN.use('util.date');
+    } catch(E) {
+        var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
+            "system administrator or software developer the following:\nadmin/closed_dates.xhtml\n" + E + '\n';
+        try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+        alert(err_msg);
+    }
+
     /* set the various template rows */
     cdTbody = $('cd_tbody');
     cdRowTemplate                    = cdTbody.removeChild($('cd_row'));
@@ -162,32 +176,11 @@ function cdBuild(r) {
 }
 
 function cdDateToHours(date) {
-    var d = new Date.W3CDTF();
-    d.setW3CDTF(date.replace(/\.\d+/,'') + ":00");
-
-    var h = d.getHours() +'';
-    var m = d.getMinutes() +'';
-    var s = d.getSeconds() +'';
-
-    if(h.length == 1) h = '0'+h;
-    if(m.length == 1) m = '0'+m;
-    if(s.length == 1) s = '0'+s;
-
-    return  h + ':' + m + ':' + s;
+    return util.date.formatted_date(date, '%H:%M');
 }
 
 function cdDateToDate(date) {
-    var d = new Date.W3CDTF();
-    d.setW3CDTF(date.replace(/\.\d+/,'') + ":00");
-
-    var y = d.getFullYear()+'';
-    var m = (d.getMonth() + 1)+'';
-    var d = d.getDate()+'';
-
-    if(m.length == 1) m = '0'+m;
-    if(d.length == 1) d = '0'+d;
-
-    return  y + '-' + m + '-' + d;
+    return util.date.formatted_date(date, '%F');
 }
 
 
@@ -272,8 +265,6 @@ function cdDelete(row, date) {
 }
 
 
-/* getW3CDTF */
-
 function cdVerifyDate(d) {
     return d && d.match(/\d{4}-\d{2}-\d{2}/);
 }
index c831f7d..12032c3 100644 (file)
@@ -22,6 +22,7 @@
         <script type='text/javascript' src='/opac/common/js/init.js'> </script>
         <script type='text/javascript' src='/opac/common/js/RemoteRequest.js'> </script>
         <script type='text/javascript' src='/opac/common/js/Date.W3CDTF.js'> </script>
+        <script type="text/javascript" src="/xul/server/main/JSAN.js"></script>
         <script type='text/javascript' src='adminlib.js'> </script>
         <script type='text/javascript' src='closed_dates.js'> </script>