unifiy category selector

This commit is contained in:
hay-kot 2021-04-04 10:51:11 -08:00
commit b7da5de046
2 changed files with 22 additions and 39 deletions

View file

@ -56,6 +56,12 @@ export default {
this.$emit(MOUNTED_EVENT); this.$emit(MOUNTED_EVENT);
}, },
watch: {
value(val) {
this.selected = val;
},
},
computed: { computed: {
inputLabel() { inputLabel() {
return this.tagSelector ? "Tags" : "Categories"; return this.tagSelector ? "Tags" : "Categories";

View file

@ -7,41 +7,18 @@
<v-card-text> <v-card-text>
<h2 class="mt-1">{{ $t("recipe.categories") }}</h2> <h2 class="mt-1">{{ $t("recipe.categories") }}</h2>
<v-row> <CategoryTagSelector
<v-col sm="12" md="6"> class="mt-1"
<v-select :solo="true"
outlined :dense="false"
:flat="isFlat" v-model="groupSettings.categories"
elavation="0" :return-object="true"
v-model="groupSettings.categories" :hint="
:items="categories" $t(
item-text="name" 'meal-plan.only-recipes-with-these-categories-will-be-used-in-meal-plans'
return-object )
multiple "
chips />
:hint="
$t(
'meal-plan.only-recipes-with-these-categories-will-be-used-in-meal-plans'
)
"
class="mt-2"
persistent-hint
>
<template v-slot:selection="data">
<v-chip
outlined
:input-value="data.selected"
close
@click:close="removeCategory(data.index)"
color="secondary"
dark
>
{{ data.item.name }}
</v-chip>
</template>
</v-select>
</v-col>
</v-row>
</v-card-text> </v-card-text>
<v-divider> </v-divider> <v-divider> </v-divider>
<v-card-text> <v-card-text>
@ -59,7 +36,7 @@
<v-row dense class="flex align-center"> <v-row dense class="flex align-center">
<v-switch <v-switch
class="mx-2" class="mx-2"
v-model="groupSettings.webhookEnable" v-model="groupSettings.webhookEnable"
:label="$t('general.enabled')" :label="$t('general.enabled')"
></v-switch> ></v-switch>
@ -105,9 +82,11 @@
<script> <script>
import { api } from "@/api"; import { api } from "@/api";
import TimePickerDialog from "@/components/Admin/MealPlanner/TimePickerDialog"; import TimePickerDialog from "@/components/Admin/MealPlanner/TimePickerDialog";
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
export default { export default {
components: { components: {
TimePickerDialog, TimePickerDialog,
CategoryTagSelector,
}, },
data() { data() {
return { return {
@ -155,6 +134,7 @@ export default {
this.groupSettings.webhookUrls.splice(index, 1); this.groupSettings.webhookUrls.splice(index, 1);
}, },
async saveGroupSettings() { async saveGroupSettings() {
console.log(this.groupSettings);
await api.groups.update(this.groupSettings); await api.groups.update(this.groupSettings);
await this.$store.dispatch("requestCurrentGroup"); await this.$store.dispatch("requestCurrentGroup");
this.getSiteSettings(); this.getSiteSettings();
@ -162,9 +142,6 @@ export default {
testWebhooks() { testWebhooks() {
api.settings.testWebhooks(); api.settings.testWebhooks();
}, },
removeCategory(index) {
this.groupSettings.categories.splice(index, 1);
},
}, },
}; };
</script> </script>