mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-10 23:15:34 -04:00
add announcements composable and dialog component
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
<template>
|
||||||
|
<BaseDialog
|
||||||
|
v-model="dialog"
|
||||||
|
>
|
||||||
|
test <!-- TODO -->
|
||||||
|
</BaseDialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const dialog = defineModel<boolean>({ default: false });
|
||||||
|
</script>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-navigation-drawer v-model="modelValue" class="d-flex flex-column d-print-none position-fixed" touchless>
|
<v-navigation-drawer v-model="modelValue" class="d-flex flex-column d-print-none position-fixed" touchless>
|
||||||
|
<AnnouncementDialog v-model="showAnnouncementsDialog" />
|
||||||
<LanguageDialog v-model="state.languageDialog" />
|
<LanguageDialog v-model="state.languageDialog" />
|
||||||
<!-- User Profile -->
|
<!-- User Profile -->
|
||||||
<template v-if="loggedIn && sessionUser">
|
<template v-if="loggedIn && sessionUser">
|
||||||
@@ -117,6 +118,24 @@
|
|||||||
<!-- Bottom Navigation Links -->
|
<!-- Bottom Navigation Links -->
|
||||||
<template #append>
|
<template #append>
|
||||||
<v-list v-model:selected="state.bottomSelected" nav density="comfortable">
|
<v-list v-model:selected="state.bottomSelected" nav density="comfortable">
|
||||||
|
<v-list-item
|
||||||
|
v-if="loggedIn && announcementsEnabled"
|
||||||
|
:title="$t('announcements.announcements')"
|
||||||
|
@click="() => showAnnouncementsDialog = !showAnnouncementsDialog"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
<v-badge
|
||||||
|
:model-value="!!newAnnouncements?.length"
|
||||||
|
color="accent"
|
||||||
|
:content="newAnnouncements?.length"
|
||||||
|
offset-x="-2"
|
||||||
|
>
|
||||||
|
<v-icon>
|
||||||
|
{{ $globals.icons.bullhornVariant }}
|
||||||
|
</v-icon>
|
||||||
|
</v-badge>
|
||||||
|
</template>
|
||||||
|
</v-list-item>
|
||||||
<v-menu location="end bottom" :offset="15">
|
<v-menu location="end bottom" :offset="15">
|
||||||
<template #activator="{ props: hoverProps }">
|
<template #activator="{ props: hoverProps }">
|
||||||
<v-list-item v-bind="hoverProps" :prepend-icon="$globals.icons.cog" :title="$t('general.settings')" />
|
<v-list-item v-bind="hoverProps" :prepend-icon="$globals.icons.cog" :title="$t('general.settings')" />
|
||||||
@@ -139,8 +158,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useLoggedInState } from "~/composables/use-logged-in-state";
|
import { useLoggedInState } from "~/composables/use-logged-in-state";
|
||||||
import type { SidebarLinks } from "~/types/application-types";
|
import type { SidebarLinks } from "~/types/application-types";
|
||||||
|
import AnnouncementDialog from "~/components/Domain/Announcement/AnnouncementDialog.vue";
|
||||||
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
|
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
|
||||||
import { useToggleDarkMode } from "~/composables/use-utils";
|
import { useToggleDarkMode } from "~/composables/use-utils";
|
||||||
|
import { useAnnouncements } from "~/composables/use-announcements";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
user: {
|
user: {
|
||||||
@@ -171,6 +192,9 @@ const userProfileLink = computed(() => auth.user.value ? "/user/profile" : undef
|
|||||||
|
|
||||||
const toggleDark = useToggleDarkMode();
|
const toggleDark = useToggleDarkMode();
|
||||||
|
|
||||||
|
const showAnnouncementsDialog = ref(false);
|
||||||
|
const { announcementsEnabled, newAnnouncements } = useAnnouncements();
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
dropDowns: {} as Record<string, boolean>,
|
dropDowns: {} as Record<string, boolean>,
|
||||||
secondarySelected: null as string[] | null,
|
secondarySelected: null as string[] | null,
|
||||||
|
|||||||
36
frontend/composables/use-announcements.ts
Normal file
36
frontend/composables/use-announcements.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { useHouseholdSelf } from "~/composables/use-households";
|
||||||
|
import { useGroupSelf } from "~/composables/use-groups";
|
||||||
|
|
||||||
|
export function useAnnouncements() {
|
||||||
|
const auth = useMealieAuth();
|
||||||
|
const { household } = useHouseholdSelf();
|
||||||
|
const { group } = useGroupSelf();
|
||||||
|
|
||||||
|
const announcementsEnabled = computed(
|
||||||
|
() =>
|
||||||
|
!!(
|
||||||
|
auth.user.value?.showAnnouncements
|
||||||
|
&& household.value?.preferences?.showAnnouncements
|
||||||
|
&& group.value?.preferences?.showAnnouncements
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const newAnnouncements = ref<string[] | undefined>();
|
||||||
|
function refreshUnreadAnnouncements() {
|
||||||
|
if (!auth.user.value) {
|
||||||
|
newAnnouncements.value = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
newAnnouncements.value = []; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshUnreadAnnouncements();
|
||||||
|
watch(() => auth.user, () => {
|
||||||
|
refreshUnreadAnnouncements();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
announcementsEnabled,
|
||||||
|
newAnnouncements,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1474,6 +1474,7 @@
|
|||||||
"max-length": "Must Be At Most {max} Character|Must Be At Most {max} Characters"
|
"max-length": "Must Be At Most {max} Character|Must Be At Most {max} Characters"
|
||||||
},
|
},
|
||||||
"announcements": {
|
"announcements": {
|
||||||
|
"announcements": "Announcements",
|
||||||
"show-announcements-from-mealie": "Show announcements from Mealie",
|
"show-announcements-from-mealie": "Show announcements from Mealie",
|
||||||
"show-announcements-setting-description": "Whether or not you want to allow users to see announcements from Mealie. When enabled users can still opt-out from seeing them in their user settings"
|
"show-announcements-setting-description": "Whether or not you want to allow users to see announcements from Mealie. When enabled users can still opt-out from seeing them in their user settings"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
mdiBookOutline,
|
mdiBookOutline,
|
||||||
mdiBowlMixOutline,
|
mdiBowlMixOutline,
|
||||||
mdiBroom,
|
mdiBroom,
|
||||||
|
mdiBullhornVariant,
|
||||||
mdiCalendar,
|
mdiCalendar,
|
||||||
mdiCalendarMinus,
|
mdiCalendarMinus,
|
||||||
mdiCalendarMultiselect,
|
mdiCalendarMultiselect,
|
||||||
@@ -181,6 +182,7 @@ export const icons = {
|
|||||||
bellAlert: mdiBellAlert,
|
bellAlert: mdiBellAlert,
|
||||||
bellPlus: mdiBellPlus,
|
bellPlus: mdiBellPlus,
|
||||||
broom: mdiBroom,
|
broom: mdiBroom,
|
||||||
|
bullhornVariant: mdiBullhornVariant,
|
||||||
calendar: mdiCalendar,
|
calendar: mdiCalendar,
|
||||||
calendarMinus: mdiCalendarMinus,
|
calendarMinus: mdiCalendarMinus,
|
||||||
calendarMultiselect: mdiCalendarMultiselect,
|
calendarMultiselect: mdiCalendarMultiselect,
|
||||||
|
|||||||
Reference in New Issue
Block a user