ACQ upload form persist scratch
authorBill Erickson <berick@esilibrary.com>
Fri, 25 Jan 2013 20:50:48 +0000 (15:50 -0500)
committerBill Erickson <berick@esilibrary.com>
Fri, 25 Jan 2013 20:50:48 +0000 (15:50 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/acq/common/vlagent.js

index c92a135..a4db898 100644 (file)
@@ -1,5 +1,6 @@
 dojo.require('openils.widget.AutoFieldWidget');
 dojo.require('openils.PermaCrud');
+dojo.require('openils.XUL');
 
 function VLAgent(args) {
     args = args || {};
@@ -21,14 +22,18 @@ function VLAgent(args) {
         {key : 'fall_through_merge_profile', cls : 'vmp'},
         {key : 'existing_queue', cls : 'vbq'}
     ];
-    
+
     this.loaded = false;
+    var xulStorage = openils.XUL.localStorage();
+    var storekey = 'eg.acq.';
 
     this.init = function() {
         var self = this;
 
         dojo.forEach(this.widgets,
             function(widg) {
+
+                var cval = xulStorage.getItem(storekey + widg.key);
                 if (widg.cls) { // selectors
 
                     new openils.widget.AutoFieldWidget({
@@ -38,14 +43,16 @@ function VLAgent(args) {
                         parentNode : dojo.byId('acq_vl:' + widg.key),
                         searchFilter : (widg.cls == 'vbq') ? {queue_type : 'acq'} : null,
                         useWriteStore :  (widg.cls == 'vbq')
-                    }).build(function(dijit) { 
-                        widg.dijit = dijit; 
+                    }).build(function(dij) { 
+                        widg.dijit = dij; 
+                        if (cval) widg.dijit.attr('value', cval);
                         self.attachOnChange(widg);
                     }); 
 
                 } else { // bools
                     widg.dijit = dijit.byId('acq_vl:' + widg.key);
                     if (!widg.dijit) return; // some fields optional
+                    if (cval) widg.dijit.attr('value', cval);
                     self.attachOnChange(widg);
                 }
             }
@@ -134,8 +141,14 @@ function VLAgent(args) {
         var values = {};
         dojo.forEach(this.widgets,
             function(widg) {
-                if (widg.dijit)
+                if (widg.dijit) {
                     values[widg.key] = widg.dijit.attr('value');
+                    if (values[widg.key]) {
+                        xulStorage.setItem(storekey + widg.key, values[widg.key]);
+                    } else {
+                        xulStorage.removeItem(storekey + widg.key);
+                    }
+                }
             }
         );
         return values;