mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
feat: If only 1 shopping list, navigate straight to it (Shopping List QoL) (#3764)
Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
parent
d923b4c7fa
commit
eb36912e5c
@ -2,7 +2,16 @@
|
||||
<v-container v-if="shoppingList" class="md-container">
|
||||
<BasePageTitle divider>
|
||||
<template #header>
|
||||
<v-img max-height="100" max-width="100" :src="require('~/static/svgs/shopping-cart.svg')"></v-img>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col cols="3" class="text-left">
|
||||
<ButtonLink :to="`/shopping-lists?disableRedirect=true`" :text="$tc('general.back')" :icon="$globals.icons.backArrow" />
|
||||
</v-col>
|
||||
<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-row>
|
||||
</v-container>
|
||||
</template>
|
||||
<template #title> {{ shoppingList.name }} </template>
|
||||
</BasePageTitle>
|
||||
|
@ -48,7 +48,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, useAsync, useContext, reactive, toRefs, useRoute } from "@nuxtjs/composition-api";
|
||||
import { computed, defineComponent, useAsync, useContext, reactive, toRefs, useRoute, useRouter } from "@nuxtjs/composition-api";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import { useAsyncKey } from "~/composables/use-utils";
|
||||
import { useShoppingListPreferences } from "~/composables/use-users/preferences";
|
||||
@ -59,7 +59,9 @@ export default defineComponent({
|
||||
const { $auth } = useContext();
|
||||
const userApi = useUserApi();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
|
||||
const disableRedirect = computed(() => route.value.query.disableRedirect === "true");
|
||||
const preferences = useShoppingListPreferences();
|
||||
|
||||
const state = reactive({
|
||||
@ -116,6 +118,15 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
if (!disableRedirect.value) {
|
||||
useAsync(async () => {
|
||||
await refresh();
|
||||
if (shoppingListChoices.value?.length === 1) {
|
||||
router.push(`/shopping-lists/${shoppingListChoices.value[0].id}`);
|
||||
}
|
||||
}, useAsyncKey());
|
||||
}
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
groupSlug,
|
||||
|
Loading…
x
Reference in New Issue
Block a user