mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
lint notes
This commit is contained in:
parent
5f8545a146
commit
f76a0c2288
1 changed files with 21 additions and 37 deletions
|
@ -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: () => [],
|
|
||||||
},
|
|
||||||
|
|
||||||
edit: {
|
defineProps({
|
||||||
type: Boolean,
|
edit: {
|
||||||
default: true,
|
type: Boolean,
|
||||||
},
|
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>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue