Skip to content

Commit

Permalink
Merge pull request #700 from geographika/wfs-params
Browse files Browse the repository at this point in the history
Extract WFS Store parameter creation to its own function
  • Loading branch information
geographika committed Aug 9, 2021
2 parents 765ce2b + a6c3516 commit 8d50bdb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 16 deletions.
45 changes: 29 additions & 16 deletions src/data/store/WfsFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,26 +376,13 @@ Ext.define('GeoExt.data.store.WfsFeatures', {
},

/**
* Loads the data from the connected WFS.
* @private
* Create a parameters object used to make a WFS feature request
* @return {Object} A object of WFS parameter keys and values
*/
loadWfs: function() {
var me = this;

if (me.loadWfsTask_.id === null) {
me.loadWfsTask_.delay(me.debounce, function() {});
me.loadWfsInternal();
} else {
me.loadWfsTask_.delay(me.debounce, function() {
me.loadWfsInternal();
});
}
},
createParameters: function() {

loadWfsInternal: function() {
var me = this;

var url = me.url;
var params = {
service: me.service,
version: me.version,
Expand Down Expand Up @@ -444,6 +431,32 @@ Ext.define('GeoExt.data.store.WfsFeatures', {
params.count = me.pageSize;
}

return params;
},

/**
* Loads the data from the connected WFS.
* @private
*/
loadWfs: function() {
var me = this;

if (me.loadWfsTask_.id === null) {
me.loadWfsTask_.delay(me.debounce, function() {});
me.loadWfsInternal();
} else {
me.loadWfsTask_.delay(me.debounce, function() {
me.loadWfsInternal();
});
}
},

loadWfsInternal: function() {
var me = this;

var url = me.url;
var params = me.createParameters();

// fire event 'gx-wfsstoreload-beforeload' and skip loading if listener
// function returns false
if (me.fireEvent('gx-wfsstoreload-beforeload', me, params) === false) {
Expand Down
19 changes: 19 additions & 0 deletions test/spec/GeoExt/data/store/WfsFeatures.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ describe('GeoExt.data.store.WfsFeatures', function() {
}
});
});

it('WFS parameters are created correctly', function() {

var store = Ext.create('GeoExt.data.store.WfsFeatures', {
url: url,
count: 25,
srsName: 'EPSG:3857',
propertyName: 'FID'
});

var params = store.createParameters();

expect(params.startIndex).to.be(0);
expect(params.count).to.be(25);
expect(params.propertyName).to.be('FID');
expect(params.srsName).to.be('EPSG:3857');
expect(params.filter).to.be(undefined);
expect(params.sortBy).to.be(undefined);
});
});

describe('loading with paging', function() {
Expand Down

0 comments on commit 8d50bdb

Please sign in to comment.