mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-31 02:03:35 -04:00 
			
		
		
		
	fix: mis-ordered shoppinglist after checking item (#1749)
This commit is contained in:
		| @@ -15,7 +15,7 @@ | |||||||
|             <ShoppingListItem |             <ShoppingListItem | ||||||
|               v-model="listItems.unchecked[index]" |               v-model="listItems.unchecked[index]" | ||||||
|               class="my-2 my-sm-0" |               class="my-2 my-sm-0" | ||||||
|               :labels="allLabels" |               :labels="allLabels || []" | ||||||
|               :units="allUnits || []" |               :units="allUnits || []" | ||||||
|               :foods="allFoods || []" |               :foods="allFoods || []" | ||||||
|               @checked="saveListItem(item)" |               @checked="saveListItem(item)" | ||||||
| @@ -40,7 +40,7 @@ | |||||||
|           <v-lazy v-for="(item, index) in value" :key="item.id"> |           <v-lazy v-for="(item, index) in value" :key="item.id"> | ||||||
|             <ShoppingListItem |             <ShoppingListItem | ||||||
|               v-model="value[index]" |               v-model="value[index]" | ||||||
|               :labels="allLabels" |               :labels="allLabels || []" | ||||||
|               :units="allUnits || []" |               :units="allUnits || []" | ||||||
|               :foods="allFoods || []" |               :foods="allFoods || []" | ||||||
|               @checked="saveListItem(item)" |               @checked="saveListItem(item)" | ||||||
| @@ -56,7 +56,7 @@ | |||||||
|         <ShoppingListItemEditor |         <ShoppingListItemEditor | ||||||
|           v-model="createListItemData" |           v-model="createListItemData" | ||||||
|           class="my-4" |           class="my-4" | ||||||
|           :labels="allLabels" |           :labels="allLabels || []" | ||||||
|           :units="allUnits || []" |           :units="allUnits || []" | ||||||
|           :foods="allFoods || []" |           :foods="allFoods || []" | ||||||
|           @delete="createEditorOpen = false" |           @delete="createEditorOpen = false" | ||||||
| @@ -439,11 +439,22 @@ export default defineComponent({ | |||||||
|     // ===================================== |     // ===================================== | ||||||
|     // List Item CRUD |     // List Item CRUD | ||||||
|  |  | ||||||
|  |     /* | ||||||
|  |      * saveListItem updates and update on the backend server. Additionally, if the item is | ||||||
|  |      * checked it will also append that item to the end of the list so that the unchecked items | ||||||
|  |      * are at the top of the list. | ||||||
|  |      */ | ||||||
|     async function saveListItem(item: ShoppingListItemOut) { |     async function saveListItem(item: ShoppingListItemOut) { | ||||||
|       if (!shoppingList.value) { |       if (!shoppingList.value) { | ||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|  |  | ||||||
|  |       if (item.checked && shoppingList.value.listItems) { | ||||||
|  |         const lst = shoppingList.value.listItems.filter((itm) => itm.id !== item.id); | ||||||
|  |         lst.push(item); | ||||||
|  |         updateIndex(lst); | ||||||
|  |       } | ||||||
|  |  | ||||||
|       const { data } = await userApi.shopping.items.updateOne(item.id, item); |       const { data } = await userApi.shopping.items.updateOne(item.id, item); | ||||||
|  |  | ||||||
|       if (data) { |       if (data) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user