[Commits] r2666 - sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets

commits at geoext.org commits at geoext.org
Wed May 11 15:41:22 CEST 2011


Author: adube
Date: 2011-05-11 15:41:22 +0200 (Wed, 11 May 2011)
New Revision: 2666

Modified:
   sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingManager.js
   sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingStatusBar.js
Log:
WFSTFeatureEditing - StatusBar added

Modified: sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingManager.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingManager.js	2011-05-11 12:45:03 UTC (rev 2665)
+++ sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingManager.js	2011-05-11 13:41:22 UTC (rev 2666)
@@ -4,6 +4,15 @@
 
 /* CONSTANT */
 
+    /** private: property[CUSTOM_EVENTS]
+     *  ``Array(String)`` Array of custom events used by this widget
+     */
+    CUSTOM_EVENTS: [
+        "commitstart",
+        "commitsuccess",
+        "commitfail"
+    ],
+
     DEFAULT_CAPABILITIES_PARAMS: {
         'SERVICE': "WFS",
         'REQUEST': "GetCapabilities",
@@ -53,7 +62,10 @@
 
     returnToSelectionText: "Return to selection",
 
+    commitSuccessText: "Changes successfully saved",
 
+    commitFailText: "An error occured.  The changes were not saved",
+
 /* API */
 
     toolbar: null,
@@ -108,6 +120,7 @@
         arguments.callee.superclass.constructor.call(this, config);
         this.queries = 0;
         this.layers = [];
+        this.addEvents(this.CUSTOM_EVENTS);
         this.initMainTools();
         this.url && this.createToolsFromURL(this.url);
     },
@@ -150,13 +163,17 @@
             "layout": "fit"
         });
 
-        this.mainPanel = new Ext.Panel({
+        var mainPanelOptions = {
             "border": false, 
             "layout": "border",
             "items": [this.featureGridContainer,
                       this.featureEditorGridContainer]
-        });
-
+        };
+        if (GeoExt.ux.WFSTFeatureEditingStatusBar) {
+            mainPanelOptions.tbar = new GeoExt.ux.WFSTFeatureEditingStatusBar({
+                "manager": this});
+        }
+        this.mainPanel = new Ext.Panel(mainPanelOptions);
         this.mainPanelContainer && this.mainPanelContainer.add(this.mainPanel);
     },
 
@@ -688,12 +705,13 @@
 
     commitFeature: function(feature) {
         if (feature.state != null) {
+            this.fireEvent('commitstart');
             feature.layer.wfstFeatureEditing.saveStrategy.save([feature]);
         }
     },
 
     onCommitSuccess: function(e) {
-        // todo : show success message
+        this.manager.fireEvent('commitsuccess', e);
         var wfstFE = this.layer.wfstFeatureEditing;
         wfstFE.wmsLayerSibling && wfstFE.wmsLayerSibling.redraw(true);
 
@@ -734,8 +752,7 @@
     },
 
     onCommitFail: function(e) {
-        // todo : show error message instead
-        alert("an error occured");
+        this.manager.fireEvent('commitfail', e);
     },
 
     toggleMainPanelContainer: function(display) {

Modified: sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingStatusBar.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingStatusBar.js	2011-05-11 12:45:03 UTC (rev 2665)
+++ sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingStatusBar.js	2011-05-11 13:41:22 UTC (rev 2666)
@@ -7,11 +7,80 @@
      */
     GeoExt.ux.WFSTFeatureEditingStatusBar = Ext.extend(Ext.ux.StatusBar, {
 
+        /* API */
+
+        /* begin i18n */
+        /** api: config[text] ``String`` i18n */
+        text: 'Ready',
+
+        /** api: config[busyText] ``String`` i18n */
+        busyText: 'Saving in progress.  Please wait...',
+
+        /** api: config[defaultText] ``String`` i18n */
+        defaultText: 'Ready',
+        /* end i18n */
+
+        /** api: config[iconCls]
+         *  ``String``  The default 'iconCls' value.
+         */
+        iconCls: 'x-status-valid',
+
+        /** api: config[defaultIconCls]
+         *  ``String``  The default 'defaultIconCls' value.
+         */
+        defaultIconCls: 'x-status-valid',
+
+        /* PRIVATE*/
+    
+        manager: null,
+
         /** private: method[constructor]
          */
         constructor: function(config) {
             Ext.apply(this, config);
             arguments.callee.superclass.constructor.call(this, config);
+            this.manager.on("commitstart", this.onCommitStart, this);
+            this.manager.on("commitsuccess", this.onCommitSuccess, this);
+            this.manager.on("commitfail", this.onCommitFail, this);
+        },
+
+        /** private: method[onCommitStart]
+         *  Called when a "commitstart" event is fired by the 
+         *      :class:`GeoExt.ux.WFSTFeatureEditingManager` widget.  Set the
+         *      status bar to "busy".
+         */
+        onCommitStart: function() {
+            this.showBusy();
+        },
+
+        /** private: method[onCommitSuccess]
+         *  :param response: ``Object`` The response from the request
+         *
+         *  Called when a "commitsuccess" event is fired by the 
+         *      :class:`GeoExt.ux.WFSTFeatureEditingManager` widget.  Shows the
+         *      according success message.
+         */
+        onCommitSuccess: function(response) {
+            this.setStatus({
+                text: this.manager.commitSuccessText,
+                iconCls: 'x-status-valid',
+                clear: true
+            });
+        },
+
+        /** private: method[onCommitFail]
+         *  :param response: ``Object`` The response from the request
+         *
+         *  Called when a "commitfail" event is fired by the 
+         *      :class:`GeoExt.ux.WFSTFeatureEditingManager` widget.  Shows the
+         *      according failure message.
+         */
+        onCommitFail: function(response) {
+            this.setStatus({
+                text: this.manager.commitFailText,
+                iconCls: 'x-status-error',
+                clear: true
+            });
         }
     });
 }



More information about the Commits mailing list