Skip to content

Commit

Permalink
Track sort params for reload events.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrichar1 committed Apr 24, 2024
1 parent f639bd0 commit 9428323
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uoe-eng/tabularasa",
"version": "1.31.1",
"version": "1.32.0",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --target lib --name tabularasa src/index.js",
Expand Down
23 changes: 20 additions & 3 deletions src/components/TRList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,29 @@ let dtProps = ref({})
let selectedRow = ref({})
let rowIndex = ref()
let filters = ref({})
let sortField = undefined
let sortOrder = undefined
const columns = computed(() => {
// Get column metadata from collections
return props.configuration.TRList.fields
})
const getUIState = () => {
// Return current state of filters and sorting params
let uiState = { filters: filters.value }
if (sortField.value && sortOrder.value) {
uiState['sortField'] = sortField.value
uiState['sortOrder'] = sortOrder.value
}
return uiState
}
const onClearGlobalFilter = (field) => {
let val = filters.value[field].constraints[0]
if (val.value) {
val.value = ''
onLazy('filter', { filters: filters.value })
onLazy('filter', getUIState())
}
}
Expand All @@ -145,16 +157,21 @@ const onClearFilters = () => {
}
}
}
onLazy('filter', { filters: filters.value })
onLazy('filter', getUIState())
}
const onLazy = (type, event) => {
// Cache sort params for getUIState
if (type === 'sort') {
sortField.value = event.sortField
sortOrder.value = event.sortOrder
}
dtProps.value.limit = event.rows
trBus.emit(`TRList:${type}:${props.name}`, event)
}
const onReload = () => {
trBus.emit(`TRList:reload:${props.name}`, { filters: filters.value })
trBus.emit(`TRList:reload:${props.name}`, getUIState())
}
const onRefresh = () => {
Expand Down

0 comments on commit 9428323

Please sign in to comment.