Add basic pagination support for model index, and view w/ rows
This commit is contained in:
parent
c87fd1ab35
commit
e83d98905a
2 changed files with 58 additions and 6 deletions
|
@ -58,7 +58,7 @@
|
|||
<div v-if="hasRows && mode == 'viewing'">
|
||||
<b-menu>
|
||||
<b-menu-list>
|
||||
<b-menu-item v-for="row in rows"
|
||||
<b-menu-item v-for="row in rowData.data"
|
||||
:key="row.uuid"
|
||||
tag="router-link"
|
||||
:to="getRowPathPrefix() + '/' + row.uuid">
|
||||
|
@ -68,6 +68,14 @@
|
|||
</b-menu-item>
|
||||
</b-menu-list>
|
||||
</b-menu>
|
||||
<b-pagination v-if="rowsPaginated"
|
||||
:total="rowData.total"
|
||||
:current.sync="rowPage"
|
||||
:per-page="rowsPerPage"
|
||||
@change="changeRowPagination"
|
||||
>
|
||||
<!-- icon-pack="fas" -->
|
||||
</b-pagination>
|
||||
</div>
|
||||
|
||||
<slot name="footer"></slot>
|
||||
|
@ -97,6 +105,14 @@ export default {
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
rowsPaginated: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
rowsPerPage: {
|
||||
type: Number,
|
||||
default: 20,
|
||||
},
|
||||
apiRowsUrl: String,
|
||||
isRow: {
|
||||
type: Boolean,
|
||||
|
@ -121,7 +137,8 @@ export default {
|
|||
data: function() {
|
||||
return {
|
||||
record: {},
|
||||
rows: [],
|
||||
rowData: {},
|
||||
rowPage: 1,
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -328,8 +345,12 @@ export default {
|
|||
orderBy: 'modified',
|
||||
ascending: 0,
|
||||
}
|
||||
if (this.rowsPaginated) {
|
||||
params.per_page = this.rowsPerPage
|
||||
params.page = this.rowPage
|
||||
}
|
||||
this.$http.get(this.getApiRowsUrl(), {params: params}).then(response => {
|
||||
this.rows = response.data.data
|
||||
this.rowData = response.data
|
||||
|
||||
}, response => {
|
||||
if (response.status == 403) { // forbidden; redirect to home page
|
||||
|
@ -349,6 +370,10 @@ export default {
|
|||
})
|
||||
},
|
||||
|
||||
changeRowPagination(value) {
|
||||
this.fetchRows(this.record.uuid)
|
||||
},
|
||||
|
||||
save() {
|
||||
let url = this.getApiIndexUrl()
|
||||
if (this.mode != 'creating') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue