This commit is contained in:
2020-02-12 18:45:45 +00:00
parent 08fb113193
commit 7908f82c35
4 changed files with 437 additions and 31 deletions

View File

@@ -284,14 +284,12 @@ export default {
props: {
apiBaseUrl: {
type: String,
default: "DataList/List"
default: "DataList"
},
formKey: String,
dataListKey: String,
dataFilterId: {
type: Number,
default: 0
},
dataListSort: String,
dataListFilter: String,
showSelect: {
type: Boolean,
default: false
@@ -377,34 +375,52 @@ export default {
that.loading = true;
var listUrl =
that.apiBaseUrl + "?" + window.$gz.api.buildQuery(listOptions);
window.$gz.api.get(listUrl).then(res => {
//NOTE: This is how to call an async function and await it from sync code
(async function() {
//Save a copy of the server columns data for handling button clicks etc later
that.serverColumns = res.columns;
//Make sure the locale keys are fetched
await fetchLocalizedHeaderNames(res.columns); //Note can use await here because it's wrapped inside an async function call, it will wait then resume next stuff below
await fetchEnums(res.columns);
//build that.headers here
that.headers = buildHeaders(res.columns);
//Post process data here and then set that.records
that.records = buildRecords(res.data, res.columns);
that.loading = false;
that.totalRecords = res.totalRecordCount;
// var listUrl =
// that.apiBaseUrl + "?" + window.$gz.api.buildQuery(listOptions);
//persist the paging options so user sees same page and list on refresh or leave and return scenario
// {
// "offset": 0,
// "limit": 0,
// "mini": true,
// "dataListKey": "string",
// "filterJson": "string",
// "sortJson": "string"
// }
window.$gz.form.setFormSettings(that.formKey, {
temp: { page: that.dataTablePagingOptions.page },
saved: {
itemsPerPage: that.dataTablePagingOptions.itemsPerPage
}
});
//////////
})();
});
window.$gz.api
.upsert(that.apiBaseUrl, {
offset: listOptions.Offset,
limit: listOptions.Limit,
dataListKey: that.dataListKey,
filterJson: that.dataListFilter,
sortJson: that.dataListSort
})
.then(res => {
//NOTE: This is how to call an async function and await it from sync code
(async function() {
//Save a copy of the server columns data for handling button clicks etc later
that.serverColumns = res.columns;
//Make sure the locale keys are fetched
await fetchLocalizedHeaderNames(res.columns); //Note can use await here because it's wrapped inside an async function call, it will wait then resume next stuff below
await fetchEnums(res.columns);
//build that.headers here
that.headers = buildHeaders(res.columns);
//Post process data here and then set that.records
that.records = buildRecords(res.data, res.columns);
that.loading = false;
that.totalRecords = res.totalRecordCount;
//persist the paging options so user sees same page and list on refresh or leave and return scenario
window.$gz.form.setFormSettings(that.formKey, {
temp: { page: that.dataTablePagingOptions.page },
saved: {
itemsPerPage: that.dataTablePagingOptions.itemsPerPage
}
});
//////////
})();
});
}
},
created() {