diff options
Diffstat (limited to 'viewer/src/views/layout/top/LayoutCommandSort.vue')
-rw-r--r-- | viewer/src/views/layout/top/LayoutCommandSort.vue | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/viewer/src/views/layout/top/LayoutCommandSort.vue b/viewer/src/views/layout/top/LayoutCommandSort.vue new file mode 100644 index 0000000..8336621 --- /dev/null +++ b/viewer/src/views/layout/top/LayoutCommandSort.vue | |||
@@ -0,0 +1,85 @@ | |||
1 | <!-- ldgallery - A static generator which turns a collection of tagged | ||
2 | -- pictures into a searchable web gallery. | ||
3 | -- | ||
4 | -- Copyright (C) 2019-2022 Guillaume FOUET | ||
5 | -- 2020 Pacien TRAN-GIRARD | ||
6 | -- | ||
7 | -- This program is free software: you can redistribute it and/or modify | ||
8 | -- it under the terms of the GNU Affero General Public License as | ||
9 | -- published by the Free Software Foundation, either version 3 of the | ||
10 | -- License, or (at your option) any later version. | ||
11 | -- | ||
12 | -- This program is distributed in the hope that it will be useful, | ||
13 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | -- GNU Affero General Public License for more details. | ||
16 | -- | ||
17 | -- You should have received a copy of the GNU Affero General Public License | ||
18 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
19 | --> | ||
20 | |||
21 | <template> | ||
22 | <LdLink | ||
23 | :title="t('command.sort.title')" | ||
24 | :tabindex="props.tabindex" | ||
25 | @click="showDropdown=!showDropdown" | ||
26 | > | ||
27 | <fa-icon | ||
28 | :icon="faSortAmountDown" | ||
29 | size="lg" | ||
30 | /> | ||
31 | <teleport to="body"> | ||
32 | <LdDropdown | ||
33 | v-model="showDropdown" | ||
34 | :list="itemComparator.ITEM_SORTS" | ||
35 | :tabindex-root="props.tabindex + 1" | ||
36 | :class="$style.dropdown" | ||
37 | @select="(sort: ItemSort) => selectedSort=sort" | ||
38 | > | ||
39 | <template #option="{option}:{option:ItemSort}"> | ||
40 | <fa-icon :icon="option.name == selectedSort.name ? faDotCircle : faCircle" /> | ||
41 | <span v-text="option.text" /> | ||
42 | </template> | ||
43 | </LdDropdown> | ||
44 | </teleport> | ||
45 | </LdLink> | ||
46 | </template> | ||
47 | |||
48 | <script setup lang="ts"> | ||
49 | import LdDropdown from '@/components/LdDropdown.vue'; | ||
50 | import LdLink from '@/components/LdLink.vue'; | ||
51 | import { ItemSort, useItemComparator } from '@/services/itemComparator'; | ||
52 | import { useUiStore } from '@/store/uiStore'; | ||
53 | import { faCircle, faDotCircle, faSortAmountDown } from '@fortawesome/free-solid-svg-icons'; | ||
54 | import { computed, ref } from 'vue'; | ||
55 | import { useI18n } from 'vue-i18n'; | ||
56 | |||
57 | const props = defineProps({ | ||
58 | tabindex: { type: Number, required: true }, | ||
59 | }); | ||
60 | |||
61 | const { t } = useI18n(); | ||
62 | const uiStore = useUiStore(); | ||
63 | const itemComparator = useItemComparator(); | ||
64 | |||
65 | const selectedSort = computed({ | ||
66 | get: () => uiStore.sort, | ||
67 | set: (newValue: ItemSort) => (uiStore.sort = newValue), | ||
68 | }); | ||
69 | |||
70 | const showDropdown = ref(false); | ||
71 | </script> | ||
72 | |||
73 | <style lang="scss" module> | ||
74 | @import "~@/assets/scss/theme"; | ||
75 | |||
76 | .dropdown { | ||
77 | top: $layout-top; | ||
78 | > div { | ||
79 | padding: 8px 14px; | ||
80 | > span { | ||
81 | padding-left: 12px; | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | </style> | ||