mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-10 15:05:35 -04:00
refactor group settings to use group settings form
This commit is contained in:
@@ -1,11 +1,24 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="preferences">
|
<div v-if="preferences">
|
||||||
<BaseCardSectionTitle :title="$t('group.general-preferences')" />
|
<BaseCardSectionTitle :title="$t('group.group-preferences')" />
|
||||||
<v-checkbox
|
<div class="mb-6">
|
||||||
v-model="preferences.privateGroup"
|
<v-checkbox
|
||||||
class="mt-n4"
|
v-model="preferences.privateGroup"
|
||||||
:label="$t('group.private-group')"
|
hide-details
|
||||||
/>
|
density="compact"
|
||||||
|
color="primary"
|
||||||
|
:label="$t('group.private-group')"
|
||||||
|
/>
|
||||||
|
<div class="ml-8">
|
||||||
|
<p class="text-subtitle-2 my-0 py-0">
|
||||||
|
{{ $t("group.private-group-description") }}
|
||||||
|
</p>
|
||||||
|
<DocLink
|
||||||
|
class="mt-2"
|
||||||
|
link="/documentation/getting-started/faq/#how-do-private-groups-and-recipes-work"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -14,5 +27,3 @@ import type { ReadGroupPreferences } from "~/lib/api/types/user";
|
|||||||
|
|
||||||
const preferences = defineModel<ReadGroupPreferences>({ required: true });
|
const preferences = defineModel<ReadGroupPreferences>({ required: true });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ export const useGroupSelf = function () {
|
|||||||
if (data) {
|
if (data) {
|
||||||
groupSelfRef.value.preferences = data;
|
groupSelfRef.value.preferences = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return data || undefined;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ async function handleSubmit() {
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
group.value = data;
|
group.value = data;
|
||||||
|
alert.success(i18n.t("settings.settings-updated"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert.error(i18n.t("settings.settings-update-failed"));
|
alert.error(i18n.t("settings.settings-update-failed"));
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container class="narrow-container">
|
<v-container
|
||||||
|
v-if="group"
|
||||||
|
class="narrow-container"
|
||||||
|
>
|
||||||
<BasePageTitle class="mb-5">
|
<BasePageTitle class="mb-5">
|
||||||
<template #header>
|
<template #header>
|
||||||
<v-img
|
<v-img
|
||||||
@@ -14,37 +17,26 @@
|
|||||||
</template>
|
</template>
|
||||||
{{ $t("profile.group-description") }}
|
{{ $t("profile.group-description") }}
|
||||||
</BasePageTitle>
|
</BasePageTitle>
|
||||||
|
<v-form ref="refGroupEditForm" @submit.prevent="handleSubmit">
|
||||||
<section v-if="group">
|
<v-card variant="outlined" style="border-color: lightgray;">
|
||||||
<BaseCardSectionTitle
|
<v-card-text>
|
||||||
class="mt-10"
|
<GroupPreferencesEditor v-if="group.preferences" v-model="group.preferences" />
|
||||||
:title="$t('group.group-preferences')"
|
</v-card-text>
|
||||||
/>
|
</v-card>
|
||||||
<div class="mb-6">
|
<div class="d-flex pa-2">
|
||||||
<v-checkbox
|
<BaseButton type="submit" edit class="ml-auto">
|
||||||
v-model="group.preferences.privateGroup"
|
{{ $t("general.update") }}
|
||||||
hide-details
|
</BaseButton>
|
||||||
density="compact"
|
|
||||||
color="primary"
|
|
||||||
:label="$t('group.private-group')"
|
|
||||||
@change="groupActions.updatePreferences()"
|
|
||||||
/>
|
|
||||||
<div class="ml-8">
|
|
||||||
<p class="text-subtitle-2 my-0 py-0">
|
|
||||||
{{ $t("group.private-group-description") }}
|
|
||||||
</p>
|
|
||||||
<DocLink
|
|
||||||
class="mt-2"
|
|
||||||
link="/documentation/getting-started/faq/#how-do-private-groups-and-recipes-work"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</v-form>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import GroupPreferencesEditor from "~/components/Domain/Group/GroupPreferencesEditor.vue";
|
||||||
import { useGroupSelf } from "~/composables/use-groups";
|
import { useGroupSelf } from "~/composables/use-groups";
|
||||||
|
import { alert } from "~/composables/use-toast";
|
||||||
|
import type { VForm } from "~/types/auto-forms";
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: ["can-manage-only"],
|
middleware: ["can-manage-only"],
|
||||||
@@ -56,6 +48,22 @@ const i18n = useI18n();
|
|||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title: i18n.t("group.group"),
|
title: i18n.t("group.group"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const refGroupEditForm = ref<VForm | null>(null);
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
if (!refGroupEditForm.value?.validate() || !group.value?.preferences) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await groupActions.updatePreferences();
|
||||||
|
if (data) {
|
||||||
|
alert.success(i18n.t("settings.settings-updated"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alert.error(i18n.t("settings.settings-update-failed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="css">
|
<style lang="css">
|
||||||
|
|||||||
Reference in New Issue
Block a user