1
0
mirror of https://github.com/TandoorRecipes/recipes.git synced 2026-01-11 09:07:12 -05:00

fixed category change entry updaet

This commit is contained in:
vabene1111
2025-12-04 07:46:56 +01:00
parent d0856ce3b7
commit 17de37b9fc
3 changed files with 11 additions and 11 deletions

View File

@@ -187,7 +187,6 @@ class SpaceFilterSerializer(serializers.ListSerializer):
data = [] data = []
else: else:
iterable = data.all() if hasattr(data, 'all') else data iterable = data.all() if hasattr(data, 'all') else data
try:
if isinstance(iterable, list) or (isinstance(iterable, QuerySet) and getattr(iterable, '_result_cache', None) is not None): if isinstance(iterable, list) or (isinstance(iterable, QuerySet) and getattr(iterable, '_result_cache', None) is not None):
data = [d for d in iterable if d.userspace.space.id == self.context['request'].space.id] data = [d for d in iterable if d.userspace.space.id == self.context['request'].space.id]
else: else:
@@ -196,9 +195,6 @@ class SpaceFilterSerializer(serializers.ListSerializer):
else: else:
# not sure why but this branch can be hit (just normal page load, need to see why) # not sure why but this branch can be hit (just normal page load, need to see why)
data = data.filter(userspace__space=self.context['request'].user.get_active_space()).all() data = data.filter(userspace__space=self.context['request'].user.get_active_space()).all()
except Exception:
# not sure why but this branch can be hit (just normal page load, need to see why)
data = data.filter(userspace__space=self.context['request'].user.get_active_space()).all()
elif isinstance(data, list): elif isinstance(data, list):
data = [d for d in data if getattr(d, self.child.Meta.model.get_space_key()[0]) == self.context['request'].space] data = [d for d in data if getattr(d, self.child.Meta.model.get_space_key()[0]) == self.context['request'].space]
else: else:

View File

@@ -174,6 +174,7 @@ const isShoppingLineDelayed = computed(() => {
function categoryUpdate(category: SupermarketCategory) { function categoryUpdate(category: SupermarketCategory) {
const api = new ApiApi() const api = new ApiApi()
shoppingListFood.value.food.supermarketCategory = category shoppingListFood.value.food.supermarketCategory = category
shoppingListFood.value.entries.forEach(e => e.food.supermarketCategory = category)
useShoppingStore().updateEntriesStructure() useShoppingStore().updateEntriesStructure()
api.apiFoodUpdate({id: shoppingListFood.value.food.id, food: shoppingListFood.value.food}).then(r => { api.apiFoodUpdate({id: shoppingListFood.value.food.id, food: shoppingListFood.value.food}).then(r => {
useMessageStore().addPreparedMessage(PreparedMessage.UPDATE_SUCCESS) useMessageStore().addPreparedMessage(PreparedMessage.UPDATE_SUCCESS)

View File

@@ -234,6 +234,9 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
r.results.forEach((e) => { r.results.forEach((e) => {
entries.value.set(e.id!, e) entries.value.set(e.id!, e)
}) })
if(r.results.length > 0){
updateEntriesStructure()
}
currentlyUpdating.value = false currentlyUpdating.value = false
}).catch((err: any) => { }).catch((err: any) => {
currentlyUpdating.value = false currentlyUpdating.value = false