diff --git a/resources/assets/js/components/MetadataPreview.vue b/resources/assets/js/components/MetadataPreview.vue
index eeada94..7b81c8a 100644
--- a/resources/assets/js/components/MetadataPreview.vue
+++ b/resources/assets/js/components/MetadataPreview.vue
@@ -20,8 +20,8 @@
タグ候補
(クリックするとタグ入力欄にコピーできます)
- {{ tag }}
+ :class="tagClasses(tag)"
+ @click="addTag(tag.name)"> {{ tag.name }}
@@ -54,6 +54,11 @@
}[],
};
+ type Suggestion = {
+ name: string,
+ used: boolean,
+ }
+
@Component
export default class MetadataPreview extends Vue {
@Prop() readonly state!: MetadataLoadState;
@@ -62,16 +67,37 @@
// for use in v-if
private readonly MetadataLoadState = MetadataLoadState;
+ tags: string[] = [];
+
+ created() {
+ bus.$on("change-tag", (tags: string[]) => this.tags = tags);
+ }
+
addTag(tag: string) {
bus.$emit("add-tag", tag);
}
- get suggestions() {
+ tagClasses(s: Suggestion) {
+ return {
+ "list-inline-item": true,
+ "badge": true,
+ "badge-primary": !s.used,
+ "badge-secondary": s.used,
+ "metadata-tag-item": true,
+ };
+ }
+
+ get suggestions(): Suggestion[] {
if (this.metadata === null) {
return [];
}
- return this.metadata.tags.map(t => t.name);
+ return this.metadata.tags.map(t => {
+ return {
+ name: t.name,
+ used: this.tags.indexOf(t.name) !== -1
+ };
+ });
}
get hasImage() {
diff --git a/resources/assets/js/components/TagInput.vue b/resources/assets/js/components/TagInput.vue
index 6c7908e..564c088 100644
--- a/resources/assets/js/components/TagInput.vue
+++ b/resources/assets/js/components/TagInput.vue
@@ -16,7 +16,7 @@