mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
fixed SLI grouping entries with different delay/check state
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
<div class="flex-grow-1 p-2">
|
<div class="flex-grow-1 p-2">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<div class="d-flex flex-column pr-2">
|
<div class="d-flex flex-column pr-2">
|
||||||
<span v-for="[i, a] in amounts" v-bind:key="a.key">
|
<span v-for="a in amounts" v-bind:key="a.key">
|
||||||
<span>
|
<span>
|
||||||
<i class="fas fa-check text-success fa-fw" v-if="a.checked"></i>
|
<i class="fas fa-check text-success fa-fw" v-if="a.checked"></i>
|
||||||
<i class="fas fa-clock-rotate-left text-info fa-fw" v-if="a.delayed"></i> <b>
|
<i class="fas fa-clock-rotate-left text-info fa-fw" v-if="a.delayed"></i> <b>
|
||||||
@@ -57,7 +57,7 @@ import {useUserPreferenceStore} from "@/stores/UserPreferenceStore.js";
|
|||||||
import {ApiApi, Food, ShoppingListEntry} from '@/openapi'
|
import {ApiApi, Food, ShoppingListEntry} from '@/openapi'
|
||||||
import {ErrorMessageType, useMessageStore} from "@/stores/MessageStore";
|
import {ErrorMessageType, useMessageStore} from "@/stores/MessageStore";
|
||||||
import {IShoppingListFood, ShoppingLineAmount} from "@/types/Shopping";
|
import {IShoppingListFood, ShoppingLineAmount} from "@/types/Shopping";
|
||||||
import {isDelayed, isShoppingListFoodDelayed, isShoppingListFoodVisible} from "@/utils/logic_utils";
|
import {isDelayed, isEntryVisible, isShoppingListFoodDelayed, isShoppingListFoodVisible} from "@/utils/logic_utils";
|
||||||
import ShoppingLineItemDialog from "@/components/dialogs/ShoppingLineItemDialog.vue";
|
import ShoppingLineItemDialog from "@/components/dialogs/ShoppingLineItemDialog.vue";
|
||||||
|
|
||||||
const emit = defineEmits(['clicked'])
|
const emit = defineEmits(['clicked'])
|
||||||
@@ -113,16 +113,13 @@ const actionButtonIcon = computed(() => {
|
|||||||
* can combine 1 to n entries with the same unit
|
* can combine 1 to n entries with the same unit
|
||||||
* can contain more 0 to n different entries for different units
|
* can contain more 0 to n different entries for different units
|
||||||
*/
|
*/
|
||||||
const amounts = computed((): Map<number, ShoppingLineAmount> => {
|
const amounts = computed((): ShoppingLineAmount[] => {
|
||||||
let unitAmounts = new Map<number, ShoppingLineAmount>()
|
let unitAmounts: ShoppingLineAmount[] = []
|
||||||
|
|
||||||
for (let i in entries.value) {
|
for (let i in entries.value) {
|
||||||
let e = entries.value[i]
|
let e = entries.value[i]
|
||||||
|
|
||||||
if (!e.checked && !isDelayed(e)
|
if (isEntryVisible(e, useUserPreferenceStore().deviceSettings)) {
|
||||||
|| (e.checked && useUserPreferenceStore().deviceSettings.shopping_show_checked_entries)
|
|
||||||
|| (isDelayed(e) && useUserPreferenceStore().deviceSettings.shopping_show_delayed_entries)) {
|
|
||||||
|
|
||||||
let unit = -1
|
let unit = -1
|
||||||
if (e.unit !== undefined && e.unit !== null) {
|
if (e.unit !== undefined && e.unit !== null) {
|
||||||
unit = e.unit.id!
|
unit = e.unit.id!
|
||||||
@@ -130,11 +127,17 @@ const amounts = computed((): Map<number, ShoppingLineAmount> => {
|
|||||||
|
|
||||||
if (e.amount > 0) {
|
if (e.amount > 0) {
|
||||||
|
|
||||||
if (unitAmounts.get(unit) != undefined) {
|
let uaMerged = false
|
||||||
unitAmounts.get(unit)!.amount += e.amount
|
unitAmounts.forEach(ua => {
|
||||||
} else {
|
if (((ua.unit == null && e.unit == null) || ua.unit.id! == unit) && ua.checked == e.checked && ua.delayed == isDelayed(e)) {
|
||||||
unitAmounts.set(unit, {
|
ua.amount += e.amount
|
||||||
key: e.food?.id!,
|
uaMerged = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!uaMerged) {
|
||||||
|
unitAmounts.push({
|
||||||
|
key: `${unit}_${e.checked}_${isDelayed(e)}`,
|
||||||
amount: e.amount,
|
amount: e.amount,
|
||||||
unit: e.unit,
|
unit: e.unit,
|
||||||
checked: e.checked,
|
checked: e.checked,
|
||||||
@@ -164,9 +167,7 @@ const infoRow = computed(() => {
|
|||||||
for (let i in entries.value) {
|
for (let i in entries.value) {
|
||||||
let e = entries.value[i]
|
let e = entries.value[i]
|
||||||
|
|
||||||
if (!e.checked && !isDelayed(e)
|
if (isEntryVisible(e, useUserPreferenceStore().deviceSettings)) {
|
||||||
|| (e.checked && useUserPreferenceStore().deviceSettings.shopping_show_checked_entries)
|
|
||||||
|| (isDelayed(e) && useUserPreferenceStore().deviceSettings.shopping_show_delayed_entries)) {
|
|
||||||
|
|
||||||
if (authors.indexOf(e.createdBy.displayName) === -1) {
|
if (authors.indexOf(e.createdBy.displayName) === -1) {
|
||||||
authors.push(e.createdBy.displayName)
|
authors.push(e.createdBy.displayName)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<v-tabs v-model="tab" :disabled="loading" grow>
|
<v-tabs v-model="tab" :disabled="loading" grow>
|
||||||
<v-tab value="supermarket">{{ $t('Supermarket') }}</v-tab>
|
<v-tab value="supermarket">{{ $t('Supermarket') }}</v-tab>
|
||||||
<v-tab value="categories">{{ $t('Categories') }}</v-tab>
|
<v-tab value="categories" :disabled="!isUpdate()">{{ $t('Categories') }}</v-tab>
|
||||||
</v-tabs>
|
</v-tabs>
|
||||||
|
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export interface IShoppingListFood {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type ShoppingLineAmount = {
|
export type ShoppingLineAmount = {
|
||||||
key: number,
|
key: string,
|
||||||
amount: number,
|
amount: number,
|
||||||
unit: Unit,
|
unit: Unit,
|
||||||
checked: boolean,
|
checked: boolean,
|
||||||
|
|||||||
Reference in New Issue
Block a user