Improve checkbox click handling support for grids
i.e. let custom use define click handlers
This commit is contained in:
parent
a857d31776
commit
bcfb4f257d
5 changed files with 96 additions and 10 deletions
|
@ -93,6 +93,10 @@ Vue.component('grid-filter', GridFilter)
|
|||
let TailboneGrid = {
|
||||
template: '#tailbone-grid-template',
|
||||
|
||||
props: {
|
||||
csrftoken: String,
|
||||
},
|
||||
|
||||
computed: {
|
||||
// note, can use this with v-model for hidden 'uuids' fields
|
||||
selected_uuids: function() {
|
||||
|
@ -120,14 +124,14 @@ let TailboneGrid = {
|
|||
|
||||
this.loading = true
|
||||
this.$http.get(`${this.ajaxDataUrl}?${params}`).then(({ data }) => {
|
||||
this.data = data.data
|
||||
TailboneGridCurrentData = data.data
|
||||
this.data = TailboneGridCurrentData
|
||||
this.rowStatusMap = data.row_status_map
|
||||
this.total = data.total_items
|
||||
this.firstItem = data.first_item
|
||||
this.lastItem = data.last_item
|
||||
this.loading = false
|
||||
// TODO: should "merge" checked results from server?
|
||||
this.checkedRows = []
|
||||
this.checkedRows = this.locateCheckedRows(data.checked_rows)
|
||||
})
|
||||
.catch((error) => {
|
||||
this.data = []
|
||||
|
@ -137,6 +141,18 @@ let TailboneGrid = {
|
|||
})
|
||||
},
|
||||
|
||||
locateCheckedRows(checked) {
|
||||
let rows = []
|
||||
if (checked) {
|
||||
for (let i = 0; i < this.data.length; i++) {
|
||||
if (checked.includes(i)) {
|
||||
rows.push(this.data[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
return rows
|
||||
},
|
||||
|
||||
onPageChange(page) {
|
||||
this.page = page
|
||||
this.loadAsyncData()
|
||||
|
@ -244,6 +260,14 @@ let TailboneGrid = {
|
|||
uuids.push(row.uuid)
|
||||
}
|
||||
return uuids
|
||||
}
|
||||
},
|
||||
|
||||
allRowUUIDs() {
|
||||
let uuids = []
|
||||
for (let row of this.data) {
|
||||
uuids.push(row.uuid)
|
||||
}
|
||||
return uuids
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,45 @@
|
|||
* Add "row status" styles for Buefy grid tables.
|
||||
********************************************************************************/
|
||||
|
||||
/**************************************************
|
||||
* grid rows with "warning" status
|
||||
**************************************************/
|
||||
|
||||
tr.warning {
|
||||
background-color: #fcc;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************
|
||||
* grid rows with "notice" status
|
||||
**************************************************/
|
||||
|
||||
tr.notice {
|
||||
background-color: #fe8;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************
|
||||
* grid rows which are "checked" (selected)
|
||||
**************************************************/
|
||||
|
||||
/* TODO: this references some color values, whereas it would be preferable
|
||||
* to refer to some sort of "state" instead, color of which was
|
||||
* configurable. b/c these are just the default Buefy theme colors. */
|
||||
|
||||
tr.is-checked {
|
||||
background-color: #7957d5;
|
||||
color: white;
|
||||
}
|
||||
|
||||
tr.is-checked:hover {
|
||||
color: #363636;
|
||||
}
|
||||
|
||||
tr.is-checked a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
tr.is-checked:hover a {
|
||||
color: #7957d5;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue