mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
merge category and tag selector
This commit is contained in:
parent
ab81061cba
commit
a2382e5b32
5 changed files with 24 additions and 91 deletions
File diff suppressed because one or more lines are too long
|
@ -19,7 +19,7 @@
|
||||||
v-model="page.name"
|
v-model="page.name"
|
||||||
label="Page Name"
|
label="Page Name"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<CategorySelector
|
<CategoryTagSelector
|
||||||
v-model="page.categories"
|
v-model="page.categories"
|
||||||
ref="categoryFormSelector"
|
ref="categoryFormSelector"
|
||||||
@mounted="catMounted = true"
|
@mounted="catMounted = true"
|
||||||
|
@ -43,10 +43,10 @@
|
||||||
<script>
|
<script>
|
||||||
const NEW_PAGE_EVENT = "refresh-page";
|
const NEW_PAGE_EVENT = "refresh-page";
|
||||||
import { api } from "@/api";
|
import { api } from "@/api";
|
||||||
import CategorySelector from "@/components/FormHelpers/CategorySelector";
|
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
CategorySelector,
|
CategoryTagSelector,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<v-select
|
<v-select
|
||||||
:items="allCategories"
|
:items="activeItems"
|
||||||
v-model="selected"
|
v-model="selected"
|
||||||
label="Categories"
|
:label="inputLabel"
|
||||||
chips
|
chips
|
||||||
deletable-chips
|
deletable-chips
|
||||||
:dense="dense"
|
:dense="dense"
|
||||||
|
@ -43,6 +43,9 @@ export default {
|
||||||
returnObject: {
|
returnObject: {
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
tagSelector: {
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -54,9 +57,18 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
inputLabel() {
|
||||||
|
return this.tagSelector ? "Tags" : "Categories";
|
||||||
|
},
|
||||||
|
activeItems() {
|
||||||
|
return this.tagSelector ? this.allTags : this.allCategories;
|
||||||
|
},
|
||||||
allCategories() {
|
allCategories() {
|
||||||
return this.$store.getters.getAllCategories;
|
return this.$store.getters.getAllCategories;
|
||||||
},
|
},
|
||||||
|
allTags() {
|
||||||
|
return this.$store.getters.getAllTags;
|
||||||
|
},
|
||||||
flat() {
|
flat() {
|
||||||
return this.selected.length > 0 && this.solo;
|
return this.selected.length > 0 && this.solo;
|
||||||
},
|
},
|
|
@ -1,79 +0,0 @@
|
||||||
<template>
|
|
||||||
<v-select
|
|
||||||
:items="allTags"
|
|
||||||
v-model="selected"
|
|
||||||
label="Tags"
|
|
||||||
chips
|
|
||||||
deletable-chips
|
|
||||||
:dense="dense"
|
|
||||||
:solo="solo"
|
|
||||||
:flat="flat"
|
|
||||||
item-text="name"
|
|
||||||
multiple
|
|
||||||
:return-object="returnObject"
|
|
||||||
@input="emitChange"
|
|
||||||
>
|
|
||||||
<template v-slot:selection="data">
|
|
||||||
<v-chip
|
|
||||||
class="ma-1"
|
|
||||||
:input-value="data.selected"
|
|
||||||
close
|
|
||||||
@click:close="removeByIndex(data.index)"
|
|
||||||
label
|
|
||||||
color="accent"
|
|
||||||
dark
|
|
||||||
>
|
|
||||||
{{ data.item.name }}
|
|
||||||
</v-chip>
|
|
||||||
</template>
|
|
||||||
</v-select>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const MOUNTED_EVENT = "mounted";
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
value: Array,
|
|
||||||
solo: {
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
dense: {
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
returnObject: {
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
selected: [],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$emit(MOUNTED_EVENT);
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
allTags() {
|
|
||||||
return this.$store.getters.getAllTags;
|
|
||||||
},
|
|
||||||
flat() {
|
|
||||||
return this.selected.length > 0 && this.solo;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
emitChange() {
|
|
||||||
this.$emit("input", this.selected);
|
|
||||||
},
|
|
||||||
setInit(val) {
|
|
||||||
this.selected = val;
|
|
||||||
},
|
|
||||||
removeByIndex(index) {
|
|
||||||
this.selected.splice(index, 1);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
</style>
|
|
|
@ -28,7 +28,7 @@
|
||||||
<v-col>
|
<v-col>
|
||||||
<h3 class="pl-2 text-center headline">Category Filter</h3>
|
<h3 class="pl-2 text-center headline">Category Filter</h3>
|
||||||
<FilterSelector class="mb-1" @update="updateCatParams" />
|
<FilterSelector class="mb-1" @update="updateCatParams" />
|
||||||
<CategorySelector
|
<CategoryTagSelector
|
||||||
:solo="true"
|
:solo="true"
|
||||||
:dense="false"
|
:dense="false"
|
||||||
v-model="includeCategories"
|
v-model="includeCategories"
|
||||||
|
@ -38,11 +38,13 @@
|
||||||
<v-col>
|
<v-col>
|
||||||
<h3 class="pl-2 text-center headline">Tag Filter</h3>
|
<h3 class="pl-2 text-center headline">Tag Filter</h3>
|
||||||
<FilterSelector class="mb-1" @update="updateTagParams" />
|
<FilterSelector class="mb-1" @update="updateTagParams" />
|
||||||
<TagSelector
|
|
||||||
|
<CategoryTagSelector
|
||||||
:solo="true"
|
:solo="true"
|
||||||
:dense="false"
|
:dense="false"
|
||||||
v-model="includeTags"
|
v-model="includeTags"
|
||||||
:return-object="false"
|
:return-object="false"
|
||||||
|
:tag-selector="true"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
@ -74,16 +76,14 @@
|
||||||
import Fuse from "fuse.js";
|
import Fuse from "fuse.js";
|
||||||
import RecipeCard from "@/components/Recipe/RecipeCard";
|
import RecipeCard from "@/components/Recipe/RecipeCard";
|
||||||
import CategorySidebar from "@/components/UI/CategorySidebar";
|
import CategorySidebar from "@/components/UI/CategorySidebar";
|
||||||
import CategorySelector from "@/components/FormHelpers/CategorySelector";
|
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||||
import TagSelector from "@/components/FormHelpers/TagSelector";
|
|
||||||
import FilterSelector from "./FilterSelector.vue";
|
import FilterSelector from "./FilterSelector.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
RecipeCard,
|
RecipeCard,
|
||||||
CategorySidebar,
|
CategorySidebar,
|
||||||
CategorySelector,
|
CategoryTagSelector,
|
||||||
TagSelector,
|
|
||||||
FilterSelector,
|
FilterSelector,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue