mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-06 06:38:03 -05:00
Squashed commit of shoppinglist_v2
This commit is contained in:
@@ -19,8 +19,10 @@
|
||||
<!-- <span><b-button variant="link" size="sm" class="text-dark shadow-none"><i class="fas fa-chevron-down"></i></b-button></span> -->
|
||||
<model-menu />
|
||||
<span>{{ this.this_model.name }}</span>
|
||||
<span v-if="this_model.name !== 'Step'"
|
||||
><b-button variant="link" @click="startAction({ action: 'new' })"><i class="fas fa-plus-circle fa-2x"></i></b-button></span
|
||||
<span v-if="apiName !== 'Step'">
|
||||
<b-button variant="link" @click="startAction({ action: 'new' })">
|
||||
<i class="fas fa-plus-circle fa-2x"></i>
|
||||
</b-button> </span
|
||||
><!-- TODO add proper field to model config to determine if create should be available or not -->
|
||||
</h3>
|
||||
</div>
|
||||
@@ -112,6 +114,9 @@ export default {
|
||||
// TODO this is not necessarily bad but maybe there are better options to do this
|
||||
return () => import(/* webpackChunkName: "header-component" */ `@/components/${this.header_component_name}`)
|
||||
},
|
||||
apiName() {
|
||||
return this.this_model?.apiName
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
// value is passed from lists.py
|
||||
@@ -291,11 +296,6 @@ export default {
|
||||
this.refreshCard({ ...food }, this.items_right)
|
||||
})
|
||||
},
|
||||
addOnhand: function (item) {
|
||||
item.on_hand = true
|
||||
this.saveThis(item)
|
||||
},
|
||||
|
||||
updateThis: function (item) {
|
||||
this.refreshThis(item.id)
|
||||
},
|
||||
|
||||
@@ -49,13 +49,13 @@
|
||||
|
||||
<div class="col-md-6 mt-1">
|
||||
<label for="id_name"> {{ $t('Preparation') }} {{ $t('Time') }} ({{ $t('min') }})</label>
|
||||
<input class="form-control" id="id_prep_time" v-model="recipe.working_time">
|
||||
<input class="form-control" id="id_prep_time" v-model="recipe.working_time" type="number">
|
||||
<br/>
|
||||
<label for="id_name"> {{ $t('Waiting') }} {{ $t('Time') }} ({{ $t('min') }})</label>
|
||||
<input class="form-control" id="id_wait_time" v-model="recipe.waiting_time">
|
||||
<input class="form-control" id="id_wait_time" v-model="recipe.waiting_time" type="number">
|
||||
<br/>
|
||||
<label for="id_name"> {{ $t('Servings') }}</label>
|
||||
<input class="form-control" id="id_servings" v-model="recipe.servings">
|
||||
<input class="form-control" id="id_servings" v-model="recipe.servings" type="number">
|
||||
<br/>
|
||||
<label for="id_name"> {{ $t('Servings') }} {{ $t('Text') }}</label>
|
||||
<input class="form-control" id="id_servings_text" v-model="recipe.servings_text" maxlength="32">
|
||||
@@ -343,7 +343,7 @@
|
||||
</div>
|
||||
<div class="small-padding"
|
||||
v-bind:class="{ 'col-lg-4 col-md-6': !ingredient.is_header, 'col-lg-12 col-md-12': ingredient.is_header }">
|
||||
<input class="form-control"
|
||||
<input class="form-control" maxlength="256"
|
||||
v-model="ingredient.note"
|
||||
v-bind:placeholder="$t('Note')"
|
||||
v-on:keydown.tab="event => {if(step.ingredients.indexOf(ingredient) === (step.ingredients.length -1)){event.preventDefault();addIngredient(step)}}">
|
||||
@@ -623,9 +623,10 @@ export default {
|
||||
this.sortIngredients(s)
|
||||
}
|
||||
|
||||
if (this.recipe.waiting_time === ''){ this.recipe.waiting_time = 0}
|
||||
if (this.recipe.working_time === ''){ this.recipe.working_time = 0}
|
||||
if (this.recipe.servings === ''){ this.recipe.servings = 0}
|
||||
if (this.recipe.waiting_time === '' || isNaN(this.recipe.waiting_time)){ this.recipe.waiting_time = 0}
|
||||
if (this.recipe.working_time === ''|| isNaN(this.recipe.working_time)){ this.recipe.working_time = 0}
|
||||
if (this.recipe.servings === ''|| isNaN(this.recipe.servings)){ this.recipe.servings = 0}
|
||||
|
||||
|
||||
apiFactory.updateRecipe(this.recipe_id, this.recipe,
|
||||
{}).then((response) => {
|
||||
|
||||
@@ -306,7 +306,7 @@ export default {
|
||||
this.settings?.search_keywords?.length === 0 &&
|
||||
this.settings?.search_foods?.length === 0 &&
|
||||
this.settings?.search_books?.length === 0 &&
|
||||
this.settings?.pagination_page === 1 &&
|
||||
// this.settings?.pagination_page === 1 &&
|
||||
!this.random_search &&
|
||||
this.settings?.search_ratings === undefined
|
||||
) {
|
||||
|
||||
@@ -200,6 +200,9 @@ export default {
|
||||
ingredient_factor: function () {
|
||||
return this.servings / this.recipe.servings
|
||||
},
|
||||
title() {
|
||||
return this.recipe?.steps?.map((x) => x?.ingredients).flat()
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -212,9 +215,11 @@ export default {
|
||||
share_uid: window.SHARE_UID,
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.loadRecipe(window.RECIPE_ID)
|
||||
this.$i18n.locale = window.CUSTOM_LOCALE
|
||||
console.log(this.recipe)
|
||||
},
|
||||
methods: {
|
||||
loadRecipe: function (recipe_id) {
|
||||
|
||||
@@ -30,22 +30,24 @@
|
||||
<div class="row">
|
||||
<div class="col col-md-12">
|
||||
<div role="tablist">
|
||||
<div class="row justify-content-md-center w-75" v-if="entrymode">
|
||||
<div class="col col-md-2">
|
||||
<!-- add to shopping form -->
|
||||
<b-row class="row justify-content-md-center" v-if="entrymode">
|
||||
<b-col cols="12" sm="4" md="2">
|
||||
<b-form-input min="1" type="number" :description="$t('Amount')" v-model="new_item.amount"></b-form-input>
|
||||
</div>
|
||||
<div class="col col-md-3">
|
||||
</b-col>
|
||||
<b-col cols="12" sm="8" md="3">
|
||||
<lookup-input :form="formUnit" :model="Models.UNIT" @change="new_item.unit = $event" :show_label="false" />
|
||||
</div>
|
||||
<div class="col col-md-4">
|
||||
</b-col>
|
||||
<b-col cols="12" sm="8" md="4">
|
||||
<lookup-input :form="formFood" :model="Models.FOOD" @change="new_item.food = $event" :show_label="false" />
|
||||
</div>
|
||||
<div class="col col-md-1">
|
||||
</b-col>
|
||||
<b-col cols="12" sm="4" md="1">
|
||||
<b-button variant="link" class="px-0">
|
||||
<i class="btn fas fa-cart-plus fa-lg px-0 text-success" @click="addItem" />
|
||||
</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<!-- shopping list table -->
|
||||
<div v-if="items && items.length > 0">
|
||||
<div v-for="(done, x) in Sections" :key="x">
|
||||
<div v-if="x == 'true'">
|
||||
@@ -491,15 +493,6 @@
|
||||
</b-form-group>
|
||||
</ContextMenuItem>
|
||||
|
||||
<ContextMenuItem
|
||||
@click="
|
||||
$refs.menu.close()
|
||||
ignoreThis(contextData)
|
||||
"
|
||||
>
|
||||
<a class="dropdown-item p-2" href="#"><i class="fas fa-ban"></i> {{ $t("IgnoreThis", { food: foodName(contextData) }) }}</a>
|
||||
</ContextMenuItem>
|
||||
|
||||
<ContextMenuItem
|
||||
@click="
|
||||
$refs.menu.close()
|
||||
@@ -746,7 +739,7 @@ export default {
|
||||
} else {
|
||||
console.log("no data returned")
|
||||
}
|
||||
this.new_item = { amount: 1 }
|
||||
this.new_item = { amount: 1, unit: undefined, food: undefined }
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
@@ -906,13 +899,6 @@ export default {
|
||||
getThis: function (id) {
|
||||
return this.genericAPI(this.Models.SHOPPING_CATEGORY, this.Actions.FETCH, { id: id })
|
||||
},
|
||||
ignoreThis: function (item) {
|
||||
let food = {
|
||||
id: item?.[0]?.food.id ?? item.food.id,
|
||||
ignore_shopping: true,
|
||||
}
|
||||
this.updateFood(food, "ignore_shopping")
|
||||
},
|
||||
mergeShoppingList: function (data) {
|
||||
this.items.map((x) =>
|
||||
data.map((y) => {
|
||||
@@ -939,10 +925,10 @@ export default {
|
||||
let api = new ApiApiFactory()
|
||||
let food = {
|
||||
id: item?.[0]?.food.id ?? item?.food?.id,
|
||||
on_hand: true,
|
||||
food_onhand: true,
|
||||
}
|
||||
|
||||
this.updateFood(food)
|
||||
this.updateFood(food, "food_onhand")
|
||||
.then((result) => {
|
||||
let entries = this.items.filter((x) => x.food.id == food.id).map((x) => x.id)
|
||||
this.items = this.items.filter((x) => x.food.id !== food.id)
|
||||
@@ -1005,16 +991,18 @@ export default {
|
||||
// when checking a sub item don't refresh the screen until all entries complete but change class to cross out
|
||||
let promises = []
|
||||
update.entries.forEach((x) => {
|
||||
promises.push(this.saveThis({ id: x, checked: update.checked }, false))
|
||||
let item = this.items.filter((entry) => entry.id == x)[0]
|
||||
|
||||
Vue.set(item, "checked", update.checked)
|
||||
const id = x?.id ?? x
|
||||
let completed_at = undefined
|
||||
if (update.checked) {
|
||||
Vue.set(item, "completed_at", new Date().toISOString())
|
||||
} else {
|
||||
Vue.set(item, "completed_at", undefined)
|
||||
completed_at = new Date().toISOString()
|
||||
}
|
||||
promises.push(this.saveThis({ id: id, checked: update.checked }, false))
|
||||
|
||||
let item = this.items.filter((entry) => entry.id == id)[0]
|
||||
Vue.set(item, "checked", update.checked)
|
||||
Vue.set(item, "completed_at", completed_at)
|
||||
})
|
||||
|
||||
Promise.all(promises).catch((err) => {
|
||||
console.log(err, err.response)
|
||||
StandardToasts.makeStandardToast(StandardToasts.FAIL_UPDATE)
|
||||
@@ -1024,8 +1012,8 @@ export default {
|
||||
let api = new ApiApiFactory()
|
||||
let ignore_category
|
||||
if (field) {
|
||||
ignore_category = food.ignore_inherit
|
||||
.map((x) => food.ignore_inherit.fields)
|
||||
ignore_category = food.inherit_fields
|
||||
.map((x) => food.inherit_fields.fields)
|
||||
.flat()
|
||||
.includes(field)
|
||||
} else {
|
||||
@@ -1035,7 +1023,7 @@ export default {
|
||||
return api
|
||||
.partialUpdateFood(food.id, food)
|
||||
.then((result) => {
|
||||
if (food.inherit && food.supermarket_category && !ignore_category && food.parent) {
|
||||
if (food.supermarket_category && !ignore_category && food.parent) {
|
||||
makeToast(this.$t("Warning"), this.$t("InheritWarning", { food: food.name }), "warning")
|
||||
} else {
|
||||
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_UPDATE)
|
||||
|
||||
Reference in New Issue
Block a user