Ticket #40: records.patch
| File records.patch, 3.7 kB (added by sbenthall, 1 year ago) |
|---|
-
tests/lib/GeoExt/data/FeatureRecord.html
old new 10 10 <script type="text/javascript"> 11 11 12 12 function test_featurerecord(t) { 13 t.plan(1 4);13 t.plan(15); 14 14 15 15 var c, feature, record; 16 16 … … 36 36 "\"create(o)\" returns a func with a \"extra1\" field in its prototype"); 37 37 t.eq(c.prototype.fields.items[4].name, "extra2", 38 38 "\"create(o)\" returns a func with a \"extra2\" field in its prototype"); 39 t.eq(GeoExt.data.FeatureRecord.prototype.fields.items.length, 3, "create() method does not modify class prototype's fields"); 40 39 41 40 42 feature = new OpenLayers.Feature(); 41 43 record = new c({feature: feature, state: feature.state, fid: feature.fid}, feature.id); -
tests/lib/GeoExt/data/LayerRecord.html
old new 9 9 <script type="text/javascript"> 10 10 11 11 function test_layerrecord(t) { 12 t.plan(1 2);12 t.plan(13); 13 13 14 14 var c, layer, record; 15 15 … … 31 31 "\"create(o)\" returns a func with a \"extra1\" field in its prototype"); 32 32 t.eq(c.prototype.fields.items[3].name, "extra2", 33 33 "\"create(o)\" returns a func with a \"extra2\" field in its prototype"); 34 t.eq(GeoExt.data.LayerRecord.prototype.fields.items.length, 2, "create() method does not modify class prototype's fields"); 34 35 36 35 37 layer = new OpenLayers.Layer(); 36 38 record = new c({layer: layer, title: layer.name}, layer.id); 37 39 t.ok(record instanceof GeoExt.data.LayerRecord, "create returns a constructor (LayerRecord)"); -
lib/GeoExt/data/FeatureRecord.js
old new 55 55 GeoExt.data.FeatureRecord.create = function(o) { 56 56 var f = Ext.extend(GeoExt.data.FeatureRecord, {}); 57 57 var p = f.prototype; 58 if(o) { 58 59 var oldFields = p.fields; 60 p.fields = new Ext.util.MixedCollection(false, function(field){ 61 return field.name; 62 }); 63 64 oldFields.each(function(field){ 65 p.fields.add(field); 66 }); 67 68 if(o){ 59 69 for(var i = 0, len = o.length; i < len; i++){ 60 70 p.fields.add(new Ext.data.Field(o[i])); 61 71 } 62 72 } 73 74 f.getField = function(name){ 75 return p.fields.get(name); 76 }; 77 63 78 return f; 64 79 }; -
lib/GeoExt/data/LayerRecord.js
old new 63 63 GeoExt.data.LayerRecord.create = function(o) { 64 64 var f = Ext.extend(GeoExt.data.LayerRecord, {}); 65 65 var p = f.prototype; 66 if(o) { 66 67 var oldFields = p.fields; 68 p.fields = new Ext.util.MixedCollection(false, function(field){ 69 return field.name; 70 }); 71 72 oldFields.each(function(field){ 73 p.fields.add(field); 74 }); 75 76 if(o){ 67 77 for(var i = 0, len = o.length; i < len; i++){ 68 78 p.fields.add(new Ext.data.Field(o[i])); 69 79 } 70 80 } 81 82 f.getField = function(name){ 83 return p.fields.get(name); 84 }; 85 71 86 return f; 72 87 };