Merge pull request #238 from shikorism/feature/disable-inserted-tag
入力済みのタグ候補の背景色を変更する
This commit is contained in:
commit
c5cbad4475
@ -20,8 +20,8 @@
|
|||||||
<p class="card-text mb-2" style="font-size: small;">タグ候補<br><span class="text-secondary">(クリックするとタグ入力欄にコピーできます)</span></p>
|
<p class="card-text mb-2" style="font-size: small;">タグ候補<br><span class="text-secondary">(クリックするとタグ入力欄にコピーできます)</span></p>
|
||||||
<ul class="list-inline d-inline">
|
<ul class="list-inline d-inline">
|
||||||
<li v-for="tag in suggestions"
|
<li v-for="tag in suggestions"
|
||||||
class="list-inline-item badge badge-primary metadata-tag-item"
|
:class="tagClasses(tag)"
|
||||||
@click="addTag(tag)"><span class="oi oi-tag"></span> {{ tag }}</li>
|
@click="addTag(tag.name)"><span class="oi oi-tag"></span> {{ tag.name }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@ -54,6 +54,11 @@
|
|||||||
}[],
|
}[],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type Suggestion = {
|
||||||
|
name: string,
|
||||||
|
used: boolean,
|
||||||
|
}
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class MetadataPreview extends Vue {
|
export default class MetadataPreview extends Vue {
|
||||||
@Prop() readonly state!: MetadataLoadState;
|
@Prop() readonly state!: MetadataLoadState;
|
||||||
@ -62,16 +67,38 @@
|
|||||||
// for use in v-if
|
// for use in v-if
|
||||||
private readonly MetadataLoadState = MetadataLoadState;
|
private readonly MetadataLoadState = MetadataLoadState;
|
||||||
|
|
||||||
|
tags: string[] = [];
|
||||||
|
|
||||||
|
created() {
|
||||||
|
bus.$on("change-tag", (tags: string[]) => this.tags = tags);
|
||||||
|
bus.$emit("resend-tag");
|
||||||
|
}
|
||||||
|
|
||||||
addTag(tag: string) {
|
addTag(tag: string) {
|
||||||
bus.$emit("add-tag", tag);
|
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) {
|
if (this.metadata === null) {
|
||||||
return [];
|
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() {
|
get hasImage() {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {Vue, Component, Prop} from "vue-property-decorator";
|
import {Vue, Component, Prop, Watch} from "vue-property-decorator";
|
||||||
import {bus} from "../checkin";
|
import {bus} from "../checkin";
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
created() {
|
created() {
|
||||||
bus.$on("add-tag", (tag: string) => this.tags.indexOf(tag) === -1 && this.tags.push(tag));
|
bus.$on("add-tag", (tag: string) => this.tags.indexOf(tag) === -1 && this.tags.push(tag));
|
||||||
|
bus.$on("resend-tag", () => bus.$emit("change-tag", this.tags));
|
||||||
}
|
}
|
||||||
|
|
||||||
onKeyDown(event: KeyboardEvent) {
|
onKeyDown(event: KeyboardEvent) {
|
||||||
@ -56,6 +57,11 @@
|
|||||||
this.tags.splice(index, 1);
|
this.tags.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Watch("tags")
|
||||||
|
onTagsChanged() {
|
||||||
|
bus.$emit("change-tag", this.tags);
|
||||||
|
}
|
||||||
|
|
||||||
get containerClass(): object {
|
get containerClass(): object {
|
||||||
return {
|
return {
|
||||||
"form-control": true,
|
"form-control": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user