front > menu > account : link conditionally to panel or front account depending on user role

This commit is contained in:
isUnknown 2025-05-05 15:53:12 +02:00
parent c3119a5cab
commit 4113c69ccf
2 changed files with 45 additions and 38 deletions

View file

@ -18,6 +18,9 @@ return function ($page, $kirby, $site) {
"name" => (string) $kirby->user()->client()->toPage()->title(), "name" => (string) $kirby->user()->client()->toPage()->title(),
"uuid" => (string) $kirby->user()->client()->toPage()->uuid() "uuid" => (string) $kirby->user()->client()->toPage()->uuid()
]; ];
if ($kirby->user()->client()->toPage()->logo()->isNotEmpty()) {
$userData['client']["logo"] = $kirby->user()->client()->toPage()->logo()->toFile()->url();
}
} }
if ($kirby->user()->projects()->exists() && $kirby->user()->projects()->isNotEmpty()) { if ($kirby->user()->projects()->exists() && $kirby->user()->projects()->isNotEmpty()) {

View file

@ -15,7 +15,7 @@
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<title id="menu-toggle"> <title id="menu-toggle">
{{ isExpanded ? "Masquer le menu" : "Afficher le menu" }} {{ isExpanded ? 'Masquer le menu' : 'Afficher le menu' }}
</title> </title>
<path <path
d="M10.6751 2.625L3.00007 10.3125C2.94028 10.3686 2.89263 10.4364 2.86005 10.5116C2.82748 10.5869 2.81067 10.668 2.81067 10.75C2.81067 10.832 2.82748 10.9131 2.86005 10.9884C2.89263 11.0636 2.94028 11.1314 3.00007 11.1875L10.6751 18.875M17.1876 2.625L9.50007 10.3125C9.38555 10.4293 9.32141 10.5864 9.32141 10.75C9.32141 10.9136 9.38555 11.0707 9.50007 11.1875L17.1876 18.875" d="M10.6751 2.625L3.00007 10.3125C2.94028 10.3686 2.89263 10.4364 2.86005 10.5116C2.82748 10.5869 2.81067 10.668 2.81067 10.75C2.81067 10.832 2.82748 10.9131 2.86005 10.9884C2.89263 11.0636 2.94028 11.1314 3.00007 11.1875L10.6751 18.875M17.1876 2.625L9.50007 10.3125C9.38555 10.4293 9.32141 10.5864 9.32141 10.75C9.32141 10.9136 9.38555 11.0707 9.50007 11.1875L17.1876 18.875"
@ -53,7 +53,7 @@
<span <span
v-if="mainItem.title === 'Inspirations' && page?.newInspirations" v-if="mainItem.title === 'Inspirations' && page?.newInspirations"
class="pill pill--secondary" class="pill pill--secondary"
>{{ "Nouveautés" }}</span >{{ 'Nouveautés' }}</span
> >
</li> </li>
</ul> </ul>
@ -95,7 +95,11 @@
<footer class="w-full"> <footer class="w-full">
<ul class="flex"> <ul class="flex">
<li data-icon="user"> <li data-icon="user">
<a href="/panel/account" @click="collapse()">Profil</a> <a
:href="user.role === 'admin' ? '/panel/account' : '/account'"
@click="collapse()"
>Profil</a
>
</li> </li>
<li data-icon="logout"> <li data-icon="logout">
<a href="/logout" @click="collapse()">Déconnexion</a> <a href="/logout" @click="collapse()">Déconnexion</a>
@ -106,13 +110,13 @@
</template> </template>
<script setup> <script setup>
import { storeToRefs } from "pinia"; import { storeToRefs } from 'pinia';
import { computed, ref } from "vue"; import { computed, ref } from 'vue';
import { useProjectsStore } from "../stores/projects"; import { useProjectsStore } from '../stores/projects';
import { useRoute } from "vue-router"; import { useRoute } from 'vue-router';
import { useUserStore } from "../stores/user"; import { useUserStore } from '../stores/user';
import { usePageStore } from "../stores/page"; import { usePageStore } from '../stores/page';
import { useProjectStore } from "../stores/project"; import { useProjectStore } from '../stores/project';
const route = useRoute(); const route = useRoute();
const isExpanded = ref(true); const isExpanded = ref(true);
@ -132,30 +136,30 @@ const unreadNotificationsCount = computed(() => {
const mainItems = [ const mainItems = [
{ {
title: "Home", title: 'Home',
path: "/", path: '/',
icon: "home", icon: 'home',
}, },
{ {
title: "Notifications", title: 'Notifications',
path: "/notifications", path: '/notifications',
icon: "megaphone", icon: 'megaphone',
}, },
{ {
title: "Réunions", title: 'Réunions',
path: "/reunions", path: '/reunions',
icon: "calendar", icon: 'calendar',
disabled: true, disabled: true,
}, },
{ {
title: "Design to Light", title: 'Design to Light',
path: "/design-to-light", path: '/design-to-light',
icon: "leaf", icon: 'leaf',
}, },
{ {
title: "Inspirations", title: 'Inspirations',
path: "/inspirations", path: '/inspirations',
icon: "inspiration", icon: 'inspiration',
}, },
]; ];
@ -176,7 +180,7 @@ function hasUnreadNotification(project) {
if (!user.value) return false; if (!user.value) return false;
return notifications.value.some((notification) => { return notifications.value.some((notification) => {
return ( return (
notification.isread != "true" && notification.isread != 'true' &&
project.uri.includes(notification.location.project.uri) project.uri.includes(notification.location.project.uri)
); );
}); });
@ -190,31 +194,31 @@ function collapse() {
</script> </script>
<style> <style>
button[aria-controls="menu"] { button[aria-controls='menu'] {
position: fixed; position: fixed;
z-index: 101; z-index: 101;
width: 2.5rem; width: 2.5rem;
height: 2.5rem; height: 2.5rem;
} }
button[aria-controls="menu"] svg { button[aria-controls='menu'] svg {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
button[aria-controls="menu"][aria-expanded="true"] { button[aria-controls='menu'][aria-expanded='true'] {
margin-top: 1rem; margin-top: 1rem;
padding: 0.625rem; /* 10px */ padding: 0.625rem; /* 10px */
left: var(--gutter); left: var(--gutter);
transform: translateX(calc(var(--sidebar-width) - 100% - 1rem)); transform: translateX(calc(var(--sidebar-width) - 100% - 1rem));
} }
button[aria-controls="menu"][aria-expanded="false"] { button[aria-controls='menu'][aria-expanded='false'] {
min-width: 3.5rem; min-width: 3.5rem;
min-height: 3.5rem; min-height: 3.5rem;
padding: 1.125rem; padding: 1.125rem;
transform: rotate(180deg); transform: rotate(180deg);
} }
button[aria-controls="menu"][aria-expanded="false"] button[aria-controls='menu'][aria-expanded='false']
+ main + main
> header:not([role="tablist"]) { > header:not([role='tablist']) {
margin-left: 4rem; margin-left: 4rem;
width: calc(100% - 4rem); width: calc(100% - 4rem);
} }
@ -238,7 +242,7 @@ button[aria-controls="menu"][aria-expanded="false"]
} }
@media (max-width: 1023px) { @media (max-width: 1023px) {
button[aria-controls="menu"][aria-expanded="true"] { button[aria-controls='menu'][aria-expanded='true'] {
left: 0; left: 0;
margin-top: 0.4rem; margin-top: 0.4rem;
} }
@ -252,8 +256,8 @@ button[aria-controls="menu"][aria-expanded="false"]
height: 100vh; height: 100vh;
padding-top: 2.5rem; padding-top: 2.5rem;
} }
button[aria-controls="menu"][aria-expanded="true"] + #menu::before { button[aria-controls='menu'][aria-expanded='true'] + #menu::before {
content: ""; content: '';
position: fixed; position: fixed;
top: 0; top: 0;
right: 0; right: 0;
@ -281,7 +285,7 @@ button[aria-controls="menu"][aria-expanded="false"]
z-index: 1; z-index: 1;
} }
#menu header::before { #menu header::before {
content: ""; content: '';
display: block; display: block;
position: absolute; position: absolute;
top: -1rem; top: -1rem;
@ -350,7 +354,7 @@ button[aria-controls="menu"][aria-expanded="false"]
align-items: center; align-items: center;
} }
#menu li a::before { #menu li a::before {
content: ""; content: '';
position: absolute; position: absolute;
inset: 0; inset: 0;
z-index: 1; z-index: 1;
@ -386,7 +390,7 @@ button[aria-controls="menu"][aria-expanded="false"]
width: fit-content; width: fit-content;
} }
#menu details .new::after { #menu details .new::after {
content: "" / "Nouvelles modifications"; content: '' / 'Nouvelles modifications';
color: transparent; color: transparent;
position: relative; position: relative;
display: inline-block; display: inline-block;