export default {
- schema: {
- categories: ["a", "b", "c"],
- lowTag: {
- filters: [],
- score: 10
- },
- highTag: {
- filters: [],
- score: 100
- }
- },
+// 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: [],
+ lowTag: {
+ filters: [],
+ score: 0
+ },
+ highTag: {
+ filters: [],
+ score: 0
+ },
+ currentLowAxis: "",
+ currentLowPosition: 0,
+ currentLowOp: "",
+ currentLowScore: 0,
+ currentHighAxis: "",
+ currentHighPosition: 0,
+ currentHighOp: "",
+ currentHighScore: 0,
}
},
methods: {
addFilter() {
- this.filters.push(
+ this.lowTag.filters.push(
+ {
+ axis: this.currentLowAxis,
+ op: this.currentLowOp,
+ value: this.currentLowPosition,
+ score: this.currentLowScore
+ }
+ );
+ this.highTag.filters.push(
{
- axis: this.currentAxis,
- op: this.currentOp,
- value: this.currentPosition,
- score: this.currentScore
+ axis: this.currentHighAxis,
+ op: this.currentHighOp,
+ value: this.currentHighPosition,
+ score: this.currentHighScore
}
- )
+ );
+ this.currentLowAxis = "";
+ this.currentLowPosition = 0;
+ this.currentLowOp = "";
+ this.currentHighAxis = "";
+ this.currentHighPosition = 0;
+ this.currentHighOp = "";
},
addTags() {
const filterSet = {
categories: this.currentCategories,
- filters: this.filters
+ lowTag: this.lowTag,
+ highTag: this.highTag
};
+ filterSet.lowTag.score = this.currentLowScore;
+ filterSet.highTag.score = this.currentHighScore;
this.$emit('tags-added', filterSet);
- this.filters = [];
+ this.currentCategories = [];
+ this.lowTag = { filters: [], score: 0 };
+ this.highTag = { filters: [], score: 0 };
+ this.currentLowAxis = "";
+ this.currentLowPosition = 0;
+ this.currentLowOp = "";
+ this.currentLowScore = 0;
+ this.currentHighAxis = "";
+ this.currentHighPosition = 0;
+ this.currentHighOp = "";
+ this.currentHighScore = 0;
}
},
template: `
<div>
<h3>Add Tags</h3>
- <h3>Category</h3>
+ <div>
+ <h3>Categories</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">
+ <h3>Low Tag:</h3>
+ Score:
+ <input type="number" v-model="currentLowScore" placeholder="Score" />
+ <br>
+ <input type="text" v-model="currentLowAxis" placeholder="Axis name" />
+ <input type="number" v-model="currentLowPosition" placeholder="Position" />
+ <select v-model="currentLowOp">
+ <option value="<="><=</option>
+ <option value=">=">>=</option>
+ <option value="=">=</option>
+ </select>
+
+ <h3>High Tag:</h3>
+ Score:
+ <input type="number" v-model="currentHighScore" placeholder="Score" />
+ <br>
+ <input type="text" v-model="currentHighAxis" placeholder="Axis name" />
+ <input type="number" v-model="currentHighPosition" placeholder="Position" />
+ <select v-model="currentHighOp">
<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>
+ <h3>Low Tag</h3>
+ <ul>
+ <li v-for="filter in lowTag.filters" :key="filter.axis + filter.value">
+ {{ filter.axis }} {{ filter.op }} {{ filter.value }}
+ <button @click="lowTag.filters.splice(lowTag.filters.indexOf(filter), 1)">Remove</button>
+ </li>
+ </ul>
+ <h3>High Tag</h3>
<ul>
- <li v-for="filter in filters" :key="filter.axis + filter.value">
+ <li v-for="filter in highTag.filters" :key="filter.axis + filter.value">
{{ filter.axis }} {{ filter.op }} {{ filter.value }}
- <button @click="filters.splice(filters.indexOf(filter), 1)">Remove</button>
+ <button @click="highTag.filters.splice(highTag.filters.indexOf(filter), 1)">Remove</button>
</li>
</ul>
</div>
</div>
</div>
<script type="module">
- import { GF, Tags } from './models.js';
+ import { GF, Tags, FontTag } from './models.js';
import TagsByFont from "./TagsByFont.js";
import TagsByCategories from "./TagsByCategories.js";
import Panel from "./Panel.js";
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;
- }
+ for (let family of this.gf.families) {
+ let addFamily = false;
+ for (let axis of family.axes) {
+ if (
+ filterSet.lowTag.filters.some(f => f.axis == axis.tag) &&
+ filterSet.highTag.filters.some(f => f.axis == axis.tag) &&
+ filterSet.lowTag.filters.some(f => f.value >= axis.min) &&
+ filterSet.highTag.filters.some(f => f.value <= axis.max)
+ ) {
+ addFamily = true;
}
- if (includeFamily) {
- console.log("Including family:", family);
+ }
+ if (addFamily) {
+ for (let category of filterSet.categories) {
+ const lowTag = new FontTag(category, family, filterSet.lowTag.filters, filterSet.lowTag.score);
+ const highTag = new FontTag(category, family, filterSet.highTag.filters, filterSet.highTag.score);
+ console.log(lowTag, highTag, "tt");
+ this.tags.items.push(lowTag);
+ this.tags.items.push(highTag);
}
- includeFamily = false;
}
+ }
},
addCategory(category) {
console.log("Adding category", category);