aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/components
diff options
context:
space:
mode:
authorZero~Informatique2020-09-11 00:15:04 +0200
committerG.Fouet2020-09-11 21:53:18 +0200
commite6c2a8d9653ffde924632ca2f260c3a8cddc14ed (patch)
treeccc847bdec26d131ee260203410d7a16a0a6fbcf /viewer/src/components
parentd72e317896bcc2a675d21cec6f286e0b2730d77c (diff)
downloadldgallery-e6c2a8d9653ffde924632ca2f260c3a8cddc14ed.tar.gz
viewer: item display order
github: resolves #28
Diffstat (limited to 'viewer/src/components')
-rw-r--r--viewer/src/components/LdCommand.vue1
-rw-r--r--viewer/src/components/LdCommandSort.vue57
-rw-r--r--viewer/src/components/LdGallery.vue6
3 files changed, 63 insertions, 1 deletions
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">
34import { Component, Vue, Prop } from "vue-property-decorator";
35import { RawLocation } from "vue-router";
36import ItemSortFn from "@/services/itemSortFn";
37
38@Component
39export 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 }