mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-23 06:45:22 -07:00
RecipeSettingsSwitches use v-model instead of prop and turn into script setup
This commit is contained in:
parent
eadef68002
commit
4ce1f5c926
1 changed files with 18 additions and 30 deletions
|
@ -1,9 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<v-switch
|
<v-switch
|
||||||
v-for="(_, key) in modelValue"
|
v-for="(_, key) in model"
|
||||||
:key="key"
|
:key="key"
|
||||||
v-model="modelValue[key]"
|
v-model="model[key]"
|
||||||
color="primary"
|
color="primary"
|
||||||
xs
|
xs
|
||||||
density="compact"
|
density="compact"
|
||||||
|
@ -15,37 +15,25 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
|
import { defineModel, defineProps } from "vue";
|
||||||
import type { RecipeSettings } from "~/lib/api/types/recipe";
|
import type { RecipeSettings } from "~/lib/api/types/recipe";
|
||||||
|
import { useI18n } from "#imports";
|
||||||
|
|
||||||
export default defineNuxtComponent({
|
defineProps<{ isOwner?: boolean }>();
|
||||||
props: {
|
|
||||||
modelValue: {
|
|
||||||
type: Object as () => RecipeSettings,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
isOwner: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const i18n = useI18n();
|
|
||||||
const labels: Record<keyof RecipeSettings, string> = {
|
|
||||||
public: i18n.t("recipe.public-recipe"),
|
|
||||||
showNutrition: i18n.t("recipe.show-nutrition-values"),
|
|
||||||
showAssets: i18n.t("asset.show-assets"),
|
|
||||||
landscapeView: i18n.t("recipe.landscape-view-coming-soon"),
|
|
||||||
disableComments: i18n.t("recipe.disable-comments"),
|
|
||||||
disableAmount: i18n.t("recipe.disable-amount"),
|
|
||||||
locked: i18n.t("recipe.locked"),
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
const model = defineModel<RecipeSettings>({ required: true });
|
||||||
labels,
|
|
||||||
};
|
const i18n = useI18n();
|
||||||
},
|
const labels: Record<keyof RecipeSettings, string> = {
|
||||||
});
|
public: i18n.t("recipe.public-recipe"),
|
||||||
|
showNutrition: i18n.t("recipe.show-nutrition-values"),
|
||||||
|
showAssets: i18n.t("asset.show-assets"),
|
||||||
|
landscapeView: i18n.t("recipe.landscape-view-coming-soon"),
|
||||||
|
disableComments: i18n.t("recipe.disable-comments"),
|
||||||
|
disableAmount: i18n.t("recipe.disable-amount"),
|
||||||
|
locked: i18n.t("recipe.locked"),
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue