export default {
+
+ schema: {
+ categories: ["a", "b", "c"],
+ lowTag: {
+ filters: [],
+ score: 10
+ },
+ highTag: {
+ filters: [],
+ score: 100
+ }
+ },
+
props: ["categories"],
data: function() {
return {
+ currentCategories: [],
currentAxis: "",
currentPosition: 0,
currentOp: "",
+ currentScore: 0,
filters: [],
}
},
methods: {
addFilter() {
- filters.push(
- {axis: this.currentAxis, op: this.currentOp, value: this.currentPosition}
+ this.filters.push(
+ {
+ axis: this.currentAxis,
+ op: this.currentOp,
+ value: this.currentPosition,
+ score: this.currentScore
+ }
)
+ },
+ addTags() {
+ const filterSet = {
+ categories: this.currentCategories,
+ filters: this.filters
+ };
+ this.$emit('tags-added', filterSet);
+ this.filters = [];
}
},
template: `
- <input type="text" v-model="currentAxis" placeholder="Axis name" />
- <input type="number" v-model="currentPosition" placeholder="Position" />
- <select v-model="currentOp">
- <option value="<="><=</option>
- <option value=">=">>=</option>
- <option value="=">=</option>
- </select>
- <button @click="addFilter">Add Filter</button>
+ <div>
+ <h3>Add Tags</h3>
+ <h3>Category</h3>
+ <select v-model="currentCategories" multiple>
+ <option v-for="category in categories" :key="category">
+ {{ category }}
+ </option>
+ </select>
+ <div>
+ <input type="text" v-model="currentAxis" placeholder="Axis name" />
+ <input type="number" v-model="currentPosition" placeholder="Position" />
+ <select v-model="currentOp">
+ <option value="<="><=</option>
+ <option value=">=">>=</option>
+ <option value="=">=</option>
+ </select>
+ <input type="number" v-model="currentScore" placeholder="Score" />
+ <button @click="addFilter">Add Filter</button>
+ </div>
+ <div>
+ <h3>Current Filters</h3>
+ <ul>
+ <li v-for="filter in filters" :key="filter.axis + filter.value">
+ {{ filter.axis }} {{ filter.op }} {{ filter.value }}
+ <button @click="filters.splice(filters.indexOf(filter), 1)">Remove</button>
+ </li>
+ </ul>
+ </div>
+ <button @click="addTags">Add Tags</button>
+ </div>
`
}
\ No newline at end of file
<button @click="addFontPanel('Maven Pro')">Add Font View</button>
<button @click="addCategoriesPanel(['/Expressive/Loud'])">Add Tag View</button>
<add-tag :categories="categories" @tag-added="addTag"></add-tag>
+ <add-tags :categories="categories" @tags-added="addTags"></add-tags>
<add-category @category-added="addCategory"></add-category>
<div style="display: flex; flex-direction: row; width: 100vw; min-height: 100vh;">
<div v-for="(panel, idx) in panels" :key="idx" :style="{ flex: '1 1 0', minWidth: 0, borderRight: idx < panels.length - 1 ? '1px solid #eee' : 'none', height: '100vh', overflow: 'auto' }">
import AddCategory from "./AddCategory.js";
import VFView from "./VFView.js";
import { linter } from "./linter.js";
+ import AddTags from "./AddTags.js";
import AddCategory from "./AddCategory.js";
import VFView from "./VFView.js";
tag.family = family
this.tags.items.push(tag);
},
+ addTags(filterSet) {
+ let tags = []
+ let filteredFamilies = []
+ for (let family of this.gf.families) {
+ let includeFamily = false;
+ for (let axis of family.axes) {
+ if (
+ filterSet.filters.map(f => f.axis).includes(axis.tag) &&
+ axis.min <= filterSet.filters.find(f => f.axis === axis.tag).value &&
+ axis.max >= filterSet.filters.find(f => f.axis === axis.tag).value) {
+ includeFamily = true;
+ }
+ }
+ if (includeFamily) {
+ console.log("Including family:", family);
+ }
+ includeFamily = false;
+ }
+ },
addCategory(category) {
console.log("Adding category", category);
if (!this.tags.categories.includes(category)) {
this.gf.linter = linter;
this.tags = new Tags(this.gf);
this.tags.sortCategories();
+
+ // Subscribe to events
this.$root.$on("remove-tag", this.removeTag);
}
});