diff options
Diffstat (limited to 'viewer/src')
-rw-r--r-- | viewer/src/assets/scss/theme.scss | 2 | ||||
-rw-r--r-- | viewer/src/components/LdCommand.vue | 1 | ||||
-rw-r--r-- | viewer/src/components/LdCommandSort.vue | 57 | ||||
-rw-r--r-- | viewer/src/components/LdGallery.vue | 6 | ||||
-rw-r--r-- | viewer/src/locales/en.json | 4 | ||||
-rw-r--r-- | viewer/src/plugins/buefy.ts | 3 | ||||
-rw-r--r-- | viewer/src/plugins/fontawesome-icons.ts | 3 | ||||
-rw-r--r-- | viewer/src/services/itemSortFn.ts | 28 | ||||
-rw-r--r-- | viewer/src/store/galleryStore.ts | 4 | ||||
-rw-r--r-- | viewer/src/store/uiStore.ts | 8 | ||||
-rw-r--r-- | viewer/src/views/MainLayout.vue | 8 |
11 files changed, 118 insertions, 6 deletions
diff --git a/viewer/src/assets/scss/theme.scss b/viewer/src/assets/scss/theme.scss index c59eba9..19fe673 100644 --- a/viewer/src/assets/scss/theme.scss +++ b/viewer/src/assets/scss/theme.scss | |||
@@ -54,6 +54,8 @@ $button-focus-color: $button-color; | |||
54 | $button-focus-border-color: $link; | 54 | $button-focus-border-color: $link; |
55 | $button-focus-box-shadow-size: 0; | 55 | $button-focus-box-shadow-size: 0; |
56 | $body-line-height: 1.5; | 56 | $body-line-height: 1.5; |
57 | $dropdown-item-color: $palette-900; | ||
58 | $dropdown-item-active-color: $palette-900; | ||
57 | 59 | ||
58 | // Custom components | 60 | // Custom components |
59 | 61 | ||
diff --git a/viewer/src/components/LdCommand.vue b/viewer/src/components/LdCommand.vue index d3705de..6059162 100644 --- a/viewer/src/components/LdCommand.vue +++ b/viewer/src/components/LdCommand.vue | |||
@@ -23,6 +23,7 @@ | |||
23 | <a class="link" :title="$t('command.search')" @click="$uiStore.toggleFullWidth()"> | 23 | <a class="link" :title="$t('command.search')" @click="$uiStore.toggleFullWidth()"> |
24 | <fa-icon :icon="commandToggleSearchPanelIcon" size="lg" /> | 24 | <fa-icon :icon="commandToggleSearchPanelIcon" size="lg" /> |
25 | </a> | 25 | </a> |
26 | <ld-command-sort /> | ||
26 | <a | 27 | <a |
27 | :class="{ disabled: isEntryPoint }" | 28 | :class="{ disabled: isEntryPoint }" |
28 | class="link command-secondary" | 29 | class="link command-secondary" |
diff --git a/viewer/src/components/LdCommandSort.vue b/viewer/src/components/LdCommandSort.vue new file mode 100644 index 0000000..1d2eac3 --- /dev/null +++ b/viewer/src/components/LdCommandSort.vue | |||
@@ -0,0 +1,57 @@ | |||
1 | <!-- ldgallery - A static generator which turns a collection of tagged | ||
2 | -- pictures into a searchable web gallery. | ||
3 | -- | ||
4 | -- Copyright (C) 2019-2020 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 | <b-dropdown v-model="selectedSort" :mobile-modal="false" append-to-body @change="onChangeSort"> | ||
23 | <a slot="trigger" class="link"> | ||
24 | <fa-icon icon="sort-amount-down" size="lg" /> | ||
25 | </a> | ||
26 | <b-dropdown-item v-for="(sort, idx) in SORTS" :key="idx" :value="idx"> | ||
27 | <fa-icon :icon="['far', idx === selectedSort ? 'dot-circle' : 'circle']" /> | ||
28 | <span :class="$style.ml1">{{ sort.name }}</span> | ||
29 | </b-dropdown-item> | ||
30 | </b-dropdown> | ||
31 | </template> | ||
32 | |||
33 | <script lang="ts"> | ||
34 | import { Component, Vue, Prop } from "vue-property-decorator"; | ||
35 | import { RawLocation } from "vue-router"; | ||
36 | import ItemSortFn from "@/services/itemSortFn"; | ||
37 | |||
38 | @Component | ||
39 | export default class LdCommandSort extends Vue { | ||
40 | readonly SORTS = [ | ||
41 | { name: this.$t("command.sort.byName"), fn: ItemSortFn.sortByName }, | ||
42 | { name: this.$t("command.sort.byDateDesc"), fn: ItemSortFn.sortByDateDesc }, | ||
43 | ]; | ||
44 | |||
45 | selectedSort = 0; | ||
46 | |||
47 | onChangeSort(newValue: number) { | ||
48 | this.$uiStore.setSortFn(this.SORTS[newValue].fn); | ||
49 | } | ||
50 | } | ||
51 | </script> | ||
52 | |||
53 | <style lang="scss" module> | ||
54 | .ml1 { | ||
55 | margin-left: 0.5em; | ||
56 | } | ||
57 | </style> | ||
diff --git a/viewer/src/components/LdGallery.vue b/viewer/src/components/LdGallery.vue index 5a72d99..0c0a43c 100644 --- a/viewer/src/components/LdGallery.vue +++ b/viewer/src/components/LdGallery.vue | |||
@@ -20,7 +20,7 @@ | |||
20 | <template> | 20 | <template> |
21 | <ld-error v-if="hasNoResults" icon="search" :message="noresult" /> | 21 | <ld-error v-if="hasNoResults" icon="search" :message="noresult" /> |
22 | <div v-else class="thumbnail-tiles"> | 22 | <div v-else class="thumbnail-tiles"> |
23 | <router-link v-for="item in items" :key="item.path" :to="item.path"> | 23 | <router-link v-for="item in sortedItems" :key="item.path" :to="item.path"> |
24 | <ld-thumbnail :item="item" /> | 24 | <ld-thumbnail :item="item" /> |
25 | </router-link> | 25 | </router-link> |
26 | </div> | 26 | </div> |
@@ -35,6 +35,10 @@ export default class LdPicture extends Vue { | |||
35 | @Prop({ type: Array, required: true }) readonly items!: Gallery.Item[]; | 35 | @Prop({ type: Array, required: true }) readonly items!: Gallery.Item[]; |
36 | @Prop(String) readonly noresult?: string; | 36 | @Prop(String) readonly noresult?: string; |
37 | 37 | ||
38 | get sortedItems() { | ||
39 | return this.items.sort(this.$uiStore.sortFn); | ||
40 | } | ||
41 | |||
38 | get hasNoResults(): boolean { | 42 | get hasNoResults(): boolean { |
39 | return Boolean(this.noresult) && this.items.length === 0; | 43 | return Boolean(this.noresult) && this.items.length === 0; |
40 | } | 44 | } |
diff --git a/viewer/src/locales/en.json b/viewer/src/locales/en.json index b36ac57..915f600 100644 --- a/viewer/src/locales/en.json +++ b/viewer/src/locales/en.json | |||
@@ -17,5 +17,7 @@ | |||
17 | "directory.no-results": "Empty directory", | 17 | "directory.no-results": "Empty directory", |
18 | "panelLeft.propositions.other": "other filters", | 18 | "panelLeft.propositions.other": "other filters", |
19 | "panelLeft.information.title": "Information", | 19 | "panelLeft.information.title": "Information", |
20 | "tag-propositions.showmore": "show more ({0})" | 20 | "tag-propositions.showmore": "show more ({0})", |
21 | "command.sort.byName": "By name", | ||
22 | "command.sort.byDateDesc": "By most recent" | ||
21 | } | 23 | } |
diff --git a/viewer/src/plugins/buefy.ts b/viewer/src/plugins/buefy.ts index 7a71019..4794ad9 100644 --- a/viewer/src/plugins/buefy.ts +++ b/viewer/src/plugins/buefy.ts | |||
@@ -29,6 +29,8 @@ import Button from "buefy/src/components/button"; | |||
29 | import SnackBar from "buefy/src/components/snackbar"; | 29 | import SnackBar from "buefy/src/components/snackbar"; |
30 | // @ts-ignore | 30 | // @ts-ignore |
31 | import Tag from "buefy/src/components/tag"; | 31 | import Tag from "buefy/src/components/tag"; |
32 | // @ts-ignore | ||
33 | import DropDown from "buefy/src/components/dropdown"; | ||
32 | 34 | ||
33 | import "@/assets/scss/buefy.scss"; | 35 | import "@/assets/scss/buefy.scss"; |
34 | 36 | ||
@@ -37,6 +39,7 @@ Vue.use(Loading); | |||
37 | Vue.use(Button); | 39 | Vue.use(Button); |
38 | Vue.use(SnackBar); | 40 | Vue.use(SnackBar); |
39 | Vue.use(Tag); | 41 | Vue.use(Tag); |
42 | Vue.use(DropDown); | ||
40 | 43 | ||
41 | declare module "vue/types/vue" { | 44 | declare module "vue/types/vue" { |
42 | interface Vue { | 45 | interface Vue { |
diff --git a/viewer/src/plugins/fontawesome-icons.ts b/viewer/src/plugins/fontawesome-icons.ts index 8d136a6..4b50641 100644 --- a/viewer/src/plugins/fontawesome-icons.ts +++ b/viewer/src/plugins/fontawesome-icons.ts | |||
@@ -39,4 +39,7 @@ export { | |||
39 | faCaretUp, | 39 | faCaretUp, |
40 | faCaretDown, | 40 | faCaretDown, |
41 | faAngleDoubleDown, | 41 | faAngleDoubleDown, |
42 | faSortAmountDown, | ||
42 | } from "@fortawesome/free-solid-svg-icons"; | 43 | } from "@fortawesome/free-solid-svg-icons"; |
44 | |||
45 | export { faCircle, faDotCircle } from "@fortawesome/free-regular-svg-icons"; | ||
diff --git a/viewer/src/services/itemSortFn.ts b/viewer/src/services/itemSortFn.ts new file mode 100644 index 0000000..ec9942c --- /dev/null +++ b/viewer/src/services/itemSortFn.ts | |||
@@ -0,0 +1,28 @@ | |||
1 | /* ldgallery - A static generator which turns a collection of tagged | ||
2 | -- pictures into a searchable web gallery. | ||
3 | -- | ||
4 | -- Copyright (C) 2019-2020 Guillaume FOUET | ||
5 | -- | ||
6 | -- This program is free software: you can redistribute it and/or modify | ||
7 | -- it under the terms of the GNU Affero General Public License as | ||
8 | -- published by the Free Software Foundation, either version 3 of the | ||
9 | -- License, or (at your option) any later version. | ||
10 | -- | ||
11 | -- This program is distributed in the hope that it will be useful, | ||
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | -- GNU Affero General Public License for more details. | ||
15 | -- | ||
16 | -- You should have received a copy of the GNU Affero General Public License | ||
17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | export default class ItemSortFn { | ||
21 | static sortByName(left: Gallery.Item, right: Gallery.Item): number { | ||
22 | return left.title.localeCompare(right.title); | ||
23 | } | ||
24 | |||
25 | static sortByDateDesc(left: Gallery.Item, right: Gallery.Item): number { | ||
26 | return -left.datetime.localeCompare(right.datetime); // TODO: handle timezones | ||
27 | } | ||
28 | } | ||
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 5458f20..768adb6 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts | |||
@@ -31,7 +31,7 @@ export default class GalleryStore extends VuexModule { | |||
31 | galleryIndex: Gallery.Index | null = null; | 31 | galleryIndex: Gallery.Index | null = null; |
32 | tagsIndex: Tag.Index = {}; | 32 | tagsIndex: Tag.Index = {}; |
33 | tagsCategories: Tag.Category[] = []; | 33 | tagsCategories: Tag.Category[] = []; |
34 | currentPath: string = "/"; | 34 | currentPath: string | null = null; |
35 | currentSearch: Tag.Search[] = []; | 35 | currentSearch: Tag.Search[] = []; |
36 | 36 | ||
37 | // --- | 37 | // --- |
@@ -64,7 +64,7 @@ export default class GalleryStore extends VuexModule { | |||
64 | 64 | ||
65 | get currentItemPath(): Gallery.Item[] { | 65 | get currentItemPath(): Gallery.Item[] { |
66 | const root = this.galleryIndex?.tree; | 66 | const root = this.galleryIndex?.tree; |
67 | if (root) return Navigation.searchCurrentItemPath(root, this.currentPath); | 67 | if (root && this.currentPath) return Navigation.searchCurrentItemPath(root, this.currentPath); |
68 | return []; | 68 | return []; |
69 | } | 69 | } |
70 | 70 | ||
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 91ac338..1fe9f49 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts | |||
@@ -18,16 +18,20 @@ | |||
18 | */ |