Skip to content

Commit 70b2398

Browse files
author
Bart van den Eijnden
committed
allow a different paging start than 0, since CS-W starts at 1
1 parent 3f47d18 commit 70b2398

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

src/script/plugins/CSWCatalogueSource.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ gxp.plugins.CSWCatalogueSource = Ext.extend(gxp.plugins.CatalogueSource, {
5454
gxp.plugins.LayerSource.prototype.createStore.apply(this, arguments);
5555
},
5656

57+
/** api: method[getPagingStart]
58+
* :return: ``Integer`` Where does paging start at?
59+
*/
60+
getPagingStart: function() {
61+
return 1;
62+
},
63+
5764
/** api: method[getPagingParamNames]
5865
* :return: ``Object`` with keys start and limit.
5966
*

src/script/plugins/CatalogueSource.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ gxp.plugins.CatalogueSource = Ext.extend(gxp.plugins.WMSSource, {
9494
gxp.plugins.CatalogueSource.superclass.destroy.apply(this, arguments);
9595
}
9696

97+
/** api: method[getPagingStart]
98+
* :return: ``Integer`` Where does paging start at?
99+
*
100+
* To be implemented by subclasses
101+
*/
102+
97103
/** api: method[getPagingParamNames]
98104
* :return: ``Object`` with keys start and limit.
99105
*

src/script/plugins/GeoNodeCatalogueSource.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ gxp.plugins.GeoNodeCatalogueSource = Ext.extend(gxp.plugins.CatalogueSource, {
9090
gxp.plugins.LayerSource.prototype.createStore.apply(this, arguments);
9191
},
9292

93+
/** api: method[getPagingStart]
94+
* :return: ``Integer`` Where does paging start at?
95+
*/
96+
getPagingStart: function() {
97+
return 0;
98+
},
99+
93100
/** api: method[getPagingParamNames]
94101
* :return: ``Object`` with keys start and limit.
95102
*

src/script/widgets/CatalogueSearchPanel.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ gxp.CatalogueSearchPanel = Ext.extend(Ext.Panel, {
6969
* Initializes the catalogue search panel.
7070
*/
7171
initComponent: function() {
72+
var me = this;
7273
this.addEvents(
7374
/** api: event[addlayer]
7475
* Fires when a layer needs to be added to the map.
@@ -258,6 +259,34 @@ gxp.CatalogueSearchPanel = Ext.extend(Ext.Panel, {
258259
border: false,
259260
ref: "../grid",
260261
bbar: new Ext.PagingToolbar({
262+
listeners: {
263+
'beforechange': function(tb, params) {
264+
var delta = me.sources[me.selectedSource].getPagingStart();
265+
if (params.startPosition) {
266+
params.startPosition += delta;
267+
}
268+
}
269+
},
270+
/* override to support having a different value than 0 for the start */
271+
onLoad : function(store, r, o) {
272+
var delta = me.sources[me.selectedSource].getPagingStart();
273+
if(!this.rendered){
274+
this.dsLoaded = [store, r, o];
275+
return;
276+
}
277+
var p = this.getParams();
278+
this.cursor = (o.params && o.params[p.start]) ? o.params[p.start]-delta : 0;
279+
var d = this.getPageData(), ap = d.activePage, ps = d.pages;
280+
this.afterTextItem.setText(String.format(this.afterPageText, d.pages));
281+
this.inputItem.setValue(ap);
282+
this.first.setDisabled(ap == 1);
283+
this.prev.setDisabled(ap == 1);
284+
this.next.setDisabled(ap == ps);
285+
this.last.setDisabled(ap == ps);
286+
this.refresh.enable();
287+
this.updateInfo();
288+
this.fireEvent('change', this, d);
289+
},
261290
paramNames: this.sources[this.selectedSource].getPagingParamNames(),
262291
store: this.sources[this.selectedSource].store,
263292
pageSize: this.maxRecords

0 commit comments

Comments
 (0)