[Commits] r1523 - in sandbox/camptocamp/geobretagne: lib/GeoExt/widgets tests/lib/GeoExt/widgets
commits at geoext.org
commits at geoext.org
Mon Nov 30 11:49:08 CET 2009
Author: bbinet
Date: 2009-11-30 11:49:07 +0100 (Mon, 30 Nov 2009)
New Revision: 1523
Modified:
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendPanel.js
sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LegendPanel.html
Log:
applying patch-178_r1484_A1.diff from #178
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendPanel.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendPanel.js 2009-11-30 06:51:55 UTC (rev 1522)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendPanel.js 2009-11-30 10:49:07 UTC (rev 1523)
@@ -85,6 +85,7 @@
this.layerStore.on({
"add": this.onStoreAdd,
"remove": this.onStoreRemove,
+ "clear": this.onStoreClear,
"update": this.onStoreUpdate,
scope: this
});
@@ -194,6 +195,23 @@
}
},
+ /** private: method[onStoreClear]
+ * Private method called when a layer store is cleared.
+ *
+ * :param store: ``Ext.data.Store`` The store from which was cleared.
+ */
+ onStoreClear: function(store) {
+ this.removeAllLegends();
+ },
+
+ /** private: method[removeAllLegends]
+ * Remove all legends from this legend panel.
+ */
+ removeAllLegends: function() {
+ this.removeAll(true);
+ this.doLayout();
+ },
+
/** private: method[createLegendSubpanel]
* Create a legend sub panel for the layer.
*
@@ -287,11 +305,11 @@
if(this.layerStore) {
this.layerStore.un("add", this.onStoreAdd, this);
this.layerStore.un("remove", this.onStoreRemove, this);
+ this.layerStore.un("clear", this.onStoreClear, this);
this.layerStore.un("update", this.onStoreUpdate, this);
}
GeoExt.LegendPanel.superclass.onDestroy.apply(this, arguments);
}
-
});
/** api: xtype = gx_legendpanel */
Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LegendPanel.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LegendPanel.html 2009-11-30 06:51:55 UTC (rev 1522)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LegendPanel.html 2009-11-30 10:49:07 UTC (rev 1523)
@@ -157,6 +157,21 @@
mapPanel.destroy();
}
+ function test_clear(t) {
+ t.plan(2);
+ var mapPanel = loadMapPanel();
+ var lp = new GeoExt.LegendPanel({
+ renderTo: 'legendpanel'});
+ lp.render();
+ t.eq(lp.items.length, 1, "Same number of layers in legend panel and in layerstore");
+
+ mapPanel.layers.removeAll();
+ t.eq(lp.items.length, 0, "When layerstore is cleared, legend panel is cleared");
+
+ lp.destroy();
+ mapPanel.destroy();
+ }
+
function test_changelayername(t) {
t.plan(3);
var mapPanel = loadMapPanel();
More information about the Commits
mailing list