remove not view by label view and unused functions

This commit is contained in:
Michael Genson 2025-07-31 15:22:16 +00:00
commit 3609685931
2 changed files with 59 additions and 127 deletions

View file

@ -33,7 +33,6 @@ export interface UserRecipePreferences {
export interface UserShoppingListPreferences { export interface UserShoppingListPreferences {
viewAllLists: boolean; viewAllLists: boolean;
viewByLabel: boolean;
} }
export interface UserTimelinePreferences { export interface UserTimelinePreferences {
@ -129,7 +128,6 @@ export function useShoppingListPreferences(): Ref<UserShoppingListPreferences> {
"shopping-list-preferences", "shopping-list-preferences",
{ {
viewAllLists: false, viewAllLists: false,
viewByLabel: true,
}, },
{ mergeDefaults: true }, { mergeDefaults: true },
// we cast to a Ref because by default it will return an optional type ref // we cast to a Ref because by default it will return an optional type ref

View file

@ -90,11 +90,6 @@
text: '', text: '',
event: 'three-dot', event: 'three-dot',
children: [ children: [
{
icon: $globals.icons.tags,
text: $t('shopping-list.toggle-label-sort'),
event: 'sort-by-labels',
},
{ {
icon: $globals.icons.tags, icon: $globals.icons.tags,
text: $t('shopping-list.reorder-labels'), text: $t('shopping-list.reorder-labels'),
@ -111,7 +106,6 @@
@edit="edit = true" @edit="edit = true"
@three-dot="threeDot = true" @three-dot="threeDot = true"
@check="openCheckAll" @check="openCheckAll"
@sort-by-labels="sortByLabels"
@copy-plain="copyListItems('plain')" @copy-plain="copyListItems('plain')"
@copy-markdown="copyListItems('markdown')" @copy-markdown="copyListItems('markdown')"
@reorder-labels="toggleReorderLabelsDialog()" @reorder-labels="toggleReorderLabelsDialog()"
@ -136,90 +130,56 @@
v-if="!edit" v-if="!edit"
class="py-2" class="py-2"
> >
<div v-if="!preferences.viewByLabel"> <div
<VueDraggable v-for="(value, key) in itemsByLabel"
v-model="listItems.unchecked" :key="key"
handle=".handle" class="pb-4"
:delay="250" >
:delay-on-touch-only="true" <v-btn
@start="loadingCounter += 1" :color="getLabelColor(value[0]) ? getLabelColor(value[0]) : '#959595'"
@end="loadingCounter -= 1" :style="{
@update:model-value="updateIndexUnchecked" 'color': getTextColor(getLabelColor(value[0])),
'letter-spacing': 'normal',
}"
@click="toggleShowLabel(key.toString())"
> >
<v-lazy <v-icon>
v-for="(item, index) in listItems.unchecked" {{ labelOpenState[key] ? $globals.icons.chevronDown : $globals.icons.chevronRight }}
:key="item.id" </v-icon>
class="my-2" {{ key }}
> </v-btn>
<ShoppingListItem <v-divider />
v-model="listItems.unchecked[index]" <v-expand-transition>
class="my-2 my-sm-0" <div v-if="labelOpenState[key]">
:show-label="true" <VueDraggable
:labels="allLabels || []" :model-value="value"
:units="allUnits || []" handle=".handle"
:foods="allFoods || []" :delay="250"
:recipes="recipeMap" :delay-on-touch-only="true"
@checked="saveListItem" @start="loadingCounter += 1"
@save="saveListItem" @end="loadingCounter -= 1"
@delete="deleteListItem(item)" @update:model-value="updateIndexUncheckedByLabel(key.toString(), $event)"
/> >
</v-lazy> <v-lazy
</VueDraggable> v-for="(item, index) in value"
</div> :key="item.id"
class="ml-2 my-2"
<!-- View By Label -->
<div v-else>
<div
v-for="(value, key) in itemsByLabel"
:key="key"
class="pb-4"
>
<v-btn
:color="getLabelColor(value[0]) ? getLabelColor(value[0]) : '#959595'"
:style="{
'color': getTextColor(getLabelColor(value[0])),
'letter-spacing': 'normal',
}"
@click="toggleShowLabel(key.toString())"
>
<v-icon>
{{ labelOpenState[key] ? $globals.icons.chevronDown : $globals.icons.chevronRight }}
</v-icon>
{{ key }}
</v-btn>
<v-divider />
<v-expand-transition>
<div v-if="labelOpenState[key]">
<VueDraggable
:model-value="value"
handle=".handle"
:delay="250"
:delay-on-touch-only="true"
@start="loadingCounter += 1"
@end="loadingCounter -= 1"
@update:model-value="updateIndexUncheckedByLabel(key.toString(), $event)"
> >
<v-lazy <ShoppingListItem
v-for="(item, index) in value" v-model="value[index]"
:key="item.id" :show-label="false"
class="ml-2 my-2" :labels="allLabels || []"
> :units="allUnits || []"
<ShoppingListItem :foods="allFoods || []"
v-model="value[index]" :recipes="recipeMap"
:show-label="false" @checked="saveListItem"
:labels="allLabels || []" @save="saveListItem"
:units="allUnits || []" @delete="deleteListItem(item)"
:foods="allFoods || []" />
:recipes="recipeMap" </v-lazy>
@checked="saveListItem" </VueDraggable>
@save="saveListItem" </div>
@delete="deleteListItem(item)" </v-expand-transition>
/>
</v-lazy>
</VueDraggable>
</div>
</v-expand-transition>
</div>
</div> </div>
<!-- Create Item --> <!-- Create Item -->
@ -647,29 +607,19 @@ export default defineNuxtComponent({
function copyListItems(copyType: CopyTypes) { function copyListItems(copyType: CopyTypes) {
const text: string[] = []; const text: string[] = [];
if (preferences.value.viewByLabel) { // Copy text into subsections based on label
// if we're sorting by label, we want the copied text in subsections Object.entries(itemsByLabel.value).forEach(([label, items], idx) => {
Object.entries(itemsByLabel.value).forEach(([label, items], idx) => { // for every group except the first, add a blank line
// for every group except the first, add a blank line if (idx) {
if (idx) { text.push("");
text.push(""); }
}
// add an appropriate heading for the label depending on the copy format // add an appropriate heading for the label depending on the copy format
text.push(formatCopiedLabelHeading(copyType, label)); text.push(formatCopiedLabelHeading(copyType, label));
// now add the appropriately formatted list items with the given label // now add the appropriately formatted list items with the given label
items.forEach(item => text.push(formatCopiedListItem(copyType, item))); items.forEach(item => text.push(formatCopiedListItem(copyType, item)));
}); });
}
else {
// labels are toggled off, so just copy in the order they come in
const items = shoppingList.value?.listItems?.filter(item => !item.checked);
items?.forEach((item) => {
text.push(formatCopiedListItem(copyType, item));
});
}
copy.copyPlain(text); copy.copyPlain(text);
} }
@ -801,10 +751,6 @@ export default defineNuxtComponent({
return item?.label?.color; return item?.label?.color;
} }
function sortByLabels() {
preferences.value.viewByLabel = !preferences.value.viewByLabel;
}
function toggleReorderLabelsDialog() { function toggleReorderLabelsDialog() {
// stop polling and populate localLabels // stop polling and populate localLabels
loadingCounter.value += 1; loadingCounter.value += 1;
@ -1148,16 +1094,6 @@ export default defineNuxtComponent({
refresh(); refresh();
} }
function updateIndexUnchecked(uncheckedItems: ShoppingListItemOut[]) {
listItems.unchecked = uncheckedItems;
listItems.checked = shoppingList.value?.listItems?.filter(item => item.checked) || [];
// since the user has manually reordered the list, we should preserve this order
preserveItemOrder.value = true;
updateUncheckedListItems();
}
function updateIndexUncheckedByLabel(labelName: string, labeledUncheckedItems: ShoppingListItemOut[]) { function updateIndexUncheckedByLabel(labelName: string, labeledUncheckedItems: ShoppingListItemOut[]) {
if (!itemsByLabel.value[labelName]) { if (!itemsByLabel.value[labelName]) {
return; return;
@ -1245,7 +1181,6 @@ export default defineNuxtComponent({
saveListItem, saveListItem,
shoppingList, shoppingList,
showChecked, showChecked,
sortByLabels,
labelOpenState, labelOpenState,
toggleShowLabel, toggleShowLabel,
toggleShowChecked, toggleShowChecked,
@ -1253,7 +1188,6 @@ export default defineNuxtComponent({
openUncheckAll, openUncheckAll,
checkAll, checkAll,
openCheckAll, openCheckAll,
updateIndexUnchecked,
updateIndexUncheckedByLabel, updateIndexUncheckedByLabel,
allUnits, allUnits,
allFoods, allFoods,