Ticket #57: 57.4.patch
| File 57.4.patch, 3.1 kB (added by tschaub, 1 year ago) |
|---|
-
tests/lib/GeoExt/data/LayerStore.html
old new 169 169 170 170 function test_add_remove(t) { 171 171 172 t.plan( 2);172 t.plan(6); 173 173 174 174 var map = new OpenLayers.Map("mappanel"); 175 175 var store = new GeoExt.data.LayerStore({ … … 184 184 185 185 store.remove(record); 186 186 t.eq(store.getCount(), 0, "removing a single record from the store removes one record"); 187 188 // add back the original and prepare to add copy 189 store.add([record]); 190 t.eq(store.getCount(), 1, "store has a single record before adding copy"); 191 t.eq(map.layers.length, 1, "map has a single layer before adding copy"); 187 192 193 // create a copy of the record with the same layer 194 var copy = record.copy(); // record with same id will replace original 195 copy.set("layer", record.get("layer")); // force records to have same layer 196 store.add(copy); 197 t.eq(store.getCount(), 1, "store has a single record after adding copy"); 198 t.eq(map.layers.length, 1, "map has a single layer after adding copy"); 199 188 200 } 189 201 190 202 function test_reorder(t) { -
lib/GeoExt/data/LayerStore.js
old new 151 151 "remove": this.onRemove, 152 152 scope: this 153 153 }); 154 this.data.on({ 155 "replace" : this.onReplace, 156 scope: this 157 }); 154 158 }, 155 159 156 160 /** … … 170 174 this.un("add", this.onAdd, this); 171 175 this.un("remove", this.onRemove, this); 172 176 177 this.data.un("replace", this.onReplace, this); 178 173 179 this.map = null; 174 180 } 175 181 }, … … 324 330 var layer = record.get("layer"); 325 331 if (this.map.getLayer(layer.id) != null) { 326 332 this._removing = true; 327 this. map.removeLayer(record.get("layer"));333 this.removeMapLayer(record); 328 334 delete this._removing; 329 335 } 330 336 } 337 }, 338 339 /** 340 * Method: removeMapLayers 341 * Removes a record's layer from the bound map. 342 * 343 * Parameters: 344 * record - {<Ext.data.Record>} 345 */ 346 removeMapLayer: function(record){ 347 this.map.removeLayer(record.get("layer")); 348 }, 349 350 /** 351 * Method: onReplace 352 * Handler for a store's data collections' replace event 353 * 354 * Parameters: 355 * key - {String} 356 * oldRecord - {Object} In this case, a record that has been replaced. 357 * newRecord - {Object} In this case, a record that is replacing oldRecord. 358 */ 359 onReplace: function(key, oldRecord, newRecord){ 360 this.removeMapLayer(oldRecord); 331 361 } 332 362 }; 333 363