Use 'high-low' nomenclature for numerical columns in grid sort button
This commit is contained in:
parent
e239d1e559
commit
46b079497a
|
@ -3,16 +3,13 @@
|
||||||
import { ActionButton, Popover, Select } from "@budibase/bbui"
|
import { ActionButton, Popover, Select } from "@budibase/bbui"
|
||||||
|
|
||||||
const { sort, columns, stickyColumn } = getContext("grid")
|
const { sort, columns, stickyColumn } = getContext("grid")
|
||||||
const orderOptions = [
|
|
||||||
{ label: "A-Z", value: "ascending" },
|
|
||||||
{ label: "Z-A", value: "descending" },
|
|
||||||
]
|
|
||||||
|
|
||||||
let open = false
|
let open = false
|
||||||
let anchor
|
let anchor
|
||||||
|
|
||||||
$: columnOptions = getColumnOptions($stickyColumn, $columns)
|
$: columnOptions = getColumnOptions($stickyColumn, $columns)
|
||||||
$: checkValidSortColumn($sort.column, $stickyColumn, $columns)
|
$: checkValidSortColumn($sort.column, $stickyColumn, $columns)
|
||||||
|
$: orderOptions = getOrderOptions($sort.column, columnOptions)
|
||||||
|
|
||||||
const getColumnOptions = (stickyColumn, columns) => {
|
const getColumnOptions = (stickyColumn, columns) => {
|
||||||
let options = []
|
let options = []
|
||||||
|
@ -20,6 +17,7 @@
|
||||||
options.push({
|
options.push({
|
||||||
label: stickyColumn.label || stickyColumn.name,
|
label: stickyColumn.label || stickyColumn.name,
|
||||||
value: stickyColumn.name,
|
value: stickyColumn.name,
|
||||||
|
type: stickyColumn.schema?.type,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
|
@ -27,10 +25,25 @@
|
||||||
...columns.map(col => ({
|
...columns.map(col => ({
|
||||||
label: col.label || col.name,
|
label: col.label || col.name,
|
||||||
value: col.name,
|
value: col.name,
|
||||||
|
type: col.schema?.type,
|
||||||
})),
|
})),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getOrderOptions = (column, columnOptions) => {
|
||||||
|
const type = columnOptions.find(col => col.value === column)?.type
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: type === "number" ? "Low-high" : "A-Z",
|
||||||
|
value: "ascending",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: type === "number" ? "High-low" : "Z-A",
|
||||||
|
value: "descending",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
const updateSortColumn = e => {
|
const updateSortColumn = e => {
|
||||||
sort.update(state => ({
|
sort.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
|
|
Loading…
Reference in a new issue