Let caller define row sorting for model-crud

also display a "title" for rows if set
This commit is contained in:
Lance Edgar 2020-03-23 23:55:04 -05:00
parent 36ba991bdc
commit e7a0ddb782

View file

@ -84,6 +84,7 @@
<slot name="quick-entry"></slot>
<div v-if="hasRows && mode == 'viewing'">
<h2 v-if="rowsTitle">{{ rowsTitle }}</h2>
<slot name="row-filters"></slot>
<b-menu>
<b-menu-list>
@ -132,6 +133,10 @@ export default {
type: Boolean,
default: false,
},
rowsTitle: {
type: String,
default: null,
},
rowsPaginated: {
type: Boolean,
default: true,
@ -153,6 +158,14 @@ export default {
return JSON.stringify([{field: 'batch_uuid', op: 'eq', value: uuid}])
},
},
rowOrderBy: {
type: String,
default: 'modified',
},
rowOrderAscending: {
type: Boolean,
default: false,
},
allowEdit: {
type: Boolean,
default: true,
@ -434,8 +447,8 @@ export default {
fetchRows(uuid) {
let params = {
filters: this.rowFilters(uuid),
orderBy: 'modified',
ascending: 0,
orderBy: this.rowOrderBy,
ascending: this.rowOrderAscending ? 1 : 0,
}
if (this.rowsPaginated) {
params.per_page = this.rowsPerPage