mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-27 08:14:30 -04:00
feat: Simplify Default Layout Logic and Add Household.name To Cookbooks API (#6243)
This commit is contained in:
@@ -100,9 +100,7 @@ import type { SideBarLink } from "~/types/application-types";
|
||||
import { useAppInfo } from "~/composables/api";
|
||||
import { useCookbookPreferences } from "~/composables/use-users/preferences";
|
||||
import { useCookbookStore, usePublicCookbookStore } from "~/composables/store/use-cookbook-store";
|
||||
import { useHouseholdStore, usePublicHouseholdStore } from "~/composables/store/use-household-store";
|
||||
import type { ReadCookBook } from "~/lib/api/types/cookbook";
|
||||
import type { HouseholdSummary } from "~/lib/api/types/household";
|
||||
|
||||
export default defineNuxtComponent({
|
||||
setup() {
|
||||
@@ -116,12 +114,8 @@ export default defineNuxtComponent({
|
||||
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
|
||||
|
||||
const cookbookPreferences = useCookbookPreferences();
|
||||
|
||||
const ownCookbookStore = useCookbookStore(i18n);
|
||||
const ownHouseholdStore = useHouseholdStore(i18n);
|
||||
|
||||
const publicCookbookStoreCache = ref<Record<string, ReturnType<typeof usePublicCookbookStore>>>({});
|
||||
const publicHouseholdStoreCache = ref<Record<string, ReturnType<typeof usePublicHouseholdStore>>>({});
|
||||
|
||||
function getPublicCookbookStore(slug: string) {
|
||||
if (!publicCookbookStoreCache.value[slug]) {
|
||||
@@ -130,13 +124,6 @@ export default defineNuxtComponent({
|
||||
return publicCookbookStoreCache.value[slug];
|
||||
}
|
||||
|
||||
function getPublicHouseholdStore(slug: string) {
|
||||
if (!publicHouseholdStoreCache.value[slug]) {
|
||||
publicHouseholdStoreCache.value[slug] = usePublicHouseholdStore(slug, i18n);
|
||||
}
|
||||
return publicHouseholdStoreCache.value[slug];
|
||||
}
|
||||
|
||||
const cookbooks = computed(() => {
|
||||
if (isOwnGroup.value) {
|
||||
return ownCookbookStore.store.value;
|
||||
@@ -148,24 +135,6 @@ export default defineNuxtComponent({
|
||||
return [];
|
||||
});
|
||||
|
||||
const households = computed(() => {
|
||||
if (isOwnGroup.value) {
|
||||
return ownHouseholdStore.store.value;
|
||||
}
|
||||
else if (groupSlug.value) {
|
||||
const publicStore = getPublicHouseholdStore(groupSlug.value);
|
||||
return unref(publicStore.store);
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
const householdsById = computed(() => {
|
||||
return households.value.reduce((acc, household) => {
|
||||
acc[household.id] = household;
|
||||
return acc;
|
||||
}, {} as { [key: string]: HouseholdSummary });
|
||||
});
|
||||
|
||||
const appInfo = useAppInfo();
|
||||
const showImageImport = computed(() => appInfo.value?.enableOpenaiImageServices);
|
||||
|
||||
@@ -197,11 +166,8 @@ export default defineNuxtComponent({
|
||||
const ownLinks: SideBarLink[] = [];
|
||||
const links: SideBarLink[] = [];
|
||||
const cookbooksByHousehold = sortedCookbooks.reduce((acc, cookbook) => {
|
||||
const householdName = householdsById.value[cookbook.householdId]?.name || "";
|
||||
if (!acc[householdName]) {
|
||||
acc[householdName] = [];
|
||||
}
|
||||
acc[householdName].push(cookbook);
|
||||
const householdName = cookbook.household?.name || "";
|
||||
(acc[householdName] ||= []).push(cookbook);
|
||||
return acc;
|
||||
}, {} as Record<string, ReadCookBook[]>);
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ export type LogicalOperator = "AND" | "OR";
|
||||
export type RelationalKeyword = "IS" | "IS NOT" | "IN" | "NOT IN" | "CONTAINS ALL" | "LIKE" | "NOT LIKE";
|
||||
export type RelationalOperator = "=" | "<>" | ">" | "<" | ">=" | "<=";
|
||||
|
||||
export interface CookbookHousehold {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
export interface CreateCookBook {
|
||||
name: string;
|
||||
description?: string;
|
||||
@@ -28,6 +32,7 @@ export interface ReadCookBook {
|
||||
householdId: string;
|
||||
id: string;
|
||||
queryFilter?: QueryFilterJSON;
|
||||
household?: CookbookHousehold | null;
|
||||
}
|
||||
export interface QueryFilterJSON {
|
||||
parts?: QueryFilterJSONPart[];
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
*/
|
||||
|
||||
export interface OpenAIIngredient {
|
||||
input: string;
|
||||
confidence?: number | null;
|
||||
quantity?: number | null;
|
||||
unit?: string | null;
|
||||
food?: string | null;
|
||||
|
||||
4
frontend/types/components.d.ts
vendored
4
frontend/types/components.d.ts
vendored
@@ -3,6 +3,7 @@ import type AdvancedOnly from "@/components/global/AdvancedOnly.vue";
|
||||
import type AppButtonCopy from "@/components/global/AppButtonCopy.vue";
|
||||
import type AppButtonUpload from "@/components/global/AppButtonUpload.vue";
|
||||
import type AppLoader from "@/components/global/AppLoader.vue";
|
||||
import type AppLogo from "@/components/global/AppLogo.vue";
|
||||
import type AppToolbar from "@/components/global/AppToolbar.vue";
|
||||
import type AutoForm from "@/components/global/AutoForm.vue";
|
||||
import type BannerExperimental from "@/components/global/BannerExperimental.vue";
|
||||
@@ -43,6 +44,7 @@ declare module "vue" {
|
||||
AppButtonCopy: typeof AppButtonCopy;
|
||||
AppButtonUpload: typeof AppButtonUpload;
|
||||
AppLoader: typeof AppLoader;
|
||||
AppLogo: typeof AppLogo;
|
||||
AppToolbar: typeof AppToolbar;
|
||||
AutoForm: typeof AutoForm;
|
||||
BannerExperimental: typeof BannerExperimental;
|
||||
@@ -79,4 +81,4 @@ declare module "vue" {
|
||||
}
|
||||
}
|
||||
|
||||
export { };
|
||||
export {};
|
||||
|
||||
Reference in New Issue
Block a user