lint notes

This commit is contained in:
Kuchenpirat 2025-06-18 11:40:52 +00:00
commit f76a0c2288

View file

@ -1,13 +1,13 @@
<template> <template>
<div <div
v-if="modelValue.length > 0 || edit" v-if="model.length > 0 || edit"
class="mt-8" class="mt-8"
> >
<h2 class="my-4 text-h5 font-weight-medium opacity-80"> <h2 class="my-4 text-h5 font-weight-medium opacity-80">
{{ $t("recipe.note") }} {{ $t("recipe.note") }}
</h2> </h2>
<div <div
v-for="(note, index) in modelValue" v-for="(note, index) in model"
:id="'note' + index" :id="'note' + index"
:key="'note' + index" :key="'note' + index"
class="mt-1" class="mt-1"
@ -16,7 +16,7 @@
<v-card-text> <v-card-text>
<div class="d-flex align-center"> <div class="d-flex align-center">
<v-text-field <v-text-field
v-model="modelValue[index]['title']" v-model="model[index]['title']"
variant="underlined" variant="underlined"
:label="$t('recipe.title')" :label="$t('recipe.title')"
/> />
@ -24,13 +24,13 @@
icon icon
class="mr-2" class="mr-2"
elevation="0" elevation="0"
@click="removeByIndex(modelValue, index)" @click="removeByIndex(index)"
> >
<v-icon>{{ $globals.icons.delete }}</v-icon> <v-icon>{{ $globals.icons.delete }}</v-icon>
</v-btn> </v-btn>
</div> </div>
<v-textarea <v-textarea
v-model="modelValue[index]['text']" v-model="model[index]['text']"
variant="underlined" variant="underlined"
auto-grow auto-grow
:placeholder="$t('recipe.note')" :placeholder="$t('recipe.note')"
@ -61,41 +61,25 @@
</div> </div>
</template> </template>
<script lang="ts"> <script setup lang="ts">
import type { RecipeNote } from "~/lib/api/types/recipe"; import type { RecipeNote } from "~/lib/api/types/recipe";
export default defineNuxtComponent({ const model = defineModel<RecipeNote[]>({ default: () => [] });
props: {
modelValue: {
type: Array as () => RecipeNote[],
required: false,
default: () => [],
},
defineProps({
edit: { edit: {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
},
emits: ["update:modelValue"],
setup(props, { emit }) {
function addNote() {
const newNotes = [...props.modelValue, { title: "", text: "" }];
emit("update:modelValue", newNotes);
}
function removeByIndex(list: RecipeNote[], index: number) {
const newNotes = [...props.modelValue];
newNotes.splice(index, 1);
emit("update:modelValue", newNotes);
}
return {
addNote,
removeByIndex,
};
},
}); });
</script>
<style></style> function addNote() {
model.value = [...model.value, { title: "", text: "" }];
}
function removeByIndex(index: number) {
const newNotes = [...model.value];
newNotes.splice(index, 1);
model.value = newNotes;
}
</script>