mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
fix category auto-completes
This commit is contained in:
parent
9f84e0923b
commit
096fb86761
3 changed files with 32 additions and 11 deletions
|
@ -120,17 +120,19 @@
|
||||||
deletable-chips
|
deletable-chips
|
||||||
v-model="value.recipeCategory"
|
v-model="value.recipeCategory"
|
||||||
hide-selected
|
hide-selected
|
||||||
:items="categories"
|
:items="allCategories"
|
||||||
text="name"
|
text="name"
|
||||||
:search-input.sync="categoriesSearchInput"
|
:search-input.sync="categoriesSearchInput"
|
||||||
@change="categoriesSearchInput = ''"
|
@change="categoriesSearchInput = ''"
|
||||||
>
|
>
|
||||||
<template v-slot:selection="data">
|
<template v-slot:selection="data">
|
||||||
<v-chip
|
<v-chip
|
||||||
|
class="ma-1"
|
||||||
:input-value="data.selected"
|
:input-value="data.selected"
|
||||||
close
|
close
|
||||||
@click:close="removeCategory(data.index)"
|
@click:close="removeCategory(data.index)"
|
||||||
color="secondary"
|
label
|
||||||
|
color="accent"
|
||||||
dark
|
dark
|
||||||
>
|
>
|
||||||
{{ data.item }}
|
{{ data.item }}
|
||||||
|
@ -152,10 +154,12 @@
|
||||||
>
|
>
|
||||||
<template v-slot:selection="data">
|
<template v-slot:selection="data">
|
||||||
<v-chip
|
<v-chip
|
||||||
|
class="ma-1"
|
||||||
:input-value="data.selected"
|
:input-value="data.selected"
|
||||||
close
|
close
|
||||||
|
label
|
||||||
@click:close="removeTags(data.index)"
|
@click:close="removeTags(data.index)"
|
||||||
color="secondary"
|
color="accent"
|
||||||
dark
|
dark
|
||||||
>
|
>
|
||||||
{{ data.item }}
|
{{ data.item }}
|
||||||
|
@ -221,7 +225,7 @@
|
||||||
elevation="0"
|
elevation="0"
|
||||||
@click="removeStep(index)"
|
@click="removeStep(index)"
|
||||||
>
|
>
|
||||||
<v-icon color="error">mdi-delete</v-icon>
|
<v-icon size="24" color="error">mdi-delete</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
{{ $t("recipe.step-index", { step: index + 1 }) }}
|
{{ $t("recipe.step-index", { step: index + 1 }) }}
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
@ -284,14 +288,13 @@ export default {
|
||||||
tags: [],
|
tags: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
computed: {
|
||||||
this.getCategories();
|
allCategories() {
|
||||||
|
const categories = this.$store.getters.getAllCategories;
|
||||||
|
return categories.map(cat => cat.name);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async getCategories() {
|
|
||||||
let response = await api.categories.get_all();
|
|
||||||
this.categories = response.map(cat => cat.name);
|
|
||||||
},
|
|
||||||
uploadImage() {
|
uploadImage() {
|
||||||
this.$emit("upload", this.fileObject);
|
this.$emit("upload", this.fileObject);
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
<div v-if="items && items.length > 0">
|
<div v-if="items && items.length > 0">
|
||||||
<h2 class="mt-4">{{ title }}</h2>
|
<h2 class="mt-4">{{ title }}</h2>
|
||||||
<v-chip
|
<v-chip
|
||||||
|
:to="`/recipes/${getSlug(category)}`"
|
||||||
|
label
|
||||||
class="ma-1"
|
class="ma-1"
|
||||||
color="accent"
|
color="accent"
|
||||||
dark
|
dark
|
||||||
|
@ -18,6 +20,21 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
items: Array,
|
items: Array,
|
||||||
title: String,
|
title: String,
|
||||||
|
category: {
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
allCategories() {
|
||||||
|
return this.$store.getters.getAllCategories;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getSlug(name) {
|
||||||
|
if (this.category) {
|
||||||
|
return this.allCategories.filter(x => x.name == name)[0].slug;
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -65,7 +65,8 @@ const store = new Vuex.Store({
|
||||||
getters: {
|
getters: {
|
||||||
getRecentRecipes: state => state.recentRecipes,
|
getRecentRecipes: state => state.recentRecipes,
|
||||||
getMealPlanCategories: state => state.mealPlanCategories,
|
getMealPlanCategories: state => state.mealPlanCategories,
|
||||||
getAllCategories: state => state.allCategories,
|
getAllCategories: state =>
|
||||||
|
state.allCategories.sort((a, b) => (a.slug > b.slug ? 1 : -1)),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue