mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-04 05:39:00 -05:00
fixed MealPlanEditor closing when changing date
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<v-dialog max-width="1400" :activator="dialogActivator" v-model="model">
|
||||
<component :is="editorComponent" :item="props.item" :item-id="props.itemId" @create="createEvent" @save="saveEvent" @delete="deleteEvent" dialog @close="model = false" :itemDefaults="props.itemDefaults"></component>
|
||||
<v-dialog max-width="1400" :activator="dialogActivator" v-model="dialog">
|
||||
<component :is="editorComponent" :item="props.item" :item-id="props.itemId" @create="createEvent" @save="saveEvent" @delete="deleteEvent" dialog @close="dialog = false; " :itemDefaults="props.itemDefaults"></component>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
@@ -30,8 +30,8 @@ const props = defineProps({
|
||||
|
||||
const editorComponent = shallowRef(defineAsyncComponent(() => import(`@/components/model_editors/${getGenericModelFromString(props.model, t).model.name}Editor.vue`)))
|
||||
|
||||
const model = defineModel<Boolean|undefined>({default: undefined})
|
||||
const dialogActivator = (model.value !== undefined) ? undefined : props.activator
|
||||
const dialog = defineModel<Boolean|undefined>({default: undefined})
|
||||
const dialogActivator = (dialog.value !== undefined) ? undefined : props.activator
|
||||
|
||||
/**
|
||||
* for some reason editorComponent is not updated automatically when prop is changed
|
||||
@@ -44,8 +44,8 @@ watch(() => props.model, () => {
|
||||
/**
|
||||
* Allow opening the model edit dialog trough v-model property of the dialog by watching for model changes
|
||||
*/
|
||||
watch(model, (value, oldValue, onCleanup) => {
|
||||
model.value = !!value
|
||||
watch(dialog, (value, oldValue, onCleanup) => {
|
||||
dialog.value = !!value
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ watch(model, (value, oldValue, onCleanup) => {
|
||||
*/
|
||||
function createEvent(arg: any) {
|
||||
emit('create', arg)
|
||||
model.value = model.value && !props.closeAfterCreate
|
||||
dialog.value = dialog.value && !props.closeAfterCreate
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ function createEvent(arg: any) {
|
||||
*/
|
||||
function saveEvent(arg: any) {
|
||||
emit('save', arg)
|
||||
model.value = model.value && !props.closeAfterSave
|
||||
dialog.value = dialog.value && !props.closeAfterSave
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ function saveEvent(arg: any) {
|
||||
*/
|
||||
function deleteEvent(arg: any) {
|
||||
emit('delete', arg)
|
||||
model.value = model.value && !props.closeAfterDelete
|
||||
dialog.value = dialog.value && !props.closeAfterDelete
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import {nextTick, onMounted, PropType, ref} from "vue";
|
||||
import {nextTick, onMounted, PropType, ref, toRaw} from "vue";
|
||||
import {ApiApi, MealPlan, MealType, ShoppingListRecipe} from "@/openapi";
|
||||
import ModelEditorBase from "@/components/model_editors/ModelEditorBase.vue";
|
||||
import {useModelEditorFunctions} from "@/composables/useModelEditorFunctions";
|
||||
@@ -179,6 +179,7 @@ onMounted(() => {
|
||||
editingObjChanged.value = false
|
||||
})
|
||||
}, existingItemFunction: () => {
|
||||
editingObj.value = structuredClone(toRaw(editingObj.value))
|
||||
initializeDateRange()
|
||||
loadShoppingListEntries()
|
||||
}
|
||||
@@ -200,7 +201,6 @@ function updateDate() {
|
||||
}
|
||||
} else {
|
||||
useMessageStore().addMessage(MessageType.WARNING, 'Missing Date', 7000)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,11 +227,6 @@ function initializeDateRange() {
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(date: Date) {
|
||||
console.log('called date format')
|
||||
return DateTime.fromJSDate(date).toLocaleString()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -59,7 +59,6 @@ export function useModelEditorFunctions<T>(modelName: EditorSupportedModels, emi
|
||||
function applyItemDefaults(itemDefaults: T) {
|
||||
if (Object.keys(itemDefaults).length > 0) {
|
||||
Object.keys(itemDefaults).forEach(k => {
|
||||
console.log('applying default ', k, itemDefaults[k])
|
||||
editingObj.value[k] = itemDefaults[k]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -543,6 +543,9 @@ export const TCookLog = {
|
||||
icon: 'fa-solid fa-table-list',
|
||||
|
||||
isPaginated: true,
|
||||
disableCreate: true,
|
||||
disableUpdate: true,
|
||||
disableDelete: true,
|
||||
toStringKeys: ['recipe'],
|
||||
|
||||
tableHeaders: [
|
||||
@@ -560,6 +563,9 @@ export const TViewLog = {
|
||||
icon: 'fa-solid fa-clock-rotate-left',
|
||||
|
||||
isPaginated: true,
|
||||
disableCreate: true,
|
||||
disableUpdate: true,
|
||||
disableDelete: true,
|
||||
toStringKeys: ['recipe'],
|
||||
|
||||
tableHeaders: [
|
||||
|
||||
Reference in New Issue
Block a user