Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve Shopping List UI #4608

Draft
wants to merge 6 commits into
base: mealie-next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 36 additions & 30 deletions frontend/components/Domain/ShoppingList/ShoppingListItemEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
:label="$t('shopping-list.note')"
rows="1"
auto-grow
autofocus
@keypress="handleNoteKeyPress"
></v-textarea>
</div>
Expand Down Expand Up @@ -80,37 +81,37 @@
<v-spacer />
</div>
</v-card-text>
<v-card-actions class="ma-0 pt-0 pb-1 justify-end">
<BaseButtonGroup
:buttons="[
...(allowDelete ? [{
icon: $globals.icons.delete,
text: $t('general.delete'),
event: 'delete',
}] : []),
{
icon: $globals.icons.close,
text: $t('general.cancel'),
event: 'cancel',
},
{
icon: $globals.icons.foods,
text: $t('shopping-list.toggle-food'),
event: 'toggle-foods',
},
{
icon: $globals.icons.save,
text: $t('general.save'),
event: 'save',
},
]"
@save="$emit('save')"
@cancel="$emit('cancel')"
@delete="$emit('delete')"
@toggle-foods="listItem.isFood = !listItem.isFood"
/>
</v-card-actions>
</v-card>
<v-card-actions class="ma-0 pt-0 pb-1 justify-end">
<BaseButtonGroup
:buttons="[
{
icon: $globals.icons.delete,
text: $t('general.delete'),
event: 'delete',
},
{
icon: $globals.icons.close,
text: $t('general.cancel'),
event: 'cancel',
},
{
icon: $globals.icons.foods,
text: $t('shopping-list.toggle-food'),
event: 'toggle-foods',
},
{
icon: $globals.icons.save,
text: $t('general.save'),
event: 'save',
},
]"
@save="$emit('save')"
@cancel="$emit('cancel')"
@delete="$emit('delete')"
@toggle-foods="listItem.isFood = !listItem.isFood"
/>
</v-card-actions>
</div>
</template>

Expand Down Expand Up @@ -139,6 +140,11 @@ export default defineComponent({
type: Array as () => IngredientFood[],
required: true,
},
allowDelete: {
type: Boolean,
required: false,
default: true,
},
},
setup(props, context) {
const foodStore = useFoodStore();
Expand Down
206 changes: 99 additions & 107 deletions frontend/pages/shopping-lists/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,71 @@
<v-col cols="6" class="d-flex justify-center">
<v-img max-height="100" max-width="100" :src="require('~/static/svgs/shopping-cart.svg')"></v-img>
</v-col>
<v-col class="d-flex justify-end">
<div class="d-flex justify-end mb-4 mt-2">
<v-btn-group dense>
<v-menu offset-y>
<template #activator="{ on, attrs }">
<v-btn text v-bind="attrs" v-on="on">
<v-icon>
{{ $globals.icons.dotsVertical }}
</v-icon>
</v-btn>
</template>
<v-list>
<v-list-item @click="copyListItems('plain')">
<v-icon left>
{{ $globals.icons.contentCopy }}
</v-icon>
<v-list-item-title>{{ $t("shopping-list.copy-as-text") }}</v-list-item-title>
</v-list-item>
<v-list-item @click="copyListItems('markdown')">
<v-icon left>
{{ $globals.icons.contentCopy }}
</v-icon>
<v-list-item-title>{{ $t("shopping-list.copy-as-markdown") }}</v-list-item-title>
</v-list-item>
<v-list-item @click="openUncheckAll()">
<v-icon left>
{{ $globals.icons.checkboxBlankOutline }}
</v-icon>
<v-list-item-title>{{ $t("shopping-list.uncheck-all-items") }}</v-list-item-title>
</v-list-item>
<v-list-item @click="openCheckAll()">
<v-icon left>
{{ $globals.icons.checkboxOutline }}
</v-icon>
<v-list-item-title>{{ $t("shopping-list.check-all-items") }}</v-list-item-title>
</v-list-item>
<v-list-item @click="sortByLabels()">
<v-icon left>
{{ $globals.icons.tags }}
</v-icon>
<v-list-item-title>{{ $t("shopping-list.toggle-label-sort") }}</v-list-item-title>
</v-list-item>
<v-list-item v-if="preferences.viewByLabel" @click="toggleReorderLabelsDialog()">
<v-icon left>
{{ $globals.icons.tags }}
</v-icon>
<v-list-item-title>{{ $t("shopping-list.reorder-labels") }}</v-list-item-title>
</v-list-item>
<v-list-item :to="`/group/data/labels`">
<v-icon left>
{{ $globals.icons.tags }}
</v-icon>
<v-list-item-title>{{ $t("shopping-list.manage-labels") }}</v-list-item-title>
</v-list-item>
<v-list-item @click="toggleSettingsDialog()">
<v-icon left>
{{ $globals.icons.cog }}
</v-icon>
<v-list-item-title>{{ $t('general.settings') }}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</v-btn-group>
</div>
</v-col>
</v-row>
</v-container>
</template>
Expand Down Expand Up @@ -93,6 +158,24 @@
</div>
</div>

<!-- Create Item -->
<div v-if="createEditorOpen">
<ShoppingListItemEditor
v-model="createListItemData"
class="my-4"
:labels="allLabels || []"
:units="allUnits || []"
:foods="allFoods || []"
:allow-delete="false"
@delete="createEditorOpen = false"
@cancel="createEditorOpen = false"
@save="createListItem"
/>
</div>
<div v-else class="d-flex justify-end">
<BaseButton create @click="createEditorOpen = true" > {{ $t('general.add') }} </BaseButton>
</div>

<!-- Reorder Labels -->
<BaseDialog
v-model="reorderLabelsDialog"
Expand Down Expand Up @@ -140,92 +223,24 @@
</v-container>
</BaseDialog>

<!-- Create Item -->
<div v-if="createEditorOpen">
<ShoppingListItemEditor
v-model="createListItemData"
class="my-4"
:labels="allLabels || []"
:units="allUnits || []"
:foods="allFoods || []"
@delete="createEditorOpen = false"
@cancel="createEditorOpen = false"
@save="createListItem"
/>
</div>
<div v-else class="mt-4 d-flex justify-end">
<BaseButton
v-if="preferences.viewByLabel" edit class="mr-2"
:disabled="$nuxt.isOffline"
@click="toggleReorderLabelsDialog">
<template #icon> {{ $globals.icons.tags }} </template>
{{ $t('shopping-list.reorder-labels') }}
</BaseButton>
<BaseButton create @click="createEditorOpen = true" > {{ $t('general.add') }} </BaseButton>
</div>

<!-- Action Bar -->
<div class="d-flex justify-end mb-4 mt-2">
<BaseButtonGroup
:buttons="[
{
icon: $globals.icons.contentCopy,
text: '',
event: 'edit',
children: [
{
icon: $globals.icons.contentCopy,
text: $tc('shopping-list.copy-as-text'),
event: 'copy-plain',
},
{
icon: $globals.icons.contentCopy,
text: $tc('shopping-list.copy-as-markdown'),
event: 'copy-markdown',
},
],
},
{
icon: $globals.icons.delete,
text: $tc('shopping-list.delete-checked'),
event: 'delete',
},
{
icon: $globals.icons.tags,
text: $tc('shopping-list.toggle-label-sort'),
event: 'sort-by-labels',
},
{
icon: $globals.icons.checkboxBlankOutline,
text: $tc('shopping-list.uncheck-all-items'),
event: 'uncheck',
},
{
icon: $globals.icons.checkboxOutline,
text: $tc('shopping-list.check-all-items'),
event: 'check',
},
]"
@edit="edit = true"
@delete="openDeleteChecked"
@uncheck="openUncheckAll"
@check="openCheckAll"
@sort-by-labels="sortByLabels"
@copy-plain="copyListItems('plain')"
@copy-markdown="copyListItems('markdown')"
/>
</div>

<!-- Checked Items -->
<div v-if="listItems.checked && listItems.checked.length > 0" class="mt-6">
<button @click="toggleShowChecked()">
<span>
<v-icon>
{{ showChecked ? $globals.icons.chevronDown : $globals.icons.chevronRight }}
<div v-if="listItems.checked && listItems.checked.length > 0" class="mt-10">
<div class="d-flex justify-space-between">
<button @click="toggleShowChecked()">
<span>
<v-icon>
{{ showChecked ? $globals.icons.chevronDown : $globals.icons.chevronRight }}
</v-icon>
</span>
{{ $tc('shopping-list.items-checked-count', listItems.checked ? listItems.checked.length : 0) }}
</button>
<v-btn text @click="openDeleteChecked()">
<v-icon color="">
{{ $globals.icons.delete }}
</v-icon>
</span>
{{ $tc('shopping-list.items-checked-count', listItems.checked ? listItems.checked.length : 0) }}
</button>
</v-btn>
</div>

<v-divider class="my-4"></v-divider>
<v-expand-transition>
<div v-show="showChecked">
Expand Down Expand Up @@ -277,29 +292,6 @@
</RecipeList>
</section>
</v-lazy>

<v-lazy>
<div class="d-flex justify-end">
<BaseButton
edit
:disabled="$nuxt.isOffline"
@click="toggleSettingsDialog"
>
<template #icon> {{ $globals.icons.cog }} </template>
{{ $t('general.settings') }}
</BaseButton>
</div>
</v-lazy>

<v-lazy>
<div v-if="$nuxt.isOnline" class="d-flex justify-end mt-10">
<ButtonLink
:to="`/group/data/labels`"
:text="$tc('shopping-list.manage-labels')"
:icon="$globals.icons.tags"
/>
</div>
</v-lazy>
<WakelockSwitch/>
</v-container>
</template>
Expand Down