Skip to content

Commit

Permalink
recipe editor
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Dec 5, 2024
1 parent 35461ba commit 01d5214
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
4 changes: 2 additions & 2 deletions vue3/src/components/dialogs/VClosableCardTitle.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<template>
<v-card-title class="pb-0">
<v-row align="center" >
<v-col cols="11" class="text-truncate">
<v-col cols="10" md="11" class="text-truncate">
<i :class="props.icon" v-if="props.icon != ''"></i>
{{ props.title }}
<v-card-subtitle class="pa-0" v-if="props.subTitle != ''">{{ props.subTitle}}</v-card-subtitle>
</v-col>
<v-col cols="1" v-if="!props.hideClose">
<v-col cols="2" md="1" v-if="!props.hideClose">
<v-btn class="float-right pr-2" icon="$close" variant="plain" @click="model = false; emit('close')"></v-btn>
</v-col>
</v-row>
Expand Down
9 changes: 3 additions & 6 deletions vue3/src/components/inputs/RecipeContextMenu.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>

<v-menu open-on-hover open-delay="0" :open-on-click="true" location="start">
<v-menu location="start">
<template v-slot:activator="{ props }">
<v-btn v-bind="props" icon="fas fa-ellipsis-v" variant="plain"></v-btn>
</template>

<v-list>
<v-list-item>
<v-list-item-title @click="openRecipe()"><i class="fas fa-edit fa-fw mr-2"></i> Edit</v-list-item-title>
<v-list-item :to="{ name: 'ModelEditPage', params: {model: 'recipe', id: recipe.id} }" prepend-icon="fas fa-edit">
{{$t('Edit')}}
</v-list-item>
</v-list>
</v-menu>
Expand All @@ -24,9 +24,6 @@ const props = defineProps({
recipe: {type: Object as PropType<Recipe | RecipeFlat | RecipeOverview>, required: true}
})
function openRecipe() {
router.push({name: 'edit_recipe', params: {recipe_id: props.recipe.id}})
}
</script>


Expand Down
10 changes: 6 additions & 4 deletions vue3/src/components/inputs/StepEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@
</v-col>
</v-row>
</vue-draggable>
<v-btn color="primary" @click="insertAndFocusIngredient()">{{ $t('Add') }}</v-btn>
<v-btn color="secondary" @click="dialogIngredientParser = true">{{ $t('AddMany') }}</v-btn>
<v-btn-group density="compact">
<v-btn color="success" @click="insertAndFocusIngredient()" prepend-icon="$add">{{ $t('Add') }}</v-btn>
<v-btn color="warning" @click="dialogIngredientParser = true"><v-icon icon="$add"></v-icon> <v-icon icon="$add"></v-icon></v-btn>
</v-btn-group>
</v-col>
<v-col cols="12">
<v-label>{{ $t('Instructions') }}</v-label>
Expand All @@ -94,7 +96,7 @@
:max-width="(mobile) ? '100vw': '75vw'"
:fullscreen="mobile">
<v-card>
<v-closable-card-title :title="$t('Instructions')"></v-closable-card-title>
<v-closable-card-title :title="$t('Instructions')" v-model="dialogMarkdownEdit"></v-closable-card-title>
<step-markdown-editor class="h-100" v-model="step"></step-markdown-editor>
</v-card>
</v-dialog>
Expand All @@ -104,7 +106,7 @@
:max-width="(mobile) ? '100vw': '75vw'"
:fullscreen="mobile">
<v-card>
<v-closable-card-title :title="$t('Ingredients')"></v-closable-card-title>
<v-closable-card-title :title="$t('Ingredients')" v-model="dialogIngredientParser"></v-closable-card-title>
<v-card-text>
<v-textarea v-model="ingredientTextInput"></v-textarea>
</v-card-text>
Expand Down
37 changes: 37 additions & 0 deletions vue3/src/components/model_editors/RecipeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@
<step-editor v-model="editingObj.steps[i]" :step-index="i"></step-editor>
</v-col>
</v-row>
<v-row>
<v-col class="text-center">
<v-btn-group density="compact">
<v-btn color="success" prepend-icon="fa-solid fa-plus">{{ $t('Add_Step') }}</v-btn>
<v-btn color="warning" @click="dialogStepManager = true">
<v-icon icon="fa-solid fa-arrow-down-1-9"></v-icon>
</v-btn>
</v-btn-group>
</v-col>
</v-row>

</v-form>
</v-tabs-window-item>
Expand All @@ -77,6 +87,22 @@
</v-card-text>
</model-editor-base>

<v-dialog max-width="600px" v-model="dialogStepManager">
<v-card>
<v-card-title>{{ $t('Steps') }}</v-card-title>
<v-list>
<vue-draggable handle=".drag-handle" v-model="editingObj.steps" :on-sort="sortSteps">
<v-list-item v-for="(s,i) in editingObj.steps" :key="s.id">
<v-chip color="primary">{{ i + 1 }}</v-chip> {{s.name}}
<template #append>
<v-icon class="drag-handle" icon="$dragHandle"></v-icon>
</template>
</v-list-item>
</vue-draggable>
</v-list>
</v-card>
</v-dialog>

</template>

<script setup lang="ts">
Expand All @@ -88,6 +114,7 @@ import {useModelEditorFunctions} from "@/composables/useModelEditorFunctions";
import {useI18n} from "vue-i18n";
import ModelSelect from "@/components/inputs/ModelSelect.vue";
import StepEditor from "@/components/inputs/StepEditor.vue";
import {VueDraggable} from "vue-draggable-plus";
const {t} = useI18n()
Expand All @@ -102,11 +129,21 @@ const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading,
// object specific data (for selects/display)
const tab = ref("recipe")
const dialogStepManager = ref(false)
onMounted(() => {
setupState(props.item, props.itemId)
})
/**
* called by draggable in step manager dialog when steps are sorted
*/
function sortSteps(){
editingObj.value.steps.forEach((value, index) => {
value.order = index
})
}
</script>

<style scoped>
Expand Down
1 change: 1 addition & 0 deletions vue3/src/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default createVuetify({
create: 'fa-solid fa-plus',
search: 'fa-solid fa-magnifying-glass',
copy: 'fa-solid fa-copy',
add: 'fa-solid fa-plus',
close: 'fa-solid fa-xmark',
help: 'fa-solid fa-info',
settings: 'fa-solid fa-sliders',
Expand Down

0 comments on commit 01d5214

Please sign in to comment.