basic category chaning
This commit is contained in:
parent
ae3818611d
commit
b0c561661b
@ -555,7 +555,6 @@ export default {
|
|||||||
supermarket_categories_only: false,
|
supermarket_categories_only: false,
|
||||||
shopcat: null,
|
shopcat: null,
|
||||||
delay: 0,
|
delay: 0,
|
||||||
clear: Math.random(),
|
|
||||||
generic_action: null,
|
generic_action: null,
|
||||||
generic_model: null,
|
generic_model: null,
|
||||||
ui: {
|
ui: {
|
||||||
@ -843,13 +842,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
setFocus() {
|
setFocus() {
|
||||||
if (this.ui.entry_mode_simple) {
|
this.$refs['amount_input_simple'].focus()
|
||||||
this.$refs['amount_input_simple'].focus()
|
|
||||||
} else {
|
|
||||||
if (this.$refs['amount_input_complex']) {
|
|
||||||
this.$refs['amount_input_complex'].focus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// this.genericAPI inherited from ApiMixin
|
// this.genericAPI inherited from ApiMixin
|
||||||
addItem: function () {
|
addItem: function () {
|
||||||
@ -861,19 +854,14 @@ export default {
|
|||||||
unit = {name: result.data.unit}
|
unit = {name: result.data.unit}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO clean up from here on
|
this.useShoppingListStore().createObject({
|
||||||
this.new_item = {
|
|
||||||
amount: result.data.amount,
|
amount: result.data.amount,
|
||||||
unit: unit,
|
unit: unit,
|
||||||
food: {name: result.data.food, supermarket_category: null},
|
food: {name: result.data.food, supermarket_category: null},
|
||||||
}
|
})
|
||||||
this.useShoppingListStore().createObject(this.new_item)
|
|
||||||
this.new_item = {amount: 1, unit: undefined, food: undefined, ingredient: undefined}
|
this.new_item = {amount: 1, unit: undefined, food: undefined, ingredient: undefined}
|
||||||
this.clear += 1
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setFocus()
|
|
||||||
},
|
},
|
||||||
resetFilters: function () {
|
resetFilters: function () {
|
||||||
this.ui.selected_supermarket = undefined
|
this.ui.selected_supermarket = undefined
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<span v-if="info_row"><small class="text-muted">{{ info_row }}</small></span>
|
<span v-if="info_row"><small class="text-muted">{{ info_row }}</small></span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</b-button>
|
</b-button>
|
||||||
@ -33,15 +32,24 @@
|
|||||||
|
|
||||||
<template #default>
|
<template #default>
|
||||||
<h6 class="mt-2">Actions</h6> <!-- TODO localize -->
|
<h6 class="mt-2">Actions</h6> <!-- TODO localize -->
|
||||||
<b-input :placeholder="$t('Category')" class="mb-2"></b-input> <!-- TODO implement -->
|
<b-form-select
|
||||||
|
class="form-control mb-2"
|
||||||
|
:options="useShoppingListStore().supermarket_categories"
|
||||||
|
text-field="name"
|
||||||
|
value-field="id"
|
||||||
|
v-model="food.supermarket_category"
|
||||||
|
@change="detail_modal_visible = false; updateFoodCategory(food)"
|
||||||
|
></b-form-select> <!-- TODO change to lookup input or something else that works with dicts -->
|
||||||
|
|
||||||
<b-button variant="success" block @click="detail_modal_visible = false;"> {{ $t("Edit_Food") }}</b-button> <!-- TODO implement -->
|
<b-button variant="success" block @click="detail_modal_visible = false;"> {{ $t("Edit_Food") }}</b-button> <!-- TODO implement -->
|
||||||
|
|
||||||
<b-button variant="info" block @click="detail_modal_visible = false;useShoppingListStore().delayFood(food)">{{ $t('Delay') }}</b-button>
|
<b-button variant="info" block @click="detail_modal_visible = false;useShoppingListStore().delayFood(food)">{{ $t('Delay') }}</b-button>
|
||||||
|
|
||||||
|
|
||||||
|
<h6 class="mt-2">{{ $t('Entries') }}</h6>
|
||||||
|
|
||||||
<b-button variant="danger" block @click="detail_modal_visible = false;useShoppingListStore().deleteFood(food)">{{ $t('Delete_All') }}</b-button>
|
<b-button variant="danger" block @click="detail_modal_visible = false;useShoppingListStore().deleteFood(food)">{{ $t('Delete_All') }}</b-button>
|
||||||
|
|
||||||
<h6 class="mt-2">Details</h6> <!-- TODO localize -->
|
|
||||||
<b-row v-for="e in entries" v-bind:key="e.id">
|
<b-row v-for="e in entries" v-bind:key="e.id">
|
||||||
<b-col cold="12">
|
<b-col cold="12">
|
||||||
<b-button-group class="mt-1 w-100">
|
<b-button-group class="mt-1 w-100">
|
||||||
@ -81,9 +89,10 @@
|
|||||||
import Vue from "vue"
|
import Vue from "vue"
|
||||||
import {BootstrapVue} from "bootstrap-vue"
|
import {BootstrapVue} from "bootstrap-vue"
|
||||||
import "bootstrap-vue/dist/bootstrap-vue.css"
|
import "bootstrap-vue/dist/bootstrap-vue.css"
|
||||||
import {ApiMixin, resolveDjangoUrl} from "@/utils/utils"
|
import {ApiMixin, resolveDjangoUrl, StandardToasts} from "@/utils/utils"
|
||||||
import {useMealPlanStore} from "@/stores/MealPlanStore";
|
import {useMealPlanStore} from "@/stores/MealPlanStore";
|
||||||
import {useShoppingListStore} from "@/stores/ShoppingListStore";
|
import {useShoppingListStore} from "@/stores/ShoppingListStore";
|
||||||
|
import {ApiApiFactory} from "@/utils/openapi/api";
|
||||||
|
|
||||||
|
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
@ -174,11 +183,11 @@ export default {
|
|||||||
return recipes.join(', ')
|
return recipes.join(', ')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(this.entries ).length === 1) {
|
if (Object.keys(this.entries).length === 123) {
|
||||||
return "Abendessen 31.12" // TODO implement mealplan or manual
|
return "Abendessen 31.12" // TODO implement mealplan or manual
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.entries.length
|
return "IMPLEMENT INFO ROW!!"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {},
|
watch: {},
|
||||||
@ -187,7 +196,6 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
useShoppingListStore,
|
useShoppingListStore,
|
||||||
useMealPlanStore,
|
|
||||||
resolveDjangoUrl,
|
resolveDjangoUrl,
|
||||||
|
|
||||||
formatDate: function (datetime) {
|
formatDate: function (datetime) {
|
||||||
@ -200,6 +208,21 @@ export default {
|
|||||||
}).format(Date.parse(datetime))
|
}).format(Date.parse(datetime))
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateFoodCategory: function (food) {
|
||||||
|
|
||||||
|
if (typeof food.supermarket_category === "number"){
|
||||||
|
food.supermarket_category = this.useShoppingListStore().supermarket_categories.filter(sc => sc.id === food.supermarket_category)[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
let apiClient = new ApiApiFactory()
|
||||||
|
apiClient.updateFood(food.id, food).then(r => {
|
||||||
|
|
||||||
|
}).catch((err) => {
|
||||||
|
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -346,6 +346,7 @@
|
|||||||
"Delay": "Delay",
|
"Delay": "Delay",
|
||||||
"Pin": "Pin",
|
"Pin": "Pin",
|
||||||
"Unpin": "Unpin",
|
"Unpin": "Unpin",
|
||||||
|
"Entries": "Entries",
|
||||||
"PinnedConfirmation": "{recipe} has been pinned.",
|
"PinnedConfirmation": "{recipe} has been pinned.",
|
||||||
"UnpinnedConfirmation": "{recipe} has been unpinned.",
|
"UnpinnedConfirmation": "{recipe} has been unpinned.",
|
||||||
"mark_complete": "Mark Complete",
|
"mark_complete": "Mark Complete",
|
||||||
|
@ -12,8 +12,9 @@ const _LOCAL_STORAGE_KEY = "SHOPPING_LIST_CLIENT_SETTINGS"
|
|||||||
export const useShoppingListStore = defineStore(_STORE_ID, {
|
export const useShoppingListStore = defineStore(_STORE_ID, {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
category_food_entries: {},
|
category_food_entries: {},
|
||||||
|
supermarket_categories: [],
|
||||||
|
|
||||||
show_checked_entries: false,
|
show_checked_entries: false, // TODO move to settings
|
||||||
|
|
||||||
currently_updating: false,
|
currently_updating: false,
|
||||||
settings: null,
|
settings: null,
|
||||||
@ -43,6 +44,14 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
|||||||
this.updateEntryInStructure(e)
|
this.updateEntryInStructure(e)
|
||||||
})
|
})
|
||||||
this.currently_updating = false
|
this.currently_updating = false
|
||||||
|
}).catch((err) => {
|
||||||
|
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_FETCH, err)
|
||||||
|
})
|
||||||
|
|
||||||
|
apiClient.listSupermarketCategorys().then(r => {
|
||||||
|
this.supermarket_categories = r.data
|
||||||
|
}).catch((err) => {
|
||||||
|
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_FETCH, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user