[Commits] r2116 - in core/trunk/geoext: lib/GeoExt/data tests/lib/GeoExt/data
commits at geoext.org
commits at geoext.org
Mon Apr 26 16:40:05 CEST 2010
Author: elemoine
Date: 2010-04-26 16:40:05 +0200 (Mon, 26 Apr 2010)
New Revision: 2116
Modified:
core/trunk/geoext/lib/GeoExt/data/AttributeStore.js
core/trunk/geoext/tests/lib/GeoExt/data/AttributeStore.html
Log:
mixinify AttributeStore, r=pgiraud (closes #253)
Modified: core/trunk/geoext/lib/GeoExt/data/AttributeStore.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/data/AttributeStore.js 2010-04-26 11:11:36 UTC (rev 2115)
+++ core/trunk/geoext/lib/GeoExt/data/AttributeStore.js 2010-04-26 14:40:05 UTC (rev 2116)
@@ -17,6 +17,45 @@
*/
Ext.namespace("GeoExt.data");
+/**
+ * Function: GeoExt.data.AttributeStoreMixin
+ *
+ * This function generates a mixin object to be used when extending an Ext.data.Store
+ * to create an attribute store.
+ *
+ * (start code)
+ * var AttrStore = Ext.extend(Ext.data.Store, GeoExt.data.AttributeStoreMixin);
+ * var store = new AttrStore();
+ * (end)
+ *
+ * For convenience, a GeoExt.data.AttributeStore class is available as a
+ * shortcut to the Ext.extend sequence in the above code snippet. The above
+ * is equivalent to:
+ * (start code)
+ * var store = new GeoExt.data.AttributeStore();
+ * (end)
+ */
+GeoExt.data.AttributeStoreMixin = function() {
+ return {
+ /** private */
+ constructor: function(c) {
+ c = c || {};
+ arguments.callee.superclass.constructor.call(
+ this,
+ Ext.apply(c, {
+ proxy: c.proxy || (!c.data ?
+ new Ext.data.HttpProxy({url: c.url, disableCaching: false, method: "GET"}) :
+ undefined
+ ),
+ reader: new GeoExt.data.AttributeReader(
+ c, c.fields || ["name", "type", "restriction"]
+ )
+ })
+ );
+ }
+ };
+};
+
/** api: constructor
* .. class:: AttributeStore(config)
*
@@ -42,19 +81,7 @@
* ``Ext.data.Record.create``, or a record constructor created using
* ``Ext.data.Record.create``. Defaults to ``["name", "type", "restriction"]``.
*/
-GeoExt.data.AttributeStore = function(c) {
- c = c || {};
- GeoExt.data.AttributeStore.superclass.constructor.call(
- this,
- Ext.apply(c, {
- proxy: c.proxy || (!c.data ?
- new Ext.data.HttpProxy({url: c.url, disableCaching: false, method: "GET"}) :
- undefined
- ),
- reader: new GeoExt.data.AttributeReader(
- c, c.fields || ["name", "type", "restriction"]
- )
- })
- );
-};
-Ext.extend(GeoExt.data.AttributeStore, Ext.data.Store);
+GeoExt.data.AttributeStore = Ext.extend(
+ Ext.data.Store,
+ GeoExt.data.AttributeStoreMixin()
+);
Modified: core/trunk/geoext/tests/lib/GeoExt/data/AttributeStore.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/data/AttributeStore.html 2010-04-26 11:11:36 UTC (rev 2115)
+++ core/trunk/geoext/tests/lib/GeoExt/data/AttributeStore.html 2010-04-26 14:40:05 UTC (rev 2116)
@@ -24,6 +24,20 @@
"ctor sets an Ext.data.HttpProxy in the store");
}
+ function test_grouping(t) {
+ t.plan(2);
+
+ var AttributeGroupingStore = Ext.extend(
+ Ext.data.GroupingStore,
+ GeoExt.data.AttributeStoreMixin()
+ );
+ var store = new AttributeGroupingStore();
+ t.ok(store instanceof AttributeGroupingStore,
+ "ctor creates an AttributeGroupingStore");
+ t.ok(store instanceof Ext.data.GroupingStore,
+ "ctor creates an Ext.data.GroupingStore");
+ }
+
</script>
<body>
<div id="map"></div>
More information about the Commits
mailing list