aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/views')
-rw-r--r--viewer/src/views/GalleryDirectory.vue8
-rw-r--r--viewer/src/views/MainGallery.vue (renamed from viewer/src/views/Gallery.vue)28
2 files changed, 23 insertions, 13 deletions
diff --git a/viewer/src/views/GalleryDirectory.vue b/viewer/src/views/GalleryDirectory.vue
index 1df0c4d..d01032d 100644
--- a/viewer/src/views/GalleryDirectory.vue
+++ b/viewer/src/views/GalleryDirectory.vue
@@ -19,7 +19,7 @@
19 19
20<template> 20<template>
21 <div class="thumbnail-tiles"> 21 <div class="thumbnail-tiles">
22 <div v-for="(item) in directory.properties.items" :key="item.path"> 22 <div v-for="(item) in orderedItems" :key="item.path">
23 <router-link :to="item.path"> 23 <router-link :to="item.path">
24 <gallery-thumbnail :item="item" /> 24 <gallery-thumbnail :item="item" />
25 </router-link> 25 </router-link>
@@ -32,13 +32,19 @@
32 32
33<script lang="ts"> 33<script lang="ts">
34import { Component, Vue, Prop } from "vue-property-decorator"; 34import { Component, Vue, Prop } from "vue-property-decorator";
35import Tools from "@/tools";
35import GalleryThumbnail from "./GalleryThumbnail.vue"; 36import GalleryThumbnail from "./GalleryThumbnail.vue";
37import Gallery from "./Gallery.vue";
36 38
37@Component({ 39@Component({
38 components: { GalleryThumbnail }, 40 components: { GalleryThumbnail },
39}) 41})
40export default class GalleryDirectory extends Vue { 42export default class GalleryDirectory extends Vue {
41 @Prop({ required: true }) readonly directory!: Gallery.Directory; 43 @Prop({ required: true }) readonly directory!: Gallery.Directory;
44
45 get orderedItems() {
46 return Tools.directoriesFirst(this.directory.properties.items);
47 }
42} 48}
43</script> 49</script>
44 50
diff --git a/viewer/src/views/Gallery.vue b/viewer/src/views/MainGallery.vue
index fad7cc3..06cf512 100644
--- a/viewer/src/views/Gallery.vue
+++ b/viewer/src/views/MainGallery.vue
@@ -28,7 +28,8 @@
28 28
29<script lang="ts"> 29<script lang="ts">
30import { Component, Vue, Prop, Watch } from "vue-property-decorator"; 30import { Component, Vue, Prop, Watch } from "vue-property-decorator";
31import { Operation } from '@/@types/tag/Operation'; 31import { Operation } from "@/@types/tag/Operation";
32import Tools from "@/tools";
32import GallerySearch from "./GallerySearch.vue"; 33import GallerySearch from "./GallerySearch.vue";
33import GalleryDirectory from "./GalleryDirectory.vue"; 34import GalleryDirectory from "./GalleryDirectory.vue";
34import GalleryPicture from "./GalleryPicture.vue"; 35import GalleryPicture from "./GalleryPicture.vue";
@@ -40,7 +41,7 @@ export default class Gallery extends Vue {
40 @Prop(String) readonly pathMatch!: string; 41 @Prop(String) readonly pathMatch!: string;
41 42
42 mounted() { 43 mounted() {
43 this.pathChanged() 44 this.pathChanged();
44 } 45 }
45 46
46 @Watch("pathMatch") 47 @Watch("pathMatch")
@@ -59,14 +60,15 @@ export default class Gallery extends Vue {
59 60
60 // --- 61 // ---
61 62
62 private checkType(type: string): boolean { 63 private checkType(type: Gallery.ItemType): boolean {
63 return this.$galleryStore.currentItem?.properties.type === type ?? false; 64 return Tools.checkType(this.$galleryStore.currentItem, type);
64 } 65 }
65 66
66 private extractTagsByOperation(currentTags: Tag.Search[]): Tag.SearchByOperation { 67 private extractTagsByOperation(currentTags: Tag.Search[]): Tag.SearchByOperation {
67 let byOperation: Tag.SearchByOperation = {}; 68 let byOperation: Tag.SearchByOperation = {};
68 Object.values(Operation) 69 Object.values(Operation).forEach(
69 .forEach(operation => byOperation[operation] = currentTags.filter(tag => tag.operation === operation)); 70 operation => (byOperation[operation] = currentTags.filter(tag => tag.operation === operation))
71 );
70 return byOperation; 72 return byOperation;
71 } 73 }
72 74
@@ -75,8 +77,8 @@ export default class Gallery extends Vue {
75 if (byOperation[Operation.INTERSECTION].length > 0) { 77 if (byOperation[Operation.INTERSECTION].length > 0) {
76 byOperation[Operation.INTERSECTION] 78 byOperation[Operation.INTERSECTION]
77 .map(tag => tag.items) 79 .map(tag => tag.items)
78 .reduce((a,b) => a.filter(c => b.includes(c))) 80 .reduce((a, b) => a.filter(c => b.includes(c)))
79 .flatMap(items=>items) 81 .flatMap(items => items)
80 .forEach(item => intersection.add(item)); 82 .forEach(item => intersection.add(item));
81 } 83 }
82 return intersection; 84 return intersection;
@@ -85,14 +87,16 @@ export default class Gallery extends Vue {
85 private extractSubstraction(byOperation: Tag.SearchByOperation): Set<Gallery.Item> { 87 private extractSubstraction(byOperation: Tag.SearchByOperation): Set<Gallery.Item> {
86 let substraction = new Set<Gallery.Item>(); 88 let substraction = new Set<Gallery.Item>();
87 if (byOperation[Operation.SUBSTRACTION].length > 0) { 89 if (byOperation[Operation.SUBSTRACTION].length > 0) {
88 byOperation[Operation.SUBSTRACTION] 90 byOperation[Operation.SUBSTRACTION].flatMap(tag => tag.items).forEach(item => substraction.add(item));
89 .flatMap(tag => tag.items)
90 .forEach(item => substraction.add(item));
91 } 91 }
92 return substraction; 92 return substraction;
93 } 93 }
94 94
95 private aggregateAll(byOperation: Tag.SearchByOperation, intersection: Set<Gallery.Item>, substraction: Set<Gallery.Item>): Gallery.Item[] { 95 private aggregateAll(
96 byOperation: Tag.SearchByOperation,
97 intersection: Set<Gallery.Item>,
98 substraction: Set<Gallery.Item>
99 ): Gallery.Item[] {
96 byOperation[Operation.ADDITION].flatMap(tag => tag.items).forEach(item => intersection.add(item)); 100 byOperation[Operation.ADDITION].flatMap(tag => tag.items).forEach(item => intersection.add(item));
97 substraction.forEach(item => intersection.delete(item)); 101 substraction.forEach(item => intersection.delete(item));
98 return [...intersection]; 102 return [...intersection];