2021-12-04 14:18:46 -09:00
|
|
|
<template>
|
|
|
|
<v-container fluid>
|
|
|
|
<!-- Export Purge Confirmation Dialog -->
|
|
|
|
<BaseDialog
|
|
|
|
v-model="purgeExportsDialog"
|
2023-01-29 02:39:51 +01:00
|
|
|
:title="$t('data-pages.recipes.purge-exports')"
|
2021-12-04 14:18:46 -09:00
|
|
|
color="error"
|
|
|
|
:icon="$globals.icons.alertCircle"
|
2025-06-20 00:09:12 +07:00
|
|
|
can-confirm
|
2021-12-04 14:18:46 -09:00
|
|
|
@confirm="purgeExports()"
|
|
|
|
>
|
2023-01-29 02:39:51 +01:00
|
|
|
<v-card-text> {{ $t('data-pages.recipes.are-you-sure-you-want-to-delete-all-export-data') }} </v-card-text>
|
2021-12-04 14:18:46 -09:00
|
|
|
</BaseDialog>
|
|
|
|
|
|
|
|
<!-- Base Dialog Object -->
|
|
|
|
<BaseDialog
|
|
|
|
ref="domDialog"
|
|
|
|
v-model="dialog.state"
|
|
|
|
width="650px"
|
|
|
|
:icon="dialog.icon"
|
|
|
|
:title="dialog.title"
|
2023-01-29 02:39:51 +01:00
|
|
|
:submit-text="$t('general.submit')"
|
2025-06-20 00:09:12 +07:00
|
|
|
can-submit
|
2021-12-04 14:18:46 -09:00
|
|
|
@submit="dialog.callback"
|
|
|
|
>
|
|
|
|
<v-card-text v-if="dialog.mode == MODES.tag">
|
2025-06-20 00:09:12 +07:00
|
|
|
<RecipeOrganizerSelector
|
|
|
|
v-model="toSetTags"
|
|
|
|
selector-type="tags"
|
|
|
|
/>
|
2021-12-04 14:18:46 -09:00
|
|
|
</v-card-text>
|
|
|
|
<v-card-text v-else-if="dialog.mode == MODES.category">
|
2025-06-20 00:09:12 +07:00
|
|
|
<RecipeOrganizerSelector
|
|
|
|
v-model="toSetCategories"
|
|
|
|
selector-type="categories"
|
|
|
|
/>
|
2021-12-04 14:18:46 -09:00
|
|
|
</v-card-text>
|
|
|
|
<v-card-text v-else-if="dialog.mode == MODES.delete">
|
2025-06-20 00:09:12 +07:00
|
|
|
<p class="h4">
|
|
|
|
{{ $t('data-pages.recipes.confirm-delete-recipes') }}
|
|
|
|
</p>
|
|
|
|
<v-card variant="outlined">
|
|
|
|
<v-virtual-scroll
|
|
|
|
height="400"
|
|
|
|
item-height="25"
|
|
|
|
:items="selected"
|
|
|
|
>
|
2021-12-04 14:18:46 -09:00
|
|
|
<template #default="{ item }">
|
|
|
|
<v-list-item class="pb-2">
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-list-item-title>{{ item.name }}</v-list-item-title>
|
2021-12-04 14:18:46 -09:00
|
|
|
</v-list-item>
|
|
|
|
</template>
|
|
|
|
</v-virtual-scroll>
|
|
|
|
</v-card>
|
|
|
|
</v-card-text>
|
|
|
|
<v-card-text v-else-if="dialog.mode == MODES.export">
|
2025-06-20 00:09:12 +07:00
|
|
|
<p class="h4">
|
|
|
|
{{ $t('data-pages.recipes.the-following-recipes-selected-length-will-be-exported',
|
|
|
|
[selected.length]) }}
|
|
|
|
</p>
|
|
|
|
<v-card variant="outlined">
|
|
|
|
<v-virtual-scroll
|
|
|
|
height="400"
|
|
|
|
item-height="25"
|
|
|
|
:items="selected"
|
|
|
|
>
|
2021-12-04 14:18:46 -09:00
|
|
|
<template #default="{ item }">
|
|
|
|
<v-list-item class="pb-2">
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-list-item-title>{{ item.name }}</v-list-item-title>
|
2021-12-04 14:18:46 -09:00
|
|
|
</v-list-item>
|
|
|
|
</template>
|
|
|
|
</v-virtual-scroll>
|
|
|
|
</v-card>
|
|
|
|
</v-card-text>
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-card-text
|
|
|
|
v-else-if="dialog.mode == MODES.updateSettings"
|
|
|
|
class="px-12"
|
|
|
|
>
|
2023-01-29 02:39:51 +01:00
|
|
|
<p>{{ $t('data-pages.recipes.settings-chosen-explanation') }}</p>
|
2022-08-14 10:37:44 -08:00
|
|
|
<div class="mx-auto">
|
|
|
|
<RecipeSettingsSwitches v-model="recipeSettings" />
|
|
|
|
</div>
|
|
|
|
<p class="text-center mb-0">
|
2025-06-20 00:09:12 +07:00
|
|
|
<i>{{ $t('data-pages.recipes.selected-length-recipe-s-settings-will-be-updated', selected.length) }}</i>
|
2022-08-14 10:37:44 -08:00
|
|
|
</p>
|
|
|
|
</v-card-text>
|
2024-10-19 04:33:32 -05:00
|
|
|
<v-card-text v-else-if="dialog.mode == MODES.changeOwner">
|
|
|
|
<v-select
|
|
|
|
v-model="selectedOwner"
|
|
|
|
:items="allUsers"
|
2025-06-20 00:09:12 +07:00
|
|
|
item-title="fullName"
|
2024-10-19 04:33:32 -05:00
|
|
|
item-value="id"
|
2025-06-20 00:09:12 +07:00
|
|
|
:label="$t('general.owner')"
|
2024-10-19 04:33:32 -05:00
|
|
|
hide-details
|
|
|
|
>
|
|
|
|
<template #prepend>
|
2025-06-20 00:09:12 +07:00
|
|
|
<UserAvatar
|
|
|
|
:user-id="selectedOwner"
|
|
|
|
:tooltip="false"
|
|
|
|
/>
|
2024-10-19 04:33:32 -05:00
|
|
|
</template>
|
|
|
|
</v-select>
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-card-text
|
|
|
|
v-if="selectedOwnerHousehold"
|
|
|
|
class="d-flex"
|
|
|
|
style="align-items: flex-end;"
|
|
|
|
>
|
2024-10-19 04:33:32 -05:00
|
|
|
<v-icon>{{ $globals.icons.household }}</v-icon>
|
|
|
|
<span class="pl-1">{{ selectedOwnerHousehold.name }}</span>
|
|
|
|
</v-card-text>
|
|
|
|
</v-card-text>
|
2021-12-04 14:18:46 -09:00
|
|
|
</BaseDialog>
|
|
|
|
<section>
|
|
|
|
<!-- Recipe Data Table -->
|
2025-06-20 00:09:12 +07:00
|
|
|
<BaseCardSectionTitle
|
|
|
|
:icon="$globals.icons.primary"
|
|
|
|
:title="$t('data-pages.recipes.recipe-data')"
|
|
|
|
>
|
2023-01-29 02:39:51 +01:00
|
|
|
{{ $t('data-pages.recipes.recipe-data-description') }}
|
2021-12-04 14:18:46 -09:00
|
|
|
</BaseCardSectionTitle>
|
|
|
|
<v-card-actions class="mt-n5 mb-1">
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-menu
|
|
|
|
offset-y
|
|
|
|
bottom
|
|
|
|
nudge-bottom="6"
|
|
|
|
:close-on-content-click="false"
|
|
|
|
>
|
|
|
|
<template #activator="{ props }">
|
|
|
|
<v-btn
|
|
|
|
color="accent"
|
|
|
|
class="mr-2"
|
|
|
|
variant="elevated"
|
|
|
|
dark
|
|
|
|
v-bind="props"
|
|
|
|
>
|
|
|
|
<v-icon start>
|
2021-12-04 14:18:46 -09:00
|
|
|
{{ $globals.icons.cog }}
|
|
|
|
</v-icon>
|
2023-01-29 02:39:51 +01:00
|
|
|
{{ $t('data-pages.columns') }}
|
2021-12-04 14:18:46 -09:00
|
|
|
</v-btn>
|
|
|
|
</template>
|
|
|
|
<v-card>
|
|
|
|
<v-card-title class="py-2">
|
2023-01-29 02:39:51 +01:00
|
|
|
<div>{{ $t('data-pages.recipes.recipe-columns') }}</div>
|
2021-12-04 14:18:46 -09:00
|
|
|
</v-card-title>
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-divider class="mx-2" />
|
2021-12-04 14:18:46 -09:00
|
|
|
<v-card-text class="mt-n5">
|
|
|
|
<v-checkbox
|
2022-03-22 21:08:06 -08:00
|
|
|
v-for="(_, key) in headers"
|
2021-12-04 14:18:46 -09:00
|
|
|
:key="key"
|
|
|
|
v-model="headers[key]"
|
2025-06-20 00:09:12 +07:00
|
|
|
density="compact"
|
2021-12-04 14:18:46 -09:00
|
|
|
flat
|
|
|
|
inset
|
|
|
|
:label="headerLabels[key]"
|
|
|
|
hide-details
|
2025-06-20 00:09:12 +07:00
|
|
|
/>
|
2021-12-04 14:18:46 -09:00
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
|
|
|
</v-menu>
|
|
|
|
<BaseOverflowButton
|
|
|
|
:disabled="selected.length < 1"
|
|
|
|
mode="event"
|
|
|
|
color="info"
|
2025-06-20 00:09:12 +07:00
|
|
|
variant="elevated"
|
2021-12-04 14:18:46 -09:00
|
|
|
:items="actions"
|
|
|
|
@export-selected="openDialog(MODES.export)"
|
|
|
|
@tag-selected="openDialog(MODES.tag)"
|
|
|
|
@categorize-selected="openDialog(MODES.category)"
|
|
|
|
@delete-selected="openDialog(MODES.delete)"
|
2022-08-14 10:37:44 -08:00
|
|
|
@update-settings="openDialog(MODES.updateSettings)"
|
2024-10-19 04:33:32 -05:00
|
|
|
@change-owner="openDialog(MODES.changeOwner)"
|
2025-06-20 00:09:12 +07:00
|
|
|
/>
|
2021-12-04 14:18:46 -09:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
<p
|
|
|
|
v-if="selected.length > 0"
|
|
|
|
class="text-caption my-auto ml-5"
|
|
|
|
>
|
|
|
|
{{ $t('general.selected-count', selected.length)
|
|
|
|
}}
|
|
|
|
</p>
|
2021-12-04 14:18:46 -09:00
|
|
|
</v-card-actions>
|
|
|
|
<v-card>
|
2025-06-20 00:09:12 +07:00
|
|
|
<RecipeDataTable
|
|
|
|
v-model="selected"
|
|
|
|
:loading="loading"
|
|
|
|
:recipes="allRecipes"
|
|
|
|
:show-headers="headers"
|
|
|
|
/>
|
2021-12-04 14:18:46 -09:00
|
|
|
<v-card-actions class="justify-end">
|
|
|
|
<BaseButton
|
|
|
|
color="info"
|
|
|
|
@click="
|
|
|
|
selectAll();
|
|
|
|
openDialog(MODES.export);
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<template #icon>
|
|
|
|
{{ $globals.icons.database }}
|
|
|
|
</template>
|
2023-01-29 02:39:51 +01:00
|
|
|
{{ $t('general.export-all') }}
|
2021-12-04 14:18:46 -09:00
|
|
|
</BaseButton>
|
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section class="mt-10">
|
2023-11-21 14:44:41 +00:00
|
|
|
<!-- Data Table -->
|
2025-06-20 00:09:12 +07:00
|
|
|
<BaseCardSectionTitle
|
|
|
|
:icon="$globals.icons.database"
|
|
|
|
section
|
|
|
|
:title="$t('data-pages.recipes.data-exports')"
|
|
|
|
>
|
2023-01-29 02:39:51 +01:00
|
|
|
{{ $t('data-pages.recipes.data-exports-description') }}
|
2021-12-04 14:18:46 -09:00
|
|
|
</BaseCardSectionTitle>
|
|
|
|
<v-card-actions class="mt-n5 mb-1">
|
2025-06-20 00:09:12 +07:00
|
|
|
<BaseButton
|
|
|
|
delete
|
|
|
|
@click="purgeExportsDialog = true"
|
|
|
|
/>
|
2021-12-04 14:18:46 -09:00
|
|
|
</v-card-actions>
|
|
|
|
<v-card>
|
|
|
|
<GroupExportData :exports="groupExports" />
|
|
|
|
</v-card>
|
|
|
|
</section>
|
|
|
|
</v-container>
|
|
|
|
</template>
|
2022-01-09 07:15:23 +01:00
|
|
|
|
2021-12-04 14:18:46 -09:00
|
|
|
<script lang="ts">
|
|
|
|
import RecipeDataTable from "~/components/Domain/Recipe/RecipeDataTable.vue";
|
2022-06-03 20:12:32 -08:00
|
|
|
import RecipeOrganizerSelector from "~/components/Domain/Recipe/RecipeOrganizerSelector.vue";
|
2021-12-04 14:18:46 -09:00
|
|
|
import { useUserApi } from "~/composables/api";
|
|
|
|
import { useRecipes, allRecipes } from "~/composables/recipes";
|
2025-06-20 00:09:12 +07:00
|
|
|
import type { Recipe, RecipeSettings } from "~/lib/api/types/recipe";
|
2021-12-04 14:18:46 -09:00
|
|
|
import GroupExportData from "~/components/Domain/Group/GroupExportData.vue";
|
2025-06-20 00:09:12 +07:00
|
|
|
import type { GroupDataExport } from "~/lib/api/types/group";
|
|
|
|
import type { MenuItem } from "~/components/global/BaseOverflowButton.vue";
|
2022-08-14 10:37:44 -08:00
|
|
|
import RecipeSettingsSwitches from "~/components/Domain/Recipe/RecipeSettingsSwitches.vue";
|
2024-10-19 04:33:32 -05:00
|
|
|
import { useUserStore } from "~/composables/store/use-user-store";
|
|
|
|
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
|
|
|
|
import { useHouseholdStore } from "~/composables/store/use-household-store";
|
2021-12-04 14:18:46 -09:00
|
|
|
|
2022-08-14 10:37:44 -08:00
|
|
|
enum MODES {
|
|
|
|
tag = "tag",
|
|
|
|
category = "category",
|
|
|
|
export = "export",
|
|
|
|
delete = "delete",
|
|
|
|
updateSettings = "updateSettings",
|
2024-10-19 04:33:32 -05:00
|
|
|
changeOwner = "changeOwner",
|
2022-08-14 10:37:44 -08:00
|
|
|
}
|
2021-12-04 14:18:46 -09:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
export default defineNuxtComponent({
|
2024-10-19 04:33:32 -05:00
|
|
|
components: { RecipeDataTable, RecipeOrganizerSelector, GroupExportData, RecipeSettingsSwitches, UserAvatar },
|
2021-12-04 14:18:46 -09:00
|
|
|
scrollToTop: true,
|
|
|
|
setup() {
|
2025-06-20 00:09:12 +07:00
|
|
|
const i18n = useI18n();
|
|
|
|
const $auth = useMealieAuth();
|
|
|
|
const { $globals } = useNuxtApp();
|
|
|
|
|
|
|
|
useSeoMeta({
|
|
|
|
title: i18n.t("data-pages.recipes.recipe-data"),
|
|
|
|
});
|
|
|
|
|
|
|
|
const { getAllRecipes, refreshRecipes } = useRecipes(true, true, false, `householdId=${$auth.user.value?.householdId || ""}`);
|
2021-12-04 14:18:46 -09:00
|
|
|
const selected = ref<Recipe[]>([]);
|
|
|
|
|
|
|
|
function resetAll() {
|
|
|
|
selected.value = [];
|
|
|
|
toSetTags.value = [];
|
|
|
|
toSetCategories.value = [];
|
|
|
|
loading.value = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const headers = reactive({
|
|
|
|
id: false,
|
|
|
|
owner: false,
|
|
|
|
tags: true,
|
2022-01-16 03:38:11 +01:00
|
|
|
tools: true,
|
2021-12-04 14:18:46 -09:00
|
|
|
categories: true,
|
2024-11-20 08:46:27 -06:00
|
|
|
recipeServings: false,
|
|
|
|
recipeYieldQuantity: false,
|
2021-12-04 14:18:46 -09:00
|
|
|
recipeYield: false,
|
|
|
|
dateAdded: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
const headerLabels = {
|
2023-01-29 02:39:51 +01:00
|
|
|
id: i18n.t("general.id"),
|
|
|
|
owner: i18n.t("general.owner"),
|
|
|
|
tags: i18n.t("tag.tags"),
|
|
|
|
categories: i18n.t("recipe.categories"),
|
|
|
|
tools: i18n.t("tool.tools"),
|
2024-11-20 08:46:27 -06:00
|
|
|
recipeServings: i18n.t("recipe.recipe-servings"),
|
|
|
|
recipeYieldQuantity: i18n.t("recipe.recipe-yield"),
|
|
|
|
recipeYield: i18n.t("recipe.recipe-yield-text"),
|
2023-01-29 02:39:51 +01:00
|
|
|
dateAdded: i18n.t("general.date-added"),
|
2021-12-04 14:18:46 -09:00
|
|
|
};
|
|
|
|
|
2022-01-16 03:38:11 +01:00
|
|
|
const actions: MenuItem[] = [
|
2021-12-04 14:18:46 -09:00
|
|
|
{
|
|
|
|
icon: $globals.icons.database,
|
2025-06-20 00:09:12 +07:00
|
|
|
text: i18n.t("export.export"),
|
2021-12-04 14:18:46 -09:00
|
|
|
event: "export-selected",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: $globals.icons.tags,
|
2025-06-20 00:09:12 +07:00
|
|
|
text: i18n.t("data-pages.recipes.tag"),
|
2021-12-04 14:18:46 -09:00
|
|
|
event: "tag-selected",
|
|
|
|
},
|
|
|
|
{
|
2023-10-25 17:08:58 +02:00
|
|
|
icon: $globals.icons.categories,
|
2025-06-20 00:09:12 +07:00
|
|
|
text: i18n.t("data-pages.recipes.categorize"),
|
2021-12-04 14:18:46 -09:00
|
|
|
event: "categorize-selected",
|
|
|
|
},
|
2022-08-14 10:37:44 -08:00
|
|
|
{
|
|
|
|
icon: $globals.icons.cog,
|
2025-06-20 00:09:12 +07:00
|
|
|
text: i18n.t("data-pages.recipes.update-settings"),
|
2022-08-14 10:37:44 -08:00
|
|
|
event: "update-settings",
|
|
|
|
},
|
2024-10-19 04:33:32 -05:00
|
|
|
{
|
|
|
|
icon: $globals.icons.user,
|
2025-06-20 00:09:12 +07:00
|
|
|
text: i18n.t("general.change-owner"),
|
2024-10-19 04:33:32 -05:00
|
|
|
event: "change-owner",
|
|
|
|
},
|
2021-12-04 14:18:46 -09:00
|
|
|
{
|
|
|
|
icon: $globals.icons.delete,
|
2025-06-20 00:09:12 +07:00
|
|
|
text: i18n.t("general.delete"),
|
2021-12-04 14:18:46 -09:00
|
|
|
event: "delete-selected",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const api = useUserApi();
|
|
|
|
const loading = ref(false);
|
|
|
|
|
|
|
|
// ===============================================================
|
|
|
|
// Group Exports
|
|
|
|
|
|
|
|
const purgeExportsDialog = ref(false);
|
|
|
|
|
|
|
|
async function purgeExports() {
|
|
|
|
await api.bulk.purgeExports();
|
|
|
|
refreshExports();
|
|
|
|
}
|
|
|
|
|
|
|
|
const groupExports = ref<GroupDataExport[]>([]);
|
|
|
|
|
|
|
|
async function refreshExports() {
|
|
|
|
const { data } = await api.bulk.fetchExports();
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
groupExports.value = data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
await refreshExports();
|
|
|
|
});
|
|
|
|
// ===============================================================
|
|
|
|
// All Recipes
|
|
|
|
|
|
|
|
function selectAll() {
|
|
|
|
selected.value = allRecipes.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function exportSelected() {
|
|
|
|
loading.value = true;
|
|
|
|
const { data } = await api.bulk.bulkExport({
|
2022-01-09 07:15:23 +01:00
|
|
|
recipes: selected.value.map((x: Recipe) => x.slug ?? ""),
|
2021-12-04 14:18:46 -09:00
|
|
|
exportType: "json",
|
|
|
|
});
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
console.log(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
resetAll();
|
|
|
|
refreshExports();
|
|
|
|
}
|
|
|
|
|
|
|
|
const toSetTags = ref([]);
|
|
|
|
|
|
|
|
async function tagSelected() {
|
|
|
|
loading.value = true;
|
|
|
|
|
2022-01-09 07:15:23 +01:00
|
|
|
const recipes = selected.value.map((x: Recipe) => x.slug ?? "");
|
2021-12-04 14:18:46 -09:00
|
|
|
await api.bulk.bulkTag({ recipes, tags: toSetTags.value });
|
|
|
|
await refreshRecipes();
|
|
|
|
resetAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
const toSetCategories = ref([]);
|
|
|
|
|
|
|
|
async function categorizeSelected() {
|
|
|
|
loading.value = true;
|
|
|
|
|
2022-01-09 07:15:23 +01:00
|
|
|
const recipes = selected.value.map((x: Recipe) => x.slug ?? "");
|
2021-12-04 14:18:46 -09:00
|
|
|
await api.bulk.bulkCategorize({ recipes, categories: toSetCategories.value });
|
|
|
|
await refreshRecipes();
|
|
|
|
resetAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function deleteSelected() {
|
|
|
|
loading.value = true;
|
|
|
|
|
2022-01-09 07:15:23 +01:00
|
|
|
const recipes = selected.value.map((x: Recipe) => x.slug ?? "");
|
2021-12-04 14:18:46 -09:00
|
|
|
|
2024-10-19 04:33:32 -05:00
|
|
|
await api.bulk.bulkDelete({ recipes });
|
2021-12-04 14:18:46 -09:00
|
|
|
|
|
|
|
await refreshRecipes();
|
|
|
|
resetAll();
|
|
|
|
}
|
|
|
|
|
2022-08-14 10:37:44 -08:00
|
|
|
const recipeSettings = reactive<RecipeSettings>({
|
|
|
|
public: false,
|
|
|
|
showNutrition: false,
|
|
|
|
showAssets: false,
|
|
|
|
landscapeView: false,
|
|
|
|
disableComments: false,
|
|
|
|
disableAmount: false,
|
|
|
|
locked: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
async function updateSettings() {
|
|
|
|
loading.value = true;
|
|
|
|
|
|
|
|
const recipes = selected.value.map((x: Recipe) => x.slug ?? "");
|
|
|
|
|
2024-10-19 04:33:32 -05:00
|
|
|
await api.bulk.bulkSetSettings({ recipes, settings: recipeSettings });
|
2022-08-14 10:37:44 -08:00
|
|
|
|
2024-10-19 04:33:32 -05:00
|
|
|
await refreshRecipes();
|
|
|
|
resetAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function changeOwner() {
|
2025-06-20 00:09:12 +07:00
|
|
|
if (!selected.value.length || !selectedOwner.value) {
|
2024-10-19 04:33:32 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
selected.value.forEach((r) => {
|
|
|
|
r.userId = selectedOwner.value;
|
|
|
|
});
|
|
|
|
|
|
|
|
loading.value = true;
|
2024-10-19 15:36:34 -05:00
|
|
|
await api.recipes.patchMany(selected.value);
|
2022-08-14 10:37:44 -08:00
|
|
|
|
|
|
|
await refreshRecipes();
|
|
|
|
resetAll();
|
|
|
|
}
|
|
|
|
|
2021-12-04 14:18:46 -09:00
|
|
|
// ============================================================
|
|
|
|
// Dialog Management
|
|
|
|
|
|
|
|
const dialog = reactive({
|
|
|
|
state: false,
|
2023-01-29 02:39:51 +01:00
|
|
|
title: i18n.t("data-pages.recipes.tag-recipes"),
|
2021-12-04 14:18:46 -09:00
|
|
|
mode: MODES.tag,
|
|
|
|
tag: "",
|
2022-05-25 09:38:21 -08:00
|
|
|
callback: () => {
|
|
|
|
// Stub function to be overwritten
|
|
|
|
return Promise.resolve();
|
|
|
|
},
|
2021-12-04 14:18:46 -09:00
|
|
|
icon: $globals.icons.tags,
|
|
|
|
});
|
|
|
|
|
2022-08-14 10:37:44 -08:00
|
|
|
function openDialog(mode: MODES) {
|
|
|
|
const titles: Record<MODES, string> = {
|
2025-06-20 00:09:12 +07:00
|
|
|
[MODES.tag]: i18n.t("data-pages.recipes.tag-recipes"),
|
|
|
|
[MODES.category]: i18n.t("data-pages.recipes.categorize-recipes"),
|
|
|
|
[MODES.export]: i18n.t("data-pages.recipes.export-recipes"),
|
|
|
|
[MODES.delete]: i18n.t("data-pages.recipes.delete-recipes"),
|
|
|
|
[MODES.updateSettings]: i18n.t("data-pages.recipes.update-settings"),
|
|
|
|
[MODES.changeOwner]: i18n.t("general.change-owner"),
|
2021-12-04 14:18:46 -09:00
|
|
|
};
|
|
|
|
|
2022-08-14 10:37:44 -08:00
|
|
|
const callbacks: Record<MODES, () => Promise<void>> = {
|
2021-12-04 14:18:46 -09:00
|
|
|
[MODES.tag]: tagSelected,
|
|
|
|
[MODES.category]: categorizeSelected,
|
|
|
|
[MODES.export]: exportSelected,
|
|
|
|
[MODES.delete]: deleteSelected,
|
2022-08-14 10:37:44 -08:00
|
|
|
[MODES.updateSettings]: updateSettings,
|
2024-10-19 04:33:32 -05:00
|
|
|
[MODES.changeOwner]: changeOwner,
|
2021-12-04 14:18:46 -09:00
|
|
|
};
|
|
|
|
|
2022-08-14 10:37:44 -08:00
|
|
|
const icons: Record<MODES, string> = {
|
2021-12-04 14:18:46 -09:00
|
|
|
[MODES.tag]: $globals.icons.tags,
|
2023-10-25 17:08:58 +02:00
|
|
|
[MODES.category]: $globals.icons.categories,
|
2021-12-04 14:18:46 -09:00
|
|
|
[MODES.export]: $globals.icons.database,
|
|
|
|
[MODES.delete]: $globals.icons.delete,
|
2022-08-14 10:37:44 -08:00
|
|
|
[MODES.updateSettings]: $globals.icons.cog,
|
2024-10-19 04:33:32 -05:00
|
|
|
[MODES.changeOwner]: $globals.icons.user,
|
2021-12-04 14:18:46 -09:00
|
|
|
};
|
|
|
|
|
|
|
|
dialog.mode = mode;
|
|
|
|
dialog.title = titles[mode];
|
|
|
|
dialog.callback = callbacks[mode];
|
|
|
|
dialog.icon = icons[mode];
|
|
|
|
dialog.state = true;
|
|
|
|
}
|
|
|
|
|
2024-10-19 04:33:32 -05:00
|
|
|
const { store: allUsers } = useUserStore();
|
|
|
|
const { store: households } = useHouseholdStore();
|
|
|
|
const selectedOwner = ref("");
|
|
|
|
const selectedOwnerHousehold = computed(() => {
|
2025-06-20 00:09:12 +07:00
|
|
|
if (!selectedOwner.value) {
|
2024-10-19 04:33:32 -05:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
const owner = allUsers.value.find(u => u.id === selectedOwner.value);
|
2024-10-19 04:33:32 -05:00
|
|
|
if (!owner) {
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
return households.value.find(h => h.id === owner.householdId);
|
2024-10-19 04:33:32 -05:00
|
|
|
});
|
|
|
|
|
2021-12-04 14:18:46 -09:00
|
|
|
return {
|
2022-08-14 10:37:44 -08:00
|
|
|
recipeSettings,
|
2021-12-04 14:18:46 -09:00
|
|
|
selectAll,
|
|
|
|
loading,
|
|
|
|
actions,
|
|
|
|
allRecipes,
|
|
|
|
categorizeSelected,
|
|
|
|
deleteSelected,
|
|
|
|
dialog,
|
|
|
|
exportSelected,
|
|
|
|
getAllRecipes,
|
|
|
|
headerLabels,
|
|
|
|
headers,
|
|
|
|
MODES,
|
|
|
|
openDialog,
|
|
|
|
selected,
|
|
|
|
tagSelected,
|
|
|
|
toSetCategories,
|
|
|
|
toSetTags,
|
|
|
|
groupExports,
|
|
|
|
purgeExportsDialog,
|
|
|
|
purgeExports,
|
2024-10-19 04:33:32 -05:00
|
|
|
allUsers,
|
|
|
|
selectedOwner,
|
|
|
|
selectedOwnerHousehold,
|
2021-12-04 14:18:46 -09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2022-01-09 07:15:23 +01:00
|
|
|
</script>
|
2025-06-20 00:09:12 +07:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.v-btn--disabled {
|
|
|
|
opacity: 0.5 !important;
|
|
|
|
}
|
|
|
|
</style>
|