mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 12:18:45 -05:00
shopping cleanup
This commit is contained in:
@@ -13,18 +13,19 @@
|
||||
<div class="d-flex flex-column pr-2">
|
||||
<span v-for="[i, a] in amounts" v-bind:key="a.key">
|
||||
<span>
|
||||
<i class="fas fa-check text-warning" v-if="a.checked && !isChecked"></i>
|
||||
<i class="fas fa-hourglass-half text-primary" v-if="a.delayed && !a.checked"></i> <b>
|
||||
<span :class="{'text-decoration-line-through': a.checked}">
|
||||
<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>
|
||||
<span :class="{'text-disabled': a.checked || a.delayed}">
|
||||
{{ a.amount }}
|
||||
<span v-if="a.unit">{{ a.unit.name }}</span>
|
||||
</span>
|
||||
<span v-if="a.unit">{{ a.unit.name }}</span>
|
||||
|
||||
</b>
|
||||
</span>
|
||||
<br/>
|
||||
</span>
|
||||
</div>
|
||||
<div class="d-flex flex-column flex-grow-1 align-self-center" :class="{'text-decoration-line-through': isChecked}">
|
||||
<div class="d-flex flex-column flex-grow-1 align-self-center" >
|
||||
{{ shoppingListFood.food.name }} <br/>
|
||||
<span v-if="infoRow"><small class="text-disabled">{{ infoRow }}</small></span>
|
||||
</div>
|
||||
|
||||
@@ -86,11 +86,15 @@
|
||||
</template>
|
||||
</v-text-field>
|
||||
|
||||
<v-list class="mt-3" density="compact">
|
||||
<v-list class="mt-3" density="compact" v-if="!useShoppingStore().initialized">
|
||||
<v-skeleton-loader type="list-item"></v-skeleton-loader>
|
||||
<v-skeleton-loader type="list-item"></v-skeleton-loader>
|
||||
<v-skeleton-loader type="list-item"></v-skeleton-loader>
|
||||
<v-skeleton-loader type="list-item"></v-skeleton-loader>
|
||||
</v-list>
|
||||
<v-list class="mt-3" density="compact" v-else>
|
||||
<template v-for="category in useShoppingStore().getEntriesByGroup" :key="category.name">
|
||||
<template v-if="(category.stats.countUnchecked > 0 || useUserPreferenceStore().deviceSettings.shopping_show_checked_entries)
|
||||
&& (category.stats.countUnchecked + category.stats.countChecked) > 0
|
||||
&& (category.stats.countUncheckedDelayed < category.stats.countUnchecked || useUserPreferenceStore().deviceSettings.shopping_show_delayed_entries)">
|
||||
<template v-if="isCategoryVisible(category)">
|
||||
|
||||
<v-list-subheader v-if="category.name === useShoppingStore().UNDEFINED_CATEGORY"><i>{{ $t('NoCategory') }}</i></v-list-subheader>
|
||||
<v-list-subheader v-else>{{ category.name }}</v-list-subheader>
|
||||
@@ -104,6 +108,7 @@
|
||||
</template>
|
||||
</template>
|
||||
</v-list>
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
@@ -185,13 +190,13 @@
|
||||
|
||||
import {computed, onMounted, ref} from "vue";
|
||||
import {useShoppingStore} from "@/stores/ShoppingStore";
|
||||
import {ApiApi, Food, IngredientString, ShoppingListEntry, Unit} from "@/openapi";
|
||||
import {ApiApi, Food, IngredientString, ShoppingListEntry, SupermarketCategory, Unit} from "@/openapi";
|
||||
import {ErrorMessageType, useMessageStore} from "@/stores/MessageStore";
|
||||
import ShoppingLineItem from "@/components/display/ShoppingLineItem.vue";
|
||||
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore";
|
||||
import ModelSelect from "@/components/inputs/ModelSelect.vue";
|
||||
import ShoppingLineItemDialog from "@/components/dialogs/ShoppingLineItemDialog.vue";
|
||||
import {IShoppingListFood, ShoppingGroupingOptions} from "@/types/Shopping";
|
||||
import {IShoppingListCategory, IShoppingListFood, ShoppingGroupingOptions} from "@/types/Shopping";
|
||||
import {useI18n} from "vue-i18n";
|
||||
import NumberScalerDialog from "@/components/inputs/NumberScalerDialog.vue";
|
||||
|
||||
@@ -256,6 +261,22 @@ function addIngredient() {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* determines if a category as entries that should be visible
|
||||
* @param category
|
||||
*/
|
||||
function isCategoryVisible(category: IShoppingListCategory) {
|
||||
let entryCount = category.stats.countUnchecked
|
||||
|
||||
if (useUserPreferenceStore().deviceSettings.shopping_show_checked_entries){
|
||||
entryCount += category.stats.countChecked
|
||||
}
|
||||
if (useUserPreferenceStore().deviceSettings.shopping_show_delayed_entries){
|
||||
entryCount += category.stats.countUncheckedDelayed
|
||||
}
|
||||
return entryCount > 0
|
||||
}
|
||||
|
||||
/**
|
||||
* run the autosync function in a loop
|
||||
*/
|
||||
|
||||
@@ -34,6 +34,7 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
|
||||
|
||||
// internal
|
||||
let currentlyUpdating = ref(false)
|
||||
let initialized = ref(false)
|
||||
|
||||
let autoSyncLastTimestamp = ref(new Date('1970-01-01'))
|
||||
let autoSyncHasFocus = ref(true)
|
||||
@@ -89,9 +90,10 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
|
||||
if (entry.checked) {
|
||||
categoryStats.countChecked++
|
||||
} else {
|
||||
categoryStats.countUnchecked++
|
||||
if (isDelayed(entry)) {
|
||||
categoryStats.countUncheckedDelayed++
|
||||
} else {
|
||||
categoryStats.countUnchecked++
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -175,6 +177,7 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
|
||||
entries.value.set(e.id!, e)
|
||||
})
|
||||
currentlyUpdating.value = false
|
||||
initialized.value = true
|
||||
}).catch((err) => {
|
||||
currentlyUpdating.value = false
|
||||
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
|
||||
@@ -531,6 +534,7 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
|
||||
autoSyncHasFocus,
|
||||
autoSyncLastTimestamp,
|
||||
currentlyUpdating,
|
||||
initialized,
|
||||
getFlatEntries,
|
||||
hasFailedItems,
|
||||
itemCheckSyncQueue,
|
||||
|
||||
Reference in New Issue
Block a user