fix(pagination): duplicated rows on paginate #1214
|
@ -14,6 +14,7 @@ export default class CrudModel extends ModelProxy {
|
|||
this.$q = $q;
|
||||
this.primaryKey = 'id';
|
||||
this.autoLoad = false;
|
||||
this.page = 1;
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
|
@ -125,13 +126,20 @@ export default class CrudModel extends ModelProxy {
|
|||
}
|
||||
}
|
||||
|
||||
loadMore() {
|
||||
loadMore(append) {
|
||||
if (!this.moreRows)
|
||||
return this.$q.resolve();
|
||||
|
||||
let filter = Object.assign({}, this.currentFilter);
|
||||
const filter = Object.assign({}, this.currentFilter);
|
||||
if (append)
|
||||
filter.skip = this.orgData ? this.orgData.length : 0;
|
||||
return this.sendRequest(filter, true);
|
||||
|
||||
if (!append) {
|
||||
this.page += 1;
|
||||
filter.limit = this.page * this.limit;
|
||||
}
|
||||
|
||||
return this.sendRequest(filter, append);
|
||||
}
|
||||
|
||||
clear() {
|
||||
|
|
|
@ -148,7 +148,7 @@ describe('Component vnCrudModel', () => {
|
|||
|
||||
controller.moreRows = true;
|
||||
|
||||
controller.loadMore();
|
||||
controller.loadMore(true);
|
||||
|
||||
expect(controller.sendRequest).toHaveBeenCalledWith({'skip': 2}, true);
|
||||
});
|
||||
|
|
|
@ -212,12 +212,12 @@ export default class DropDown extends Popover {
|
|||
&& !this.model.isLoading;
|
||||
|
||||
if (shouldLoad)
|
||||
this.model.loadMore();
|
||||
this.model.loadMore(true);
|
||||
}
|
||||
|
||||
onLoadMoreClick(event) {
|
||||
if (event.defaultPrevented) return;
|
||||
this.model.loadMore();
|
||||
this.model.loadMore(true);
|
||||
}
|
||||
|
||||
onContainerClick(event) {
|
||||
|
|
|
@ -374,9 +374,10 @@ export class Paginable {
|
|||
/**
|
||||
* When limit is enabled, loads the next set of rows.
|
||||
*
|
||||
* @param {Boolean} append - Whether should append new data
|
||||
* @return {Promise} The request promise
|
||||
*/
|
||||
loadMore() {
|
||||
return Promise.resolve();
|
||||
loadMore(append) {
|
||||
return Promise.resolve(append);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class Pagination extends Component {
|
|||
|
||||
if (shouldLoad) {
|
||||
this.nLoads++;
|
||||
this.model.loadMore();
|
||||
this.model.loadMore(false);
|
||||
this.$.$apply();
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class Pagination extends Component {
|
|||
if (this.maxLoads > 0 && this.nLoads == this.maxLoads)
|
||||
this.nLoads = 0;
|
||||
|
||||
this.model.loadMore();
|
||||
this.model.loadMore(false);
|
||||
}
|
||||
|
||||
$onDestroy() {
|
||||
|
|
|
@ -38,6 +38,7 @@ module.exports = Self => {
|
|||
date.setHours(0, 0, 0, 0);
|
||||
const stmt = new ParameterizedSQL(`
|
||||
SELECT
|
||||
v.id,
|
||||
u.name AS salesPerson,
|
||||
IFNULL(sc.workerSubstitute, c.salesPersonFk) AS salesPersonFk,
|
||||
c.id AS clientFk,
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="visit in model.data">
|
||||
<tr ng-repeat="visit in model.data track by visit.id">
|
||||
<td shrink-date>
|
||||
<span class="chip">
|
||||
{{::visit.dated | date:'dd/MM/yy'}}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<vn-th field="salesPersonFk" shrink>SalesPerson</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<a ng-repeat="order in model.data"
|
||||
<a ng-repeat="order in model.data track by order.id"
|
||||
class="clickable vn-tbody"
|
||||
ui-sref="order.card.summary({id: {{::order.id}}})" target="_blank">
|
||||
<vn-tr>
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="ticket in model.data"
|
||||
<tr ng-repeat="ticket in model.data track by ticket.id"
|
||||
vn-anchor="::{
|
||||
state: 'ticket.card.summary',
|
||||
params: {id: ticket.id},
|
||||
|
|
Loading…
Reference in New Issue