fix: sort by clicking instead of select option
This commit is contained in:
parent
f403bdb1f3
commit
b4df3a87b1
20
frontend/src/components/Icons/AscendingIcon.vue
Normal file
20
frontend/src/components/Icons/AscendingIcon.vue
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
class="lucide lucide-arrow-down-a-z"
|
||||||
|
>
|
||||||
|
<path d="m3 16 4 4 4-4" />
|
||||||
|
<path d="M7 20V4" />
|
||||||
|
<path d="M20 8h-5" />
|
||||||
|
<path d="M15 10V6.5a2.5 2.5 0 0 1 5 0V10" />
|
||||||
|
<path d="M15 14h5l-5 6h5" />
|
||||||
|
</svg>
|
||||||
|
</template>
|
||||||
20
frontend/src/components/Icons/DesendingIcon.vue
Normal file
20
frontend/src/components/Icons/DesendingIcon.vue
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="1"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
class="lucide lucide-arrow-up-z-a"
|
||||||
|
>
|
||||||
|
<path d="m3 8 4-4 4 4" />
|
||||||
|
<path d="M7 4v16" />
|
||||||
|
<path d="M15 4h5l-5 6h5" />
|
||||||
|
<path d="M15 20v-3.5a2.5 2.5 0 0 1 5 0V20" />
|
||||||
|
<path d="M20 18h-5" />
|
||||||
|
</svg>
|
||||||
|
</template>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #body="{ close }">
|
<template #body="{ close }">
|
||||||
<div class="my-2 rounded-lg border border-gray-100 bg-white shadow-xl">
|
<div class="my-2 rounded-lg border border-gray-100 bg-white shadow-xl">
|
||||||
<div class="min-w-[352px] p-2">
|
<div class="min-w-60 p-2">
|
||||||
<div
|
<div
|
||||||
v-if="sortValues?.size"
|
v-if="sortValues?.size"
|
||||||
id="sort-list"
|
id="sort-list"
|
||||||
@ -26,34 +26,51 @@
|
|||||||
<div
|
<div
|
||||||
v-for="(sort, i) in sortValues"
|
v-for="(sort, i) in sortValues"
|
||||||
:key="sort.fieldname"
|
:key="sort.fieldname"
|
||||||
class="flex items-center gap-2"
|
class="flex items-center gap-1"
|
||||||
>
|
>
|
||||||
<div class="handle flex h-7 w-7 items-center justify-center">
|
<div class="handle flex h-7 w-7 items-center justify-center">
|
||||||
<DragIcon class="h-4 w-4 cursor-grab text-gray-600" />
|
<DragIcon class="h-4 w-4 cursor-grab text-gray-600" />
|
||||||
</div>
|
</div>
|
||||||
<Autocomplete
|
<div class="flex">
|
||||||
class="!w-32"
|
<Button
|
||||||
:value="sort.fieldname"
|
size="md"
|
||||||
:options="sortOptions.data"
|
class="rounded-r-none border-r"
|
||||||
@change="(e) => updateSort(e, i)"
|
@click="
|
||||||
:placeholder="__('First Name')"
|
() => {
|
||||||
/>
|
sort.direction = sort.direction == 'asc' ? 'desc' : 'asc'
|
||||||
<FormControl
|
apply()
|
||||||
class="!w-32"
|
}
|
||||||
type="select"
|
"
|
||||||
v-model="sort.direction"
|
>
|
||||||
:options="[
|
<AscendingIcon v-if="sort.direction == 'asc'" class="h-4" />
|
||||||
{ label: __('Ascending'), value: 'asc' },
|
<DesendingIcon v-else class="h-4" />
|
||||||
{ label: __('Descending'), value: 'desc' },
|
</Button>
|
||||||
]"
|
<Autocomplete
|
||||||
@change="
|
class="!w-32"
|
||||||
(e) => {
|
:value="sort.fieldname"
|
||||||
sort.direction = e.target.value
|
:options="sortOptions.data"
|
||||||
apply()
|
@change="(e) => updateSort(e, i)"
|
||||||
}
|
:placeholder="__('First Name')"
|
||||||
"
|
>
|
||||||
:placeholder="__('Ascending')"
|
<template
|
||||||
/>
|
#target="{ togglePopover, selectedValue, displayValue }"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
class="flex w-full items-center justify-between rounded-l-none !text-gray-600"
|
||||||
|
size="md"
|
||||||
|
@click="togglePopover()"
|
||||||
|
>
|
||||||
|
{{ displayValue(selectedValue) }}
|
||||||
|
<template #suffix>
|
||||||
|
<FeatherIcon
|
||||||
|
name="chevron-down"
|
||||||
|
class="h-4 text-gray-600"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</Autocomplete>
|
||||||
|
</div>
|
||||||
<Button variant="ghost" icon="x" @click="removeSort(i)" />
|
<Button variant="ghost" icon="x" @click="removeSort(i)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -98,6 +115,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import AscendingIcon from '@/components/Icons/AscendingIcon.vue'
|
||||||
|
import DesendingIcon from '@/components/Icons/DesendingIcon.vue'
|
||||||
import NestedPopover from '@/components/NestedPopover.vue'
|
import NestedPopover from '@/components/NestedPopover.vue'
|
||||||
import SortIcon from '@/components/Icons/SortIcon.vue'
|
import SortIcon from '@/components/Icons/SortIcon.vue'
|
||||||
import DragIcon from '@/components/Icons/DragIcon.vue'
|
import DragIcon from '@/components/Icons/DragIcon.vue'
|
||||||
|
|||||||
@ -2,7 +2,16 @@
|
|||||||
<Combobox v-model="selectedValue" nullable v-slot="{ open: isComboboxOpen }">
|
<Combobox v-model="selectedValue" nullable v-slot="{ open: isComboboxOpen }">
|
||||||
<Popover class="w-full" v-model:show="showOptions">
|
<Popover class="w-full" v-model:show="showOptions">
|
||||||
<template #target="{ open: openPopover, togglePopover }">
|
<template #target="{ open: openPopover, togglePopover }">
|
||||||
<slot name="target" v-bind="{ open: openPopover, togglePopover, isOpen: showOptions }">
|
<slot
|
||||||
|
name="target"
|
||||||
|
v-bind="{
|
||||||
|
open: openPopover,
|
||||||
|
togglePopover,
|
||||||
|
isOpen: showOptions,
|
||||||
|
selectedValue,
|
||||||
|
displayValue,
|
||||||
|
}"
|
||||||
|
>
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<button
|
<button
|
||||||
class="flex w-full items-center justify-between focus:outline-none"
|
class="flex w-full items-center justify-between focus:outline-none"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user