Skip to content

Commit

Permalink
new recipe fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Dec 19, 2024
1 parent 3e37800 commit 0399763
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion vue3/src/apps/tandoor/Tandoor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<v-icon icon="$add"></v-icon>
<v-menu activator="parent">
<v-list>
<v-list-item prepend-icon="$add" :to="{ name: 'ModelEditPage', params: {model: 'Recipe'} }">{{ $t('Create Recipe') }}</v-list-item>
<v-list-item prepend-icon="$add" :to="{ name: 'ModelEditPage', params: {model: 'recipe'} }">{{ $t('Create Recipe') }}</v-list-item>
<v-list-item prepend-icon="fa-solid fa-globe" :to="{ name: 'RecipeImportPage', params: {} }">{{ $t('Import Recipe') }}</v-list-item>
</v-list>
</v-menu>
Expand Down
15 changes: 10 additions & 5 deletions vue3/src/components/model_editors/RecipeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<v-tabs-window-item value="properties">
<v-form :disabled="loading">
<v-alert class="mb-2" icon="$help">{{ $t('PropertiesFoodHelp') }}</v-alert>
<properties-editor v-model="editingObj.properties" :amount-for="$t('Serving')"></properties-editor>
<properties-editor v-model="editingObj.properties" :amount-for="$t('Serving')"></properties-editor>
</v-form>
</v-tabs-window-item>
<v-tabs-window-item value="settings">
Expand All @@ -100,7 +100,8 @@
<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}}
<v-chip color="primary">{{ i + 1 }}</v-chip>
{{ s.name }}
<template #append>
<v-icon class="drag-handle" icon="$dragHandle"></v-icon>
</template>
Expand All @@ -115,7 +116,7 @@
<script setup lang="ts">
import {onMounted, PropType, ref} from "vue";
import {Recipe} from "@/openapi";
import {Recipe, Step} from "@/openapi";
import ModelEditorBase from "@/components/model_editors/ModelEditorBase.vue";
import {useModelEditorFunctions} from "@/composables/useModelEditorFunctions";
import {useI18n} from "vue-i18n";
Expand All @@ -140,13 +141,17 @@ const tab = ref("recipe")
const dialogStepManager = ref(false)
onMounted(() => {
setupState(props.item, props.itemId)
setupState(props.item, props.itemId, {
newItemFunction: () => {
editingObj.value.steps = [] as Step[]
}
})
})
/**
* called by draggable in step manager dialog when steps are sorted
*/
function sortSteps(){
function sortSteps() {
editingObj.value.steps.forEach((value, index) => {
value.order = index
})
Expand Down
2 changes: 2 additions & 0 deletions vue3/src/composables/useModelEditorFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export function useModelEditorFunctions<T>(modelName: EditorSupportedModels, emi
editingObj.value = r
useMessageStore().addPreparedMessage(PreparedMessage.UPDATE_SUCCESS)
}).catch((err: any) => {
console.error(err)
useMessageStore().addError(ErrorMessageType.UPDATE_ERROR, err)
}).finally(() => {
loading.value = false
Expand All @@ -155,6 +156,7 @@ export function useModelEditorFunctions<T>(modelName: EditorSupportedModels, emi
editingObj.value = r
useMessageStore().addPreparedMessage(PreparedMessage.CREATE_SUCCESS)
}).catch((err: any) => {
console.error(err)
useMessageStore().addError(ErrorMessageType.CREATE_ERROR, err)
}).finally(() => {
loading.value = false
Expand Down
2 changes: 1 addition & 1 deletion vue3/src/pages/StartPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<v-card-title><i class="fa-solid fa-eye-slash"></i> {{ $t('search_no_recipes') }}</v-card-title>
<v-card-text>
<v-btn-group divided>
<v-btn size="large" color="success" prepend-icon="$create" :to="{ name: 'ModelEditPage', params: {model: 'Recipe'} }">{{ $t('Create Recipe') }}</v-btn>
<v-btn size="large" color="success" prepend-icon="$create" :to="{ name: 'ModelEditPage', params: {model: 'recipe'} }">{{ $t('Create Recipe') }}</v-btn>
<v-btn size="large" color="primary" prepend-icon="fa-solid fa-globe" :to="{ name: 'RecipeImportPage', params: {} }">{{ $t('Import Recipe') }}</v-btn>
</v-btn-group>
</v-card-text>
Expand Down
1 change: 1 addition & 0 deletions vue3/src/stores/MessageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {useStorage} from "@vueuse/core";
import {DateTime} from "luxon";
import {ResponseError} from "@/openapi";
import {useI18n} from "vue-i18n";
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore";

/** @enum {string} different message types */
export enum MessageType {
Expand Down

0 comments on commit 0399763

Please sign in to comment.