2021-07-31 15:07:19 -08:00
|
|
|
<template>
|
2025-06-20 00:09:12 +07:00
|
|
|
<div
|
|
|
|
v-if="model.length > 0 || edit"
|
|
|
|
class="mt-8"
|
|
|
|
>
|
|
|
|
<h2 class="my-4 text-h5 font-weight-medium opacity-80">
|
|
|
|
{{ $t("recipe.note") }}
|
|
|
|
</h2>
|
|
|
|
<div
|
|
|
|
v-for="(note, index) in model"
|
|
|
|
:id="'note' + index"
|
|
|
|
:key="'note' + index"
|
|
|
|
class="mt-1"
|
|
|
|
>
|
2022-05-11 17:14:03 -08:00
|
|
|
<v-card v-if="edit">
|
2021-07-31 15:07:19 -08:00
|
|
|
<v-card-text>
|
2022-05-11 17:14:03 -08:00
|
|
|
<div class="d-flex align-center">
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-text-field
|
|
|
|
v-model="model[index]['title']"
|
|
|
|
variant="underlined"
|
|
|
|
:label="$t('recipe.title')"
|
|
|
|
/>
|
|
|
|
<v-btn
|
|
|
|
icon
|
|
|
|
class="mr-2"
|
|
|
|
elevation="0"
|
|
|
|
@click="removeByIndex(index)"
|
|
|
|
>
|
2022-05-11 17:14:03 -08:00
|
|
|
<v-icon>{{ $globals.icons.delete }}</v-icon>
|
2021-07-31 15:07:19 -08:00
|
|
|
</v-btn>
|
2022-05-11 17:14:03 -08:00
|
|
|
</div>
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-textarea
|
|
|
|
v-model="model[index]['text']"
|
|
|
|
variant="underlined"
|
|
|
|
auto-grow
|
|
|
|
:placeholder="$t('recipe.note')"
|
|
|
|
/>
|
2021-07-31 15:07:19 -08:00
|
|
|
</v-card-text>
|
2022-05-11 17:14:03 -08:00
|
|
|
</v-card>
|
2021-07-31 15:07:19 -08:00
|
|
|
<div v-else>
|
2022-05-11 17:14:03 -08:00
|
|
|
<v-card-title class="text-subtitle-1 font-weight-medium py-1">
|
2021-07-31 15:07:19 -08:00
|
|
|
{{ note.title }}
|
|
|
|
</v-card-title>
|
|
|
|
<v-card-text>
|
2022-07-31 13:10:20 -08:00
|
|
|
<SafeMarkdown :source="note.text" />
|
2021-07-31 15:07:19 -08:00
|
|
|
</v-card-text>
|
|
|
|
</div>
|
2022-05-11 17:14:03 -08:00
|
|
|
</div>
|
2021-07-31 15:07:19 -08:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
<div
|
|
|
|
v-if="edit"
|
|
|
|
class="d-flex justify-end"
|
|
|
|
>
|
|
|
|
<BaseButton
|
|
|
|
class="ml-auto my-2"
|
|
|
|
@click="addNote"
|
|
|
|
>
|
|
|
|
{{ $t("general.add") }}
|
|
|
|
</BaseButton>
|
2021-07-31 15:07:19 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { RecipeNote } from "~/lib/api/types/recipe";
|
2022-01-09 07:15:23 +01:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
const model = defineModel<RecipeNote[]>({ default: () => [] });
|
2021-07-31 15:07:19 -08:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
defineProps({
|
|
|
|
edit: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
2021-07-31 15:07:19 -08:00
|
|
|
},
|
2025-06-20 00:09:12 +07:00
|
|
|
});
|
2022-01-09 07:15:23 +01:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
function addNote() {
|
|
|
|
model.value = [...model.value, { title: "", text: "" }];
|
|
|
|
}
|
2022-01-09 07:15:23 +01:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
function removeByIndex(index: number) {
|
|
|
|
const newNotes = [...model.value];
|
|
|
|
newNotes.splice(index, 1);
|
|
|
|
model.value = newNotes;
|
|
|
|
}
|
2021-07-31 15:07:19 -08:00
|
|
|
</script>
|