test_to_dev #1513

Merged
alexm merged 12 commits from test_to_dev into dev 2023-05-10 10:41:12 +00:00
1 changed files with 12 additions and 12 deletions
Showing only changes of commit 7a668adf18 - Show all commits

View File

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