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,39 +130,6 @@
v-if="!edit" v-if="!edit"
class="py-2" class="py-2"
> >
<div v-if="!preferences.viewByLabel">
<VueDraggable
v-model="listItems.unchecked"
handle=".handle"
:delay="250"
:delay-on-touch-only="true"
@start="loadingCounter += 1"
@end="loadingCounter -= 1"
@update:model-value="updateIndexUnchecked"
>
<v-lazy
v-for="(item, index) in listItems.unchecked"
:key="item.id"
class="my-2"
>
<ShoppingListItem
v-model="listItems.unchecked[index]"
class="my-2 my-sm-0"
:show-label="true"
:labels="allLabels || []"
:units="allUnits || []"
:foods="allFoods || []"
:recipes="recipeMap"
@checked="saveListItem"
@save="saveListItem"
@delete="deleteListItem(item)"
/>
</v-lazy>
</VueDraggable>
</div>
<!-- View By Label -->
<div v-else>
<div <div
v-for="(value, key) in itemsByLabel" v-for="(value, key) in itemsByLabel"
:key="key" :key="key"
@ -220,7 +181,6 @@
</div> </div>
</v-expand-transition> </v-expand-transition>
</div> </div>
</div>
<!-- Create Item --> <!-- Create Item -->
<div v-if="createEditorOpen"> <div v-if="createEditorOpen">
@ -647,8 +607,7 @@ 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) {
@ -661,15 +620,6 @@ export default defineNuxtComponent({
// 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,