[fusion-commits] r2246 - sandbox/jxlib-3.0/lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Oct 13 11:24:06 EDT 2010


Author: pagameba
Date: 2010-10-13 08:24:06 -0700 (Wed, 13 Oct 2010)
New Revision: 2246

Modified:
   sandbox/jxlib-3.0/lib/jxlib.uncompressed.js
Log:
updating jxlib build with some grid updates

Modified: sandbox/jxlib-3.0/lib/jxlib.uncompressed.js
===================================================================
--- sandbox/jxlib-3.0/lib/jxlib.uncompressed.js	2010-10-07 20:06:07 UTC (rev 2245)
+++ sandbox/jxlib-3.0/lib/jxlib.uncompressed.js	2010-10-13 15:24:06 UTC (rev 2246)
@@ -18345,6 +18345,12 @@
      * Used to determine if the store is completely initialized.
      */
     ready: false,
+    
+    /**
+     * Property: deleted
+     * track deleted records before they are purged
+     */
+    deleted: null,
 
     /**
      * Method: init
@@ -18353,6 +18359,8 @@
     init: function () {
         this.parent();
 
+        this.deleted = [];
+        
         if ($defined(this.options.id)) {
             this.id = this.options.id;
         }
@@ -18813,9 +18821,11 @@
         // Set to Null or slice it out and compact the array???
         //this.data[index] = null;
         this.data.splice(index,1);
-        if (!$defined(this.deleted)) {
-            this.deleted = [];
-        }
+        // TODO: I moved this to a property that is always an array so I don't
+        // get an error in the save strategy.
+        // if (!$defined(this.deleted)) {
+        //     this.deleted = [];
+        // }
         this.deleted.push(record);
         this.fireEvent('storeRecordDeleted', [this, record]);
     },
@@ -19854,7 +19864,13 @@
 
     parser: null,
 
-    options: {},
+    options: {
+      combine: {
+        insert: false,
+        update: false,
+        'delete': false
+      }
+    },
 
     init: function () {
         this.parent();
@@ -19914,7 +19930,19 @@
      * used to abort any of the above methods (where practical). Abstract method
      * that subclasses should implement.
      */
-    abort: $empty
+    abort: $empty,
+    /**
+     * APIMethod: combineRequests
+     * tests whether the protocol supports combining multiple records for a given operation
+     * 
+     * Parameter:
+     * operation - {String} the operation to test for multiple record support
+     * 
+     * Returns {Boolean} true if the operation supports it, false otherwise
+     */
+    combineRequests: function(op) {
+      return $defined(this.options.combine[op]) ? this.options.combine[op] : false;
+    }
 });/*
 ---
 
@@ -20082,10 +20110,29 @@
             read: null,
             update: null,
             'delete': null
+        },
+        /**
+         * Option: queue
+         * an object containing options suitable for <Request.Queue>.
+         * By default, autoAdvance is set to true and concurrent is set to 1.
+         */
+        queue: {
+          autoAdvance: true,
+          concurrent: 1
         }
     },
+    
+    queue: null,
 
     init: function() {
+        if (!$defined(Jx.Store.Protocol.Ajax.UniqueId)) {
+          Jx.Store.Protocol.Ajax.UniqueId = 1;
+        }
+      
+        this.queue = new Request.Queue({
+          autoAdvance: this.options.queue.autoAdvance,
+          concurrent: this.options.queue.concurrent
+        });
         this.parent();
     },
     /**
@@ -20099,7 +20146,8 @@
         var resp = new Jx.Store.Response(),
             temp = {},
             opts,
-            req;
+            req,
+            uniqueId = Jx.Store.Protocol.Ajax.UniqueId();
         resp.requestType = 'read';
         resp.requestParams = arguments;
 
@@ -20116,6 +20164,8 @@
 
         req = new Request(opts);
         resp.request = req;
+        
+        this.queue.addRequest(uniqueId, req);
         req.send();
 
         resp.code = Jx.Store.Response.WAITING;
@@ -20230,10 +20280,27 @@
     run: function (record, options, method) {
         var resp = new Jx.Store.Response(),
             opts,
-            req;
+            req,
+            data,
+            uniqueId = Jx.Store.Protocol.Ajax.UniqueId();
         
+        if (Jx.type(record) == 'array') {
+          if (!this.combineRequests(method)) {
+            record.each(function(r) {
+              this.run(r, options, method);
+            }, this);
+          } else {
+            data = [];
+            record.each(function(r) {
+              data.push(this.parser.encode(r));
+            }, this);
+          }
+        } else {
+          data = this.parser.encode(record);
+        }
+
         this.options.requestOptions.data = $merge(this.options.requestOptions.data, {
-          data: this.parser.encode(record)
+          data: data
         });
 
         resp.requestType = method;
@@ -20242,17 +20309,28 @@
         //set up options
         opts = $merge(this.options.requestOptions, options);
         opts.onSuccess = this.handleResponse.bind(this,resp);
-
         req = new Request(opts);
         resp.request = req;
+        this.queue.addRequest(uniqueId, req);
         req.send();
 
         resp.code = Jx.Store.Response.WAITING;
 
         return resp;
-    }
-
-});/*
+    },
+    
+});
+/**
+ * Method: uniqueId
+ * returns a unique identifier to be used with queued requests
+ */
+Jx.Store.Protocol.Ajax.UniqueId = (function() {
+  var uniqueId = 1;
+  return function() {
+    return 'req-'+(uniqueId++);
+  };
+})();
+/*
 ---
 
 name: Jx.Store.Strategy
@@ -21075,20 +21153,22 @@
         //determine the status and route based on that
         if (!this.updating && $defined(record.state)) {
             if (this.totalChanges === 0) {
-                this.store.protocol.addEvent('dataLoaded', this.bound.completed);
+                store.protocol.addEvent('dataLoaded', this.bound.completed);
             }
             this.totalChanges++;
             var ret;
             switch (record.state) {
                 case Jx.Record.UPDATE:
-                    ret = this.store.protocol.update(record);
+                    ret = store.protocol.update(record);
                     break;
                 case Jx.Record.DELETE:
-                    ret = this.store.protocol['delete'](record);
+                    ret = store.protocol['delete'](record);
                     break;
                 case Jx.Record.INSERT:
-                    ret = this.store.protocol.insert(record);
+                    ret = store.protocol.insert(record);
                     break;
+                default:
+                  break;
             }
             return ret;
         }
@@ -21113,9 +21193,27 @@
             }, this);
             records[Jx.Record.DELETE] = this.store.deleted;
             
-            records.flatten().each(function (record) {
-                this.saveRecord(null, record);
-            }, this);
+            if (!this.updating) {
+              if (this.totalChanges === 0) {
+                  store.protocol.addEvent('dataLoaded', this.bound.completed);
+              }
+              this.totalChanges += records[Jx.Record.UPDATE].length + 
+                                   records[Jx.Record.INSERT].length +
+                                   records[Jx.Record.DELETE].length;
+              if (records[Jx.Record.UPDATE].length) {
+                this.store.protocol.update(records[Jx.Record.UPDATE]);
+              }
+              if (records[Jx.Record.INSERT].length) {
+                this.store.protocol.insert(records[Jx.Record.INSERT]);
+              }
+              if (records[Jx.Record.DELETE].length) {
+                this.store.protocol['delete'](records[Jx.Record.DELETE]);
+              }
+            }
+            
+            // records.flatten().each(function (record) {
+            //     this.saveRecord(this.store, record);
+            // }, this);
         }
         
     },
@@ -21140,28 +21238,33 @@
             this.failedChanges.push(response);
         } else {
             //process the response
-            var record = response.requestParams[0];
-            if (response.requestType === 'delete') {
-                this.store.deleted.erase(record);
-            } else { 
-                if (response.requestType === 'insert' || response.requestType == 'update') {
-                    if ($defined(response.data)) {
-                        this.updating = true;
-                        $H(response.data).each(function (val, key) {
-                            var d = record.set(key, val);
-                            if (d[1] != val && $defined(response.index)) {
-                              d.unshift(response.index);
-                              record.store.fireEvent('storeColumnChanged', d);
-                            }
-                        });
-                        this.updating = false;
-                    }
-                }
-                record.state = null;
-            } 
-            this.successfulChanges.push(response);
+            var records = [response.requestParams[0]].flatten(),
+                responseData = $defined(response.data) ? [response.data].flatten() : null;
+            records.each(function(record, index) {
+              if (response.requestType === 'delete') {
+                  this.store.deleted.erase(record);
+              } else { 
+                  if (response.requestType === 'insert' || response.requestType == 'update') {
+                      if (responseData && $defined(responseData[index])) {
+                          this.updating = true;
+                          $H(responseData[index]).each(function (val, key) {
+                              var d = record.set(key, val);
+                              if (d[1] != val) {
+                                if ($defined(response.index)) {
+                                  d.unshift(response.index);
+                                }
+                                record.store.fireEvent('storeColumnChanged', d);
+                              }
+                          });
+                          this.updating = false;
+                      }
+                  }
+                  record.state = null;
+              } 
+              this.totalChanges--;
+          }, this);
+          this.successfulChanges.push(response);
         }
-        this.totalChanges--;
         if (this.totalChanges === 0) {
             this.store.protocol.removeEvent('dataLoaded', this.bound.completed);
             this.store.fireEvent('storeChangesCompleted', {
@@ -32403,7 +32506,7 @@
 Jx.Grid = new Class({
   Family : 'Jx.Grid',
   Extends: Jx.Widget,
-  Binds: ['storeLoaded', 'clickColumnHeader', 'moveColumnHeader', 'clickRowHeader', 'moveRowHeader', 'clickCell', 'dblclickCell', 'moveCell', 'leaveGrid', 'resize', 'drawStore', 'scroll', 'addRow', 'removeRow', 'removeRows', 'updateRow'],
+  Binds: ['storeLoaded', 'clickColumnHeader', 'moveColumnHeader', 'clickRowHeader', 'moveRowHeader', 'clickCell', 'dblclickCell', 'moveCell', 'leaveGrid', 'resize', 'drawStore', 'scroll', 'addRow', 'removeRow', 'removeRows', 'updateRow', 'storeChangesCompleted'],
 
   /**
    * Property: pluginNamespace
@@ -32550,7 +32653,8 @@
       'storeRecordAdded': this.addRow,
       'storeColumnChanged': this.updateRow,
       'storeRecordRemoved': this.removeRow,
-      'storeMultipleRecordsRemoved': this.removeRows
+      'storeMultipleRecordsRemoved': this.removeRows,
+      'storeChangesCompleted': this.storeChangesCompleted
     };
     
     
@@ -32767,6 +32871,14 @@
     this.redraw();
   },
   
+  /**
+   */
+  storeChangesCompleted: function(results) {
+    if (results && results.successful) {
+      
+    }
+  },
+  
   redraw: function() {
     var store = this.store,
         template = '',
@@ -33581,7 +33693,7 @@
 
 ...
  */
-// $Id: grid.selector.js 991 2010-10-07 19:25:23Z pagameba $
+// $Id: grid.selector.js 994 2010-10-07 20:07:31Z pagameba $
 /**
  * Class: Jx.Plugin.Grid.Selector
  *
@@ -33771,6 +33883,7 @@
           tr = document.id((index >= 0 && index < r.length) ? r[index] : null);
       
       if (tr) {
+        tr.store('jxRowData', {row: index});
         if (state) {
           tr.addClass('jxGridRowSelected');
         } else {



More information about the fusion-commits mailing list