diff options
author | Zero~Informatique | 2020-01-29 05:35:35 +0100 |
---|---|---|
committer | Notkea | 2020-01-29 21:59:12 +0100 |
commit | c4a51940295d514dd52f48b6f18638ac554224f4 (patch) | |
tree | 56e6ab1393085f44ac71d7bc7b14b78b5d6e444d /viewer/src/components | |
parent | 8d543ab94d3678728466d3627e0d419ec00f3010 (diff) | |
download | ldgallery-c4a51940295d514dd52f48b6f18638ac554224f4.tar.gz |
viewer: Tag auto-completion should be more flexible. Resolves #38
Diffstat (limited to 'viewer/src/components')
-rw-r--r-- | viewer/src/components/LdTagInput.vue | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/viewer/src/components/LdTagInput.vue b/viewer/src/components/LdTagInput.vue index 71131e6..7c9981f 100644 --- a/viewer/src/components/LdTagInput.vue +++ b/viewer/src/components/LdTagInput.vue | |||
@@ -42,6 +42,7 @@ | |||
42 | <script lang="ts"> | 42 | <script lang="ts"> |
43 | import { Component, Vue } from "vue-property-decorator"; | 43 | import { Component, Vue } from "vue-property-decorator"; |
44 | import { Operation } from "@/@types/tag/Operation"; | 44 | import { Operation } from "@/@types/tag/Operation"; |
45 | import Tools from "@/tools"; | ||
45 | 46 | ||
46 | @Component | 47 | @Component |
47 | export default class LdTagInput extends Vue { | 48 | export default class LdTagInput extends Vue { |
@@ -92,18 +93,20 @@ export default class LdTagInput extends Vue { | |||
92 | category: string, | 93 | category: string, |
93 | disambiguation: string | 94 | disambiguation: string |
94 | ): Tag.Search[] { | 95 | ): Tag.Search[] { |
96 | disambiguation = Tools.normalize(disambiguation); | ||
95 | return Object.values(tags) | 97 | return Object.values(tags) |
96 | .filter(node => node.tag.includes(category)) | 98 | .filter(node => node.tag.includes(category)) |
97 | .flatMap(node => | 99 | .flatMap(node => |
98 | Object.values(node.children) | 100 | Object.values(node.children) |
99 | .filter(child => child.tag.includes(disambiguation)) | 101 | .filter(child => child.tagfiltered.includes(disambiguation)) |
100 | .map(child => ({ ...child, parent: node, operation, display: `${operation}${node.tag}:${child.tag}` })) | 102 | .map(child => ({ ...child, parent: node, operation, display: `${operation}${node.tag}:${child.tag}` })) |
101 | ); | 103 | ); |
102 | } | 104 | } |
103 | 105 | ||
104 | searchTagsFromFilter(tags: Tag.Index, operation: Operation, filter: string): Tag.Search[] { | 106 | searchTagsFromFilter(tags: Tag.Index, operation: Operation, filter: string): Tag.Search[] { |
107 | filter = Tools.normalize(filter); | ||
105 | return Object.values(tags) | 108 | return Object.values(tags) |
106 | .filter(node => node.tag.includes(filter)) | 109 | .filter(node => node.tagfiltered.includes(filter)) |
107 | .map(node => ({ ...node, operation, display: `${operation}${node.tag}` })); | 110 | .map(node => ({ ...node, operation, display: `${operation}${node.tag}` })); |
108 | } | 111 | } |
109 | 112 | ||