[Commits] r2221 - in sandbox/camptocamp/extensions/geoext.ux/ux/FeatureBrowser: lib/GeoExt.ux tests/lib/GeoExt.ux
commits at geoext.org
commits at geoext.org
Tue Jun 1 16:57:02 CEST 2010
Author: elemoine
Date: 2010-06-01 16:57:02 +0200 (Tue, 01 Jun 2010)
New Revision: 2221
Modified:
sandbox/camptocamp/extensions/geoext.ux/ux/FeatureBrowser/lib/GeoExt.ux/FeatureBrowser.js
sandbox/camptocamp/extensions/geoext.ux/ux/FeatureBrowser/tests/lib/GeoExt.ux/FeatureBrowser.html
Log:
introduce a skippedFeatureAttributes option
Modified: sandbox/camptocamp/extensions/geoext.ux/ux/FeatureBrowser/lib/GeoExt.ux/FeatureBrowser.js
===================================================================
--- sandbox/camptocamp/extensions/geoext.ux/ux/FeatureBrowser/lib/GeoExt.ux/FeatureBrowser.js 2010-05-31 12:41:59 UTC (rev 2220)
+++ sandbox/camptocamp/extensions/geoext.ux/ux/FeatureBrowser/lib/GeoExt.ux/FeatureBrowser.js 2010-06-01 14:57:02 UTC (rev 2221)
@@ -54,6 +54,14 @@
* when provided as an Object. Mandatory is tpl is a Object. Optional.
*/
tplFeatureAttribute: null,
+
+ /** api: config[skippedFeatureAttributes]
+ * ``Array(String)``
+ * Specifies the feature attributes to skip in the default Ext.Template
+ * created by this component. Only applies when the ``tpl`` option is
+ * not set. Optional.
+ */
+ skippedFeatureAttributes: null,
/** api: config[features]
* ``Array`` Array of ``OpenLayers.Feature.Vector`` to build the
@@ -180,10 +188,15 @@
if (!tpl) {
var templateString = '';
for (var k in attributes) {
- templateString += '<div>' +
- '<b>' + k + ': </b>' +
- '{' + k + '}' +
- '</div>';
+ if (attributes.hasOwnProperty(k) &&
+ (this.skippedFeatureAttributes == null ||
+ this.skippedFeatureAttributes.indexOf(k) === -1)) {
+
+ templateString += '<div>' +
+ '<b>' + k + ': </b>' +
+ '{' + k + '}' +
+ '</div>';
+ }
}
tpl = new Ext.Template(templateString);
}
Modified: sandbox/camptocamp/extensions/geoext.ux/ux/FeatureBrowser/tests/lib/GeoExt.ux/FeatureBrowser.html
===================================================================
--- sandbox/camptocamp/extensions/geoext.ux/ux/FeatureBrowser/tests/lib/GeoExt.ux/FeatureBrowser.html 2010-05-31 12:41:59 UTC (rev 2220)
+++ sandbox/camptocamp/extensions/geoext.ux/ux/FeatureBrowser/tests/lib/GeoExt.ux/FeatureBrowser.html 2010-06-01 14:57:02 UTC (rev 2221)
@@ -11,11 +11,13 @@
var features = [
new OpenLayers.Feature.Vector(null, {
foo: "foo0",
- bar: "bar0"
+ bar: "bar0",
+ baz: "baz0"
}),
new OpenLayers.Feature.Vector(null, {
foo: "foo1",
- bar: "bar1"
+ bar: "bar1",
+ baz: "baz1"
})
];
@@ -62,8 +64,8 @@
browser.destroy();
}
- function test_getTemlate(t) {
- t.plan(6);
+ function test_getTemplate(t) {
+ t.plan(7);
var browser, tpl;
@@ -73,10 +75,21 @@
});
tpl = browser.getTemplateForFeature(features[0]);
t.eq(tpl.apply(features[0].attributes),
- '<div><b>foo: </b>foo0</div><div><b>bar: </b>bar0</div>',
+ '<div><b>foo: </b>foo0</div><div><b>bar: </b>bar0</div><div><b>baz: </b>baz0</div>',
"Template is correct when no template given"
);
+ // no template, with skippedFeatureAttributes
+ browser = new GeoExt.ux.FeatureBrowser({
+ features: features,
+ skippedFeatureAttributes: ["bar", "baz"]
+ });
+ tpl = browser.getTemplateForFeature(features[0]);
+ t.eq(tpl.apply(features[0].attributes),
+ '<div><b>foo: </b>foo0</div>',
+ "Template is correct when no template given and skippedFeatureAttributes provided"
+ );
+
// a unique template
browser = new GeoExt.ux.FeatureBrowser({
features: features,
@@ -105,7 +118,7 @@
);
tpl = browser.getTemplateForFeature(features[1]);
t.eq(tpl.apply(features[1].attributes),
- '<div><b>foo: </b>foo1</div><div><b>bar: </b>bar1</div>',
+ '<div><b>foo: </b>foo1</div><div><b>bar: </b>bar1</div><div><b>baz: </b>baz1</div>',
"Template is correct when tpl is a hash and feature doesn't match"
);
More information about the Commits
mailing list