mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-25 08:09:41 +02:00
feat: Show Cookbooks from Other Households (#4452)
This commit is contained in:
parent
8983745106
commit
87f4b23711
13 changed files with 264 additions and 55 deletions
|
@ -99,10 +99,10 @@ export const useCookbooks = function () {
|
|||
|
||||
loading.value = false;
|
||||
},
|
||||
async createOne() {
|
||||
async createOne(name: string | null = null) {
|
||||
loading.value = true;
|
||||
const { data } = await api.cookbooks.createOne({
|
||||
name: i18n.t("cookbook.household-cookbook-name", [household.value?.name || "", String((cookbookStore?.value?.length ?? 0) + 1)]) as string,
|
||||
name: name || i18n.t("cookbook.household-cookbook-name", [household.value?.name || "", String((cookbookStore?.value?.length ?? 0) + 1)]) as string,
|
||||
position: (cookbookStore?.value?.length ?? 0) + 1,
|
||||
queryFilterString: "",
|
||||
});
|
||||
|
@ -129,18 +129,18 @@ export const useCookbooks = function () {
|
|||
return data;
|
||||
},
|
||||
|
||||
async updateOrder() {
|
||||
if (!cookbookStore?.value) {
|
||||
async updateOrder(cookbooks: ReadCookBook[]) {
|
||||
if (!cookbooks?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
|
||||
cookbookStore.value.forEach((element, index) => {
|
||||
cookbooks.forEach((element, index) => {
|
||||
element.position = index + 1;
|
||||
});
|
||||
|
||||
const { data } = await api.cookbooks.updateAll(cookbookStore.value);
|
||||
const { data } = await api.cookbooks.updateAll(cookbooks);
|
||||
|
||||
if (data && cookbookStore?.value) {
|
||||
this.refreshAll();
|
||||
|
|
|
@ -45,6 +45,10 @@ export interface UserParsingPreferences {
|
|||
parser: RegisteredParser;
|
||||
}
|
||||
|
||||
export interface UserCookbooksPreferences {
|
||||
hideOtherHouseholds: boolean;
|
||||
}
|
||||
|
||||
export function useUserMealPlanPreferences(): Ref<UserMealPlanPreferences> {
|
||||
const fromStorage = useLocalStorage(
|
||||
"meal-planner-preferences",
|
||||
|
@ -153,3 +157,17 @@ export function useParsingPreferences(): Ref<UserParsingPreferences> {
|
|||
|
||||
return fromStorage;
|
||||
}
|
||||
|
||||
export function useCookbookPreferences(): Ref<UserCookbooksPreferences> {
|
||||
const fromStorage = useLocalStorage(
|
||||
"cookbook-preferences",
|
||||
{
|
||||
hideOtherHouseholds: false,
|
||||
},
|
||||
{ mergeDefaults: true }
|
||||
// we cast to a Ref because by default it will return an optional type ref
|
||||
// but since we pass defaults we know all properties are set.
|
||||
) as unknown as Ref<UserCookbooksPreferences>;
|
||||
|
||||
return fromStorage;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue