mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-08 07:38:26 -05:00
made ModelEditor setupState function properly handle async requests
This commit is contained in:
@@ -49,11 +49,10 @@ const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading,
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
setupState(props.item, props.itemId, () => {
|
||||
editingObj.value.expires = DateTime.now().plus({year: 1}).toJSDate()
|
||||
editingObj.value.scope = 'read write'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -36,6 +36,7 @@ import ModelEditorBase from "@/components/model_editors/ModelEditorBase.vue";
|
||||
import {useModelEditorFunctions} from "@/composables/useModelEditorFunctions";
|
||||
import {useI18n} from "vue-i18n";
|
||||
import {VNumberInput} from "vuetify/labs/VNumberInput";
|
||||
import {DateTime} from "luxon";
|
||||
|
||||
const {t} = useI18n()
|
||||
|
||||
@@ -64,10 +65,9 @@ const AUTOMATION_TYPES = [
|
||||
]
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
setupState(props.item, props.itemId, () => {
|
||||
editingObj.value.order = 0
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -189,11 +189,10 @@ const stopConversionsWatcher = watch(tab, (value, oldValue, onCleanup) => {
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
setupState(props.item, props.itemId, () => {
|
||||
editingObj.value.propertiesFoodAmount = 100
|
||||
editingObj.value.propertiesFoodUnit = {name: 'g'} as Unit // TODO properly fetch default unit
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -50,11 +50,11 @@ onMounted(() => {
|
||||
api.apiGroupList().then(r => {
|
||||
groups.value = r
|
||||
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
setupState(props.item, props.itemId, () => {
|
||||
editingObj.value.validUntil = DateTime.now().plus({month: 1}).toJSDate()
|
||||
editingObj.value.group = groups.value[0]
|
||||
}
|
||||
})
|
||||
|
||||
}).catch(err => {
|
||||
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
|
||||
})
|
||||
|
||||
@@ -27,6 +27,7 @@ import {Keyword} from "@/openapi";
|
||||
import ModelEditorBase from "@/components/model_editors/ModelEditorBase.vue";
|
||||
import {useModelEditorFunctions} from "@/composables/useModelEditorFunctions";
|
||||
import {useI18n} from "vue-i18n";
|
||||
import {DateTime} from "luxon";
|
||||
|
||||
const {t} = useI18n()
|
||||
|
||||
@@ -42,10 +43,7 @@ const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading,
|
||||
// object specific data (for selects/display)
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
|
||||
}
|
||||
setupState(props.item, props.itemId)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -43,6 +43,7 @@ import {MealType} from "@/openapi";
|
||||
import {VTimePicker} from 'vuetify/labs/VTimePicker'; // TODO remove once out of labs
|
||||
import ModelEditorBase from "@/components/model_editors/ModelEditorBase.vue";
|
||||
import {useModelEditorFunctions} from "@/composables/useModelEditorFunctions";
|
||||
import {DateTime} from "luxon";
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
@@ -59,9 +60,7 @@ const timePickerMenu = ref(false)
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
}
|
||||
setupState(props.item, props.itemId)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -45,9 +45,7 @@ const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading,
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
}
|
||||
setupState(props.item, props.itemId)
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -44,10 +44,7 @@ const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading,
|
||||
// object specific data (for selects/display)
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
|
||||
}
|
||||
setupState(props.item, props.itemId)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -42,10 +42,7 @@ const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading,
|
||||
// object specific data (for selects/display)
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
|
||||
}
|
||||
setupState(props.item, props.itemId)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -119,16 +119,13 @@ const unusedSupermarketCategories = computed(() => {
|
||||
onMounted(() => {
|
||||
const api = new ApiApi()
|
||||
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
}
|
||||
|
||||
api.apiSupermarketCategoryList({pageSize: 100}).then(r => {
|
||||
supermarketCategories.value = r.results
|
||||
|
||||
//TODO fix performing this in a way that async setupState works
|
||||
editingObj.value.categoryToSupermarket.forEach(cTS => {
|
||||
editingObjSupermarketCategories.value.push(cTS.category)
|
||||
|
||||
setupState(props.item, props.itemId, undefined, () => {
|
||||
editingObj.value.categoryToSupermarket.forEach(cTS => {
|
||||
editingObjSupermarketCategories.value.push(cTS.category)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -65,9 +65,7 @@ const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading,
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
}
|
||||
setupState(props.item, props.itemId)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -67,10 +67,7 @@ const BASE_UNITS = [
|
||||
]
|
||||
|
||||
onMounted(() => {
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
|
||||
}
|
||||
setupState(props.item, props.itemId)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -48,9 +48,7 @@ onMounted(() => {
|
||||
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
|
||||
})
|
||||
|
||||
if (!setupState(props.item, props.itemId)) {
|
||||
// functions to populate defaults
|
||||
}
|
||||
setupState(props.item, props.itemId)
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user