mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-02 04:39:54 -05:00
add to shopping from meal plan editor
This commit is contained in:
@@ -130,6 +130,8 @@ function loadRecipes() {
|
||||
keyword.value = r.results[0]
|
||||
requestParameters.keywords = [keyword.value.id!]
|
||||
doRecipeRequest(requestParameters)
|
||||
} else {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
return;
|
||||
|
||||
@@ -178,8 +178,10 @@
|
||||
{{ r.recipeName }}
|
||||
</span>
|
||||
<template #append>
|
||||
|
||||
<v-btn icon="$delete" color="delete"></v-btn>
|
||||
<v-btn icon color="delete">
|
||||
<v-icon icon="$delete"></v-icon>
|
||||
<delete-confirm-dialog :object-name="r.recipeName" :model-name="$t('ShoppingListRecipe')" @delete="deleteListRecipe(r)"></delete-confirm-dialog>
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
@@ -211,7 +213,7 @@
|
||||
|
||||
import {computed, onMounted, ref} from "vue";
|
||||
import {useShoppingStore} from "@/stores/ShoppingStore";
|
||||
import {ApiApi, Food, IngredientString, ResponseError, ShoppingListEntry, ShoppingListRecipe, Supermarket, Unit} from "@/openapi";
|
||||
import {ApiApi, IngredientString, ResponseError, ShoppingListEntry, ShoppingListRecipe, Supermarket} from "@/openapi";
|
||||
import {ErrorMessageType, PreparedMessage, useMessageStore} from "@/stores/MessageStore";
|
||||
import ShoppingLineItem from "@/components/display/ShoppingLineItem.vue";
|
||||
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore";
|
||||
@@ -221,6 +223,7 @@ import {IShoppingListCategory, IShoppingListFood, ShoppingGroupingOptions} from
|
||||
import {useI18n} from "vue-i18n";
|
||||
import NumberScalerDialog from "@/components/inputs/NumberScalerDialog.vue";
|
||||
import SupermarketEditor from "@/components/model_editors/SupermarketEditor.vue";
|
||||
import DeleteConfirmDialog from "@/components/dialogs/DeleteConfirmDialog.vue";
|
||||
|
||||
const {t} = useI18n()
|
||||
|
||||
@@ -340,6 +343,20 @@ function autoSyncLoop() {
|
||||
}, timeout)
|
||||
}
|
||||
|
||||
/**
|
||||
* delete shopping list recipe
|
||||
*/
|
||||
function deleteListRecipe(slr: ShoppingListRecipe){
|
||||
let api = new ApiApi()
|
||||
|
||||
api.apiShoppingListRecipeDestroy({id: slr.id!}).then(r => {
|
||||
useShoppingStore().refreshFromAPI()
|
||||
useMessageStore().addPreparedMessage(PreparedMessage.DELETE_SUCCESS)
|
||||
}).catch(err => {
|
||||
useMessageStore().addError(ErrorMessageType.DELETE_ERROR, err)
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -37,19 +37,24 @@
|
||||
</v-col>
|
||||
<v-col cols="12" md="6">
|
||||
<ModelSelect model="Recipe" v-model="editingObj.recipe"
|
||||
@update:modelValue="editingObj.servings = editingObj.recipe?.servings ? editingObj.recipe?.servings : 1"></ModelSelect>
|
||||
@update:modelValue="editingObj.servings = editingObj.recipe ? editingObj.recipe.servings : 1"></ModelSelect>
|
||||
<!-- <v-number-input label="Days" control-variant="split" :min="1"></v-number-input>-->
|
||||
<!--TODO create days input with +/- synced to date -->
|
||||
<recipe-card :recipe="editingObj.recipe" v-if="editingObj && editingObj.recipe"></recipe-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-textarea :label="$t('Note')" v-model="editingObj.note"></v-textarea>
|
||||
<v-row dense>
|
||||
<v-col cols="12" md="6">
|
||||
<v-textarea :label="$t('Note')" v-model="editingObj.note" rows="3"></v-textarea>
|
||||
</v-col>
|
||||
<v-col cols="12" md="6" v-if="!isUpdate()">
|
||||
<v-checkbox :label="$t('AddToShopping')" v-model="editingObj.addshopping" hide-details></v-checkbox>
|
||||
<!-- <v-checkbox :label="$t('review_shopping')" v-model="addToShopping" hide-details></v-checkbox>-->
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
|
||||
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
</model-editor-base>
|
||||
@@ -109,6 +114,8 @@ onMounted(() => {
|
||||
editingObj.value.servings = 1
|
||||
editingObj.value.mealType = defaultMealType
|
||||
|
||||
editingObj.value.addshopping = !!useUserPreferenceStore().userSettings.mealplanAutoaddShopping
|
||||
|
||||
applyItemDefaults(props.itemDefaults)
|
||||
|
||||
initializeDateRange()
|
||||
|
||||
Reference in New Issue
Block a user