[Commits] r1910 - in core/trunk/geoext: lib/GeoExt/widgets tests/lib/GeoExt/widgets

commits at geoext.org commits at geoext.org
Tue Feb 23 09:25:40 CET 2010


Author: bartvde
Date: 2010-02-23 09:25:39 +0100 (Tue, 23 Feb 2010)
New Revision: 1910

Modified:
   core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js
   core/trunk/geoext/tests/lib/GeoExt/widgets/WMSLegend.html
Log:
WMSLegend does not split layer names using comma for array items, r=ahocevar (closes #226)

Modified: core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js	2010-02-22 16:21:02 UTC (rev 1909)
+++ core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js	2010-02-23 08:25:39 UTC (rev 1910)
@@ -69,13 +69,10 @@
         var url;
         var styles = rec && rec.get("styles");
         var layer = rec.get("layer");
-        layerNames = layerNames ||
-                             (layer.params.LAYERS instanceof Array) ?
-                             layer.params.LAYERS :
-                             layer.params.LAYERS.split(",");
+        layerNames = layerNames || [layer.params.LAYERS].join(",").split(",");
 
         var styleNames = layer.params.STYLES &&
-                             layer.params.STYLES.split(",");
+                             [layer.params.STYLES].join(",").split(",");
         var idx = layerNames.indexOf(layerName);
         var styleName = styleNames && styleNames[idx];
         // check if we have a legend URL in the record's
@@ -116,9 +113,7 @@
         var layerNames, layerName, i, len;
         
         var layer = this.layerRecord.get("layer");
-        layerNames = (layer.params.LAYERS instanceof Array) ? 
-            layer.params.LAYERS :
-            layer.params.LAYERS.split(",");
+        layerNames = [layer.params.LAYERS].join(",").split(",");
 
         var destroyList = [];
         var textCmp = this.items.get(0);

Modified: core/trunk/geoext/tests/lib/GeoExt/widgets/WMSLegend.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/widgets/WMSLegend.html	2010-02-22 16:21:02 UTC (rev 1909)
+++ core/trunk/geoext/tests/lib/GeoExt/widgets/WMSLegend.html	2010-02-23 08:25:39 UTC (rev 1910)
@@ -27,6 +27,38 @@
             return mapPanel;
         }
 
+        function test_legendurl_layers_array(t) {
+            t.plan(4);
+            var l, url, expectedUrl;
+            var mapPanel = loadMapPanel();
+            var layer1 = new OpenLayers.Layer.WMS("test", '/ows', {layers: ['a,b', 'c,d']});
+            var layer2 = new OpenLayers.Layer.WMS("test", '/ows', {layers: ['x', 'y']});
+            mapPanel.map.addLayers([layer1, layer2]);
+            l = new GeoExt.WMSLegend({
+                renderTo: 'legendwms',
+                layerRecord: mapPanel.layers.getAt(1)
+            });
+            l.render();
+
+            t.eq(l.items.length, 5, "We expect 5 items");
+            url = l.items.get(1).url;
+            expectedUrl = "/ows?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&EXCEPTIONS=application%2Fvnd.ogc.se_xml&FORMAT=image%2Fgif&LAYER=a";
+            t.eq(url, expectedUrl, "GetLegendGraphic url is generated correctly");
+            l.destroy();
+
+            l = new GeoExt.WMSLegend({
+                renderTo: 'legendwms',
+                layerRecord: mapPanel.layers.getAt(2)
+            });
+            l.render();
+
+            t.eq(l.items.length, 3, "We expect 3 items");
+            url = l.items.get(1).url;
+            expectedUrl = "/ows?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&EXCEPTIONS=application%2Fvnd.ogc.se_xml&FORMAT=image%2Fgif&LAYER=x";
+            t.eq(url, expectedUrl, "GetLegendGraphic url is generated correctly");
+            l.destroy();
+        }
+
         function test_legendurl(t) {
             t.plan(5);
 



More information about the Commits mailing list