return this.tags.filter(tag => tag.family && tag.family.name === this.font);
}
},
+ methods: {
+ removeTag(tag) {
+ this.$root.$emit('remove-tag', tag);
+ }
+ },
template: `
<div>
<h3>Tags for fonter</h3>
</select>
<ul>
<li v-for="tag in filteredTags" :key="tag.tagName + tag.family.name">
- {{ tag.tagName }} (Score: {{ tag.score }})
+ {{ tag.tagName }}
+ <input type="number" v-model="tag.score" @change="$emit('update:tags', tags)" />
+ <button @click="removeTag(tag)">Remove</button>
</li>
</ul>
</div>
import TagsByFont from "./TagsByFont.js";
import TagsByCategories from "./TagsByCategories.js";
import Panel from "./Panel.js";
+ import TagView from "./TagView.js";
Vue.component('tags-by-font', TagsByFont);
Vue.component('tags-by-categories', TagsByCategories);
Vue.component('panel', Panel);
+ Vue.component('tag-view', TagView);
var app = new Vue({
el: '#app',
},
removePanel(idx) {
this.panels.splice(idx, 1);
+ },
+ removeTag(tag) {
+ console.log("Removing tag:", tag);
+ const index = this.tags.items.indexOf(tag)
+ if (index !== -1) {
+ this.tags.items.splice(index, 1);
+ }
}
},
async created() {
this.gf.loadFamilies();
this.tags = new Tags(this.gf);
this.tags.items = this.tags.items;
+ this.$root.$on("remove-tag", this.removeTag);
}
});
window.app = app