refs #5517 Pagination spinner fixes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2023-05-08 16:48:05 +02:00
parent a2e71b57a2
commit 35a888a968
1 changed files with 13 additions and 13 deletions

View File

@ -126,20 +126,20 @@ export default class CrudModel extends ModelProxy {
}
}
loadMore(append) {
loadMore(overwrite) {
if (!this.moreRows)
return this.$q.resolve();
const filter = Object.assign({}, this.currentFilter);
if (append)
if (overwrite)
filter.skip = this.orgData ? this.orgData.length : 0;
if (!append) {
if (!overwrite) {
this.page += 1;
filter.limit = this.page * this.limit;
}
return this.sendRequest(filter, append);
return this.sendRequest(filter, overwrite, true);
}
clear() {
@ -231,12 +231,12 @@ export default class CrudModel extends ModelProxy {
return params;
}
sendRequest(filter, append) {
sendRequest(filter, overwrite, loadMore) {
this.cancelRequest();
this.canceler = this.$q.defer();
this.isPaging = append;
this.isPaging = overwrite;
if (!append)
if (!loadMore)
this.status = 'loading';
let params = Object.assign(
@ -249,16 +249,16 @@ export default class CrudModel extends ModelProxy {
};
return this.$http.get(this._url, options).then(
json => this.onRemoteDone(json, filter, append),
json => this.onRemoteError(json, append)
json => this.onRemoteDone(json, filter, overwrite),
json => this.onRemoteError(json, overwrite)
).finally(() => {
this.isPaging = false;
});
}
onRemoteDone(json, filter, append) {
onRemoteDone(json, filter, overwrite) {
let data = json.data;
if (append)
if (overwrite)
this.orgData = this.orgData.concat(data);
else {
this.orgData = data;
@ -269,8 +269,8 @@ export default class CrudModel extends ModelProxy {
this.onRequestEnd();
}
onRemoteError(err, append) {
if (!append) {
onRemoteError(err, overwrite) {
if (!overwrite) {
this.clear();
this.status = 'error';
}