From e6c2a8d9653ffde924632ca2f260c3a8cddc14ed Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Fri, 11 Sep 2020 00:15:04 +0200
Subject: viewer: item display order

github: resolves #28
---
 viewer/src/components/LdCommandSort.vue | 57 +++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 viewer/src/components/LdCommandSort.vue

(limited to 'viewer/src/components/LdCommandSort.vue')

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 @@
+<!-- ldgallery - A static generator which turns a collection of tagged
+--             pictures into a searchable web gallery.
+--
+-- Copyright (C) 2019-2020  Guillaume FOUET
+--               2020       Pacien TRAN-GIRARD
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU Affero General Public License as
+-- published by the Free Software Foundation, either version 3 of the
+-- License, or (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU Affero General Public License for more details.
+--
+-- You should have received a copy of the GNU Affero General Public License
+-- along with this program.  If not, see <https://www.gnu.org/licenses/>.
+-->
+
+<template>
+  <b-dropdown v-model="selectedSort" :mobile-modal="false" append-to-body @change="onChangeSort">
+    <a slot="trigger" class="link">
+      <fa-icon icon="sort-amount-down" size="lg" />
+    </a>
+    <b-dropdown-item v-for="(sort, idx) in SORTS" :key="idx" :value="idx">
+      <fa-icon :icon="['far', idx === selectedSort ? 'dot-circle' : 'circle']" />
+      <span :class="$style.ml1">{{ sort.name }}</span>
+    </b-dropdown-item>
+  </b-dropdown>
+</template>
+
+<script lang="ts">
+import { Component, Vue, Prop } from "vue-property-decorator";
+import { RawLocation } from "vue-router";
+import ItemSortFn from "@/services/itemSortFn";
+
+@Component
+export default class LdCommandSort extends Vue {
+  readonly SORTS = [
+    { name: this.$t("command.sort.byName"), fn: ItemSortFn.sortByName },
+    { name: this.$t("command.sort.byDateDesc"), fn: ItemSortFn.sortByDateDesc },
+  ];
+
+  selectedSort = 0;
+
+  onChangeSort(newValue: number) {
+    this.$uiStore.setSortFn(this.SORTS[newValue].fn);
+  }
+}
+</script>
+
+<style lang="scss" module>
+.ml1 {
+  margin-left: 0.5em;
+}
+</style>
-- 
cgit v1.2.3


From f89ed0bd94ea570d9e6533301783d13b13033db0 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Fri, 11 Sep 2020 20:10:56 +0200
Subject: viewer: PR #238 code review changes

---
 viewer/src/components/LdCommandSort.vue | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'viewer/src/components/LdCommandSort.vue')

diff --git a/viewer/src/components/LdCommandSort.vue b/viewer/src/components/LdCommandSort.vue
index 1d2eac3..1eef5d3 100644
--- a/viewer/src/components/LdCommandSort.vue
+++ b/viewer/src/components/LdCommandSort.vue
@@ -25,7 +25,7 @@
     </a>
     <b-dropdown-item v-for="(sort, idx) in SORTS" :key="idx" :value="idx">
       <fa-icon :icon="['far', idx === selectedSort ? 'dot-circle' : 'circle']" />
-      <span :class="$style.ml1">{{ sort.name }}</span>
+      <span :class="$style.dropdownLabel">{{ sort.name }}</span>
     </b-dropdown-item>
   </b-dropdown>
 </template>
@@ -38,7 +38,7 @@ import ItemSortFn from "@/services/itemSortFn";
 @Component
 export default class LdCommandSort extends Vue {
   readonly SORTS = [
-    { name: this.$t("command.sort.byName"), fn: ItemSortFn.sortByName },
+    { name: this.$t("command.sort.byNameAsc"), fn: ItemSortFn.sortByNameAsc },
     { name: this.$t("command.sort.byDateDesc"), fn: ItemSortFn.sortByDateDesc },
   ];
 
@@ -51,7 +51,7 @@ export default class LdCommandSort extends Vue {
 </script>
 
 <style lang="scss" module>
-.ml1 {
+.dropdownLabel {
   margin-left: 0.5em;
 }
 </style>
-- 
cgit v1.2.3


From 96ed5e6583a7f03d4ea7fa0512e66fffb656cc6e Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Sat, 12 Sep 2020 06:34:58 +0200
Subject: viewer: make default sort order configurable

github: resolves #239
---
 viewer/src/components/LdCommandSort.vue | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

(limited to 'viewer/src/components/LdCommandSort.vue')

diff --git a/viewer/src/components/LdCommandSort.vue b/viewer/src/components/LdCommandSort.vue
index 1eef5d3..a412afc 100644
--- a/viewer/src/components/LdCommandSort.vue
+++ b/viewer/src/components/LdCommandSort.vue
@@ -31,19 +31,28 @@
 </template>
 
 <script lang="ts">
-import { Component, Vue, Prop } from "vue-property-decorator";
+import { Component, Vue, Prop, Watch } from "vue-property-decorator";
 import { RawLocation } from "vue-router";
-import ItemSortFn from "@/services/itemSortFn";
+import ItemComparators, { ItemComparator } from "@/services/itemComparators";
 
 @Component
 export default class LdCommandSort extends Vue {
   readonly SORTS = [
-    { name: this.$t("command.sort.byNameAsc"), fn: ItemSortFn.sortByNameAsc },
-    { name: this.$t("command.sort.byDateDesc"), fn: ItemSortFn.sortByDateDesc },
+    { name: this.$t("command.sort.byNameAsc"), fn: ItemComparators.sortByNameAsc },
+    { name: this.$t("command.sort.byDateDesc"), fn: ItemComparators.sortByDateDesc },
   ];
 
   selectedSort = 0;
 
+  created() {
+    this.onChangeStore(this.$uiStore.sortFn);
+  }
+
+  @Watch("$uiStore.sortFn")
+  onChangeStore(newFn: ItemComparator) {
+    this.selectedSort = this.SORTS.map(s => s.fn).indexOf(newFn);
+  }
+
   onChangeSort(newValue: number) {
     this.$uiStore.setSortFn(this.SORTS[newValue].fn);
   }
-- 
cgit v1.2.3


From b909ec093591b50950c0de54b2005d471ca28116 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Sat, 12 Sep 2020 22:33:37 +0200
Subject: viewer: make default sort order configurable. code review
 improvements

github: resolves #239
---
 viewer/src/components/LdCommandSort.vue | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

(limited to 'viewer/src/components/LdCommandSort.vue')

diff --git a/viewer/src/components/LdCommandSort.vue b/viewer/src/components/LdCommandSort.vue
index a412afc..30644c1 100644
--- a/viewer/src/components/LdCommandSort.vue
+++ b/viewer/src/components/LdCommandSort.vue
@@ -19,42 +19,32 @@
 -->
 
 <template>
-  <b-dropdown v-model="selectedSort" :mobile-modal="false" append-to-body @change="onChangeSort">
+  <b-dropdown v-model="selectedSort" :mobile-modal="false" append-to-body>
     <a slot="trigger" class="link">
       <fa-icon icon="sort-amount-down" size="lg" />
     </a>
-    <b-dropdown-item v-for="(sort, idx) in SORTS" :key="idx" :value="idx">
+    <b-dropdown-item v-for="(sort, idx) in ITEM_SORTS" :key="idx" :value="idx">
       <fa-icon :icon="['far', idx === selectedSort ? 'dot-circle' : 'circle']" />
-      <span :class="$style.dropdownLabel">{{ sort.name }}</span>
+      <span :class="$style.dropdownLabel">{{ sort.text }}</span>
     </b-dropdown-item>
   </b-dropdown>
 </template>
 
 <script lang="ts">
-import { Component, Vue, Prop, Watch } from "vue-property-decorator";
+import { Component, Vue, Prop } from "vue-property-decorator";
 import { RawLocation } from "vue-router";
 import ItemComparators, { ItemComparator } from "@/services/itemComparators";
 
 @Component
 export default class LdCommandSort extends Vue {
-  readonly SORTS = [
-    { name: this.$t("command.sort.byNameAsc"), fn: ItemComparators.sortByNameAsc },
-    { name: this.$t("command.sort.byDateDesc"), fn: ItemComparators.sortByDateDesc },
-  ];
+  readonly ITEM_SORTS = ItemComparators.ITEM_SORTS;
 
-  selectedSort = 0;
-
-  created() {
-    this.onChangeStore(this.$uiStore.sortFn);
-  }
-
-  @Watch("$uiStore.sortFn")
-  onChangeStore(newFn: ItemComparator) {
-    this.selectedSort = this.SORTS.map(s => s.fn).indexOf(newFn);
+  get selectedSort() {
+    return this.ITEM_SORTS.map(s => s.fn).indexOf(this.$uiStore.sortFn);
   }
 
-  onChangeSort(newValue: number) {
-    this.$uiStore.setSortFn(this.SORTS[newValue].fn);
+  set selectedSort(newValue: number) {
+    this.$uiStore.setSortFn(this.ITEM_SORTS[newValue].fn);
   }
 }
 </script>
-- 
cgit v1.2.3


From 26210d495aed813baac1095b5c7a7c7879d2d206 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Fri, 25 Sep 2020 10:42:33 +0200
Subject: viewer: refactor how the available sorts are stored

github: resolves #259
---
 viewer/src/components/LdCommandSort.vue | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

(limited to 'viewer/src/components/LdCommandSort.vue')

diff --git a/viewer/src/components/LdCommandSort.vue b/viewer/src/components/LdCommandSort.vue
index 30644c1..cfaa5c1 100644
--- a/viewer/src/components/LdCommandSort.vue
+++ b/viewer/src/components/LdCommandSort.vue
@@ -23,8 +23,8 @@
     <a slot="trigger" class="link">
       <fa-icon icon="sort-amount-down" size="lg" />
     </a>
-    <b-dropdown-item v-for="(sort, idx) in ITEM_SORTS" :key="idx" :value="idx">
-      <fa-icon :icon="['far', idx === selectedSort ? 'dot-circle' : 'circle']" />
+    <b-dropdown-item v-for="(sort, idx) in ITEM_SORTS" :key="idx" :value="sort">
+      <fa-icon :icon="['far', sort === selectedSort ? 'dot-circle' : 'circle']" />
       <span :class="$style.dropdownLabel">{{ sort.text }}</span>
     </b-dropdown-item>
   </b-dropdown>
@@ -32,19 +32,18 @@
 
 <script lang="ts">
 import { Component, Vue, Prop } from "vue-property-decorator";
-import { RawLocation } from "vue-router";
-import ItemComparators, { ItemComparator } from "@/services/itemComparators";
+import ItemComparators, { ItemSort } from "@/services/itemComparators";
 
 @Component
 export default class LdCommandSort extends Vue {
   readonly ITEM_SORTS = ItemComparators.ITEM_SORTS;
 
   get selectedSort() {
-    return this.ITEM_SORTS.map(s => s.fn).indexOf(this.$uiStore.sortFn);
+    return this.$uiStore.sort;
   }
 
-  set selectedSort(newValue: number) {
-    this.$uiStore.setSortFn(this.ITEM_SORTS[newValue].fn);
+  set selectedSort(newValue: ItemSort) {
+    this.$uiStore.setSort(newValue);
   }
 }
 </script>
-- 
cgit v1.2.3

