[Commits] r451 - in core/trunk/geoext: lib/GeoExt/data tests/lib/GeoExt/data
commits at geoext.org
commits at geoext.org
Thu Apr 23 13:28:52 CEST 2009
Author: elemoine
Date: 2009-04-23 13:28:51 +0200 (Thu, 23 Apr 2009)
New Revision: 451
Modified:
core/trunk/geoext/lib/GeoExt/data/LayerStore.js
core/trunk/geoext/tests/lib/GeoExt/data/LayerStore.html
Log:
LayerStore configured with "fields" instead of "recordType", r=ahocevar,bbinet, p=bbinet,me (closes #47)
Modified: core/trunk/geoext/lib/GeoExt/data/LayerStore.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/data/LayerStore.js 2009-04-23 07:32:50 UTC (rev 450)
+++ core/trunk/geoext/lib/GeoExt/data/LayerStore.js 2009-04-23 11:28:51 UTC (rev 451)
@@ -43,7 +43,7 @@
map: null,
/**
- * Property: reader
+ * APIProperty: reader
* {<GeoExt.data.LayerReader>} The reader used to get
* <GeoExt.data.LayerRecord> objects from {OpenLayers.Layer}
* objects.
@@ -60,10 +60,14 @@
* map - {OpenLayers.Map|<GeoExt.MapPanel>} map to sync the layer store
* with.
* layers - {Array(OpenLayers.Layer)} Layers that will be added to the
- * layer store (and the map, because we are already syncing).
- * recordType - {<GeoExt.data.LayerRecord>} If provided, a custom layer
- * record type with additional fields will be used. Default fields for
- * every layer record are {OpenLayers.Layer} layer and {String} title.
+ * store (and the map, depending on the value of the initDir option).
+ * fields - {Array} If provided a custom layer record type with additional
+ * fields will be used. Default fields for every layer record are
+ * {OpenLayers.Layer} layer and {String} title. The value of this
+ * option is either a field definition objects as passed to the
+ * GeoExt.data.LayerRecord.create function or a
+ * {<GeoExt.data.LayerRecord>} constructor created using
+ * GeoExt.data.LayerRecord.create.
* initDir - {Number} Bitfields specifying the direction to use for the
* initial sync between the map and the store, if set to 0 then no
* initial sync is done. Defaults to
@@ -72,7 +76,8 @@
constructor: function(config) {
config = config || {};
config.reader = config.reader ||
- new GeoExt.data.LayerReader({}, config.recordType);
+ new GeoExt.data.LayerReader({}, config.fields);
+ delete config.fields;
// "map" option
var map = config.map instanceof GeoExt.MapPanel ?
config.map.map : config.map;
Modified: core/trunk/geoext/tests/lib/GeoExt/data/LayerStore.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/data/LayerStore.html 2009-04-23 07:32:50 UTC (rev 450)
+++ core/trunk/geoext/tests/lib/GeoExt/data/LayerStore.html 2009-04-23 11:28:51 UTC (rev 451)
@@ -33,9 +33,9 @@
}
function test_constructor(t) {
- t.plan(3);
+ t.plan(5);
- var store, reader, map;
+ var store, reader, map, fields;
store = new GeoExt.data.LayerStore();
t.ok(store.reader instanceof GeoExt.data.LayerReader,
@@ -50,6 +50,16 @@
store = new GeoExt.data.LayerStore({map: map});
t.ok(store.map == map,
"ctor sets the passed map in the instance");
+
+ fields = [{name: "foo"}];
+ store = new GeoExt.data.LayerStore({fields: fields});
+ t.eq(store.reader.recordType.prototype.fields.items[2].name, "foo",
+ "ctor creates a reader from array of field definitions with expected field in recordType prototype");
+
+ fields = GeoExt.data.LayerRecord.create([{name: "foo"}]);
+ store = new GeoExt.data.LayerStore({fields: fields});
+ t.eq(store.reader.recordType.prototype.fields.items[2].name, "foo",
+ "ctor creates a reader from layer record constructor with expected field in recordType prototype");
}
function test_layerstore(t) {
More information about the Commits
mailing list