From 60311d63061e0d704f8f80bfef748080bd255289 Mon Sep 17 00:00:00 2001 From: mister_papaye Date: Mon, 14 Sep 2026 20:17:47 +0200 Subject: [PATCH 1/4] feat: add standard Open Graph and Twitter Card meta tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit index.html had no og:* or twitter:* tags at all, so links shared to Discord/Slack/iMessage/etc. unfurled with nothing but a bare title. One static set of tags for the whole site (no per-route/per-org variants — the app is a plain client-rendered SPA with no dynamic server layer today, so per-context tags would need real infrastructure work out of scope here). Co-Authored-By: Claude Sonnet 5 --- index.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/index.html b/index.html index c721de74..0d39cd46 100644 --- a/index.html +++ b/index.html @@ -13,6 +13,24 @@ Synco. + + + + + + + + + + + + + + + + + + From 6fa9542f9c27f58d1aeac65cf948d8dc6297552e Mon Sep 17 00:00:00 2001 From: mister_papaye Date: Mon, 14 Sep 2026 21:18:50 +0200 Subject: [PATCH 2/4] feat(agenda): UI for calendar sharing (request/invite, read-only or write) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New CalendarAccessPanel.vue in the Agenda sidebar: toggle which shared calendars are overlaid (persisted per-org in localStorage), a search picker to request access to a colleague's agenda or proactively share your own, and a pending-requests section (incoming/outgoing, in both directions) with accept/decline — colocated with calendar management rather than left to the generic notification feed. New useCalendarAccess.ts composable owns the grants list and merges occurrences from every visible shared calendar (tagged with a per-calendar color) without touching useAgenda.ts's own "my events" state — which loses its dead viewingUserId/setViewingUser plumbing (never called, leftover from the removed "Équipes" cascade) now that multi-calendar overlay replaces the single-target "view as" mechanism it was built for. EventPanel.vue gains a "Créer dans" picker (create on a WRITE-access colleague's calendar instead of your own) and an "Ajouté par" badge when viewing an event created by a delegate. EventChip.vue falls back to a shared calendar's color when the event has no color of its own. useNotification.ts's click handler only special-cased CUSTOM's data.route; added a default case so the new CALENDAR_ACCESS_* types (and the pre-existing EVENT_* ones, previously dead ends) navigate too. NotificationType here was also out of sync with the backend enum. Co-Authored-By: Claude Sonnet 5 --- src/composables/useAgenda.ts | 39 +- src/composables/useCalendarAccess.ts | 236 ++++++++++ src/composables/useNotification.ts | 8 + src/types/agenda.ts | 71 +++ src/types/types.ts | 6 +- .../OrgSpace/views/Agenda/AgendaView.vue | 29 +- .../Agenda/components/CalendarAccessPanel.vue | 412 ++++++++++++++++++ .../views/Agenda/components/EventChip.vue | 9 +- .../views/Agenda/components/EventPanel.vue | 46 +- 9 files changed, 812 insertions(+), 44 deletions(-) create mode 100644 src/composables/useCalendarAccess.ts create mode 100644 src/views/OrgSpace/views/Agenda/components/CalendarAccessPanel.vue diff --git a/src/composables/useAgenda.ts b/src/composables/useAgenda.ts index 1e727c5d..01d73acb 100644 --- a/src/composables/useAgenda.ts +++ b/src/composables/useAgenda.ts @@ -2,10 +2,9 @@ // Composable pour la gestion de l'Agenda // ============================================ -import { ref, computed } from 'vue'; +import { ref } from 'vue'; import sfetch from '@/assets/utils/sfetch'; import { useToast } from './useToast'; -import { user } from '@/assets/var'; import type { CalendarEvent, CalendarEventWithDetails, @@ -39,12 +38,6 @@ const myReminders = ref([]); const loading = ref(false); const error = ref(null); -// Agenda affiché : soi-même par défaut, ou un membre dirigé (cascade Équipes). -// `null` = "moi" (résolu dynamiquement via `user`, jamais figé au chargement du module). -const viewingUserId = ref(null); - -const isViewingSelf = computed(() => !viewingUserId.value || viewingUserId.value === user.value?.id); - // ============================================ // Fonctions utilitaires internes // ============================================ @@ -58,17 +51,16 @@ function buildOccurrencePath(eventId: string, occurrenceStartAt: string): string // ============================================ /** - * Récupère les occurrences dans une plage de dates, pour soi ou (via le - * cascade Équipes) pour un membre dirigé. + * Récupère mes propres occurrences dans une plage de dates. Pour les + * calendriers partagés par des collègues, voir useCalendarAccess.ts:: + * fetchSharedOccurrences (state séparé, ne touche jamais `occurrences` ici). */ -async function fetchRange(orgId: string, from: string, to: string, userId?: string): Promise { +async function fetchRange(orgId: string, from: string, to: string): Promise { loading.value = true; error.value = null; try { - const targetUserId = userId ?? viewingUserId.value ?? undefined; const params = new URLSearchParams({ from, to }); - if (targetUserId) params.set('userId', targetUserId); const res = await sfetch(`/api/orgs/${orgId}/agenda/events?${params.toString()}`); @@ -498,20 +490,6 @@ async function listMyReminders(orgId: string): Promise([]); +const asGrantee = ref([]); +const sharedOccurrences = ref([]); +const loading = ref(false); + +// Demandes reçues sur MON agenda (quelqu'un demande à me lire/modifier) — +// c'est moi qui décide. +const incomingRequests = computed(() => asOwner.value.filter(g => g.status === 'PENDING' && g.initiatedBy === 'REQUESTER')); +// Invitations reçues à consulter/modifier l'agenda d'un tiers — c'est moi qui décide. +const incomingInvites = computed(() => asGrantee.value.filter(g => g.status === 'PENDING' && g.initiatedBy === 'OWNER')); +// Mes propres demandes/invitations envoyées, en attente de réponse de l'autre partie. +const outgoingRequests = computed(() => asGrantee.value.filter(g => g.status === 'PENDING' && g.initiatedBy === 'REQUESTER')); +const outgoingInvites = computed(() => asOwner.value.filter(g => g.status === 'PENDING' && g.initiatedBy === 'OWNER')); +const acceptedSharedCalendars = computed(() => asGrantee.value.filter(g => g.status === 'ACCEPTED')); + +function hiddenKey(orgId: string): string { + return `agenda-hidden-calendars:${orgId}`; +} + +function getHiddenIds(orgId: string): Set { + try { + const raw = localStorage.getItem(hiddenKey(orgId)); + return new Set(raw ? JSON.parse(raw) : []); + } catch { + return new Set(); + } +} + +function isVisible(orgId: string, grantId: string): boolean { + return !getHiddenIds(orgId).has(grantId); +} + +function toggleVisibility(orgId: string, grantId: string): void { + const hidden = getHiddenIds(orgId); + if (hidden.has(grantId)) hidden.delete(grantId); + else hidden.add(grantId); + localStorage.setItem(hiddenKey(orgId), JSON.stringify([...hidden])); +} + +function colorFor(grant: CalendarAccessGrantAsGrantee, index: number): string { + return grant.color || DEFAULT_COLORS[index % DEFAULT_COLORS.length] || DEFAULT_COLORS[0]!; +} + +async function fetchGrants(orgId: string): Promise { + loading.value = true; + try { + const res = await sfetch(`/api/orgs/${orgId}/agenda/access`); + if (!res.ok) { + const err: ApiErrorResponse = await res.json(); + throw new Error(err.error || "Erreur lors du chargement des accès à l'agenda"); + } + const data: ListMyGrantsResponse = await res.json(); + asOwner.value = data.asOwner; + asGrantee.value = data.asGrantee; + } catch (err: any) { + useToast().show(err.message || 'Erreur inconnue', 'error'); + } finally { + loading.value = false; + } +} + +async function requestAccess(orgId: string, ownerId: string, level: CalendarAccessLevel): Promise { + try { + const res = await sfetch(`/api/orgs/${orgId}/agenda/access/request`, { + method: 'POST', + body: JSON.stringify({ ownerId, level }) + }); + if (!res.ok) { + const err: ApiErrorResponse = await res.json(); + throw new Error(err.error || "Erreur lors de la demande d'accès"); + } + useToast().show('Demande envoyée', 'success'); + await fetchGrants(orgId); + return true; + } catch (err: any) { + useToast().show(err.message || 'Erreur inconnue', 'error'); + return false; + } +} + +async function inviteAccess(orgId: string, granteeId: string, level: CalendarAccessLevel): Promise { + try { + const res = await sfetch(`/api/orgs/${orgId}/agenda/access/invite`, { + method: 'POST', + body: JSON.stringify({ granteeId, level }) + }); + if (!res.ok) { + const err: ApiErrorResponse = await res.json(); + throw new Error(err.error || "Erreur lors de l'invitation"); + } + useToast().show('Invitation envoyée', 'success'); + await fetchGrants(orgId); + return true; + } catch (err: any) { + useToast().show(err.message || 'Erreur inconnue', 'error'); + return false; + } +} + +async function respondToGrant(orgId: string, grantId: string, action: 'ACCEPT' | 'DECLINE', level?: CalendarAccessLevel): Promise { + try { + const res = await sfetch(`/api/orgs/${orgId}/agenda/access/${grantId}/respond`, { + method: 'PATCH', + body: JSON.stringify({ action, level }) + }); + if (!res.ok) { + const err: ApiErrorResponse = await res.json(); + throw new Error(err.error || 'Erreur lors de la réponse'); + } + const data: GrantResponse = await res.json(); + useToast().show(action === 'ACCEPT' ? 'Accès accordé' : 'Demande refusée', 'success'); + await fetchGrants(orgId); + return data.grant.status === 'ACCEPTED'; + } catch (err: any) { + useToast().show(err.message || 'Erreur inconnue', 'error'); + return false; + } +} + +async function revokeGrant(orgId: string, grantId: string): Promise { + // Capturé avant l'appel : une fois révoqué, le grant peut disparaître des + // listes rechargées par fetchGrants, on ne pourrait plus retrouver son + // ownerId pour purger sharedOccurrences. + const ownerId = asGrantee.value.find(g => g.id === grantId)?.ownerId; + try { + const res = await sfetch(`/api/orgs/${orgId}/agenda/access/${grantId}`, { method: 'DELETE' }); + if (!res.ok) { + const err: ApiErrorResponse = await res.json(); + throw new Error(err.error || "Erreur lors du retrait de l'accès"); + } + useToast().show('Accès retiré', 'success'); + await fetchGrants(orgId); + if (ownerId) sharedOccurrences.value = sharedOccurrences.value.filter(o => o.sourceOwnerId !== ownerId); + return true; + } catch (err: any) { + useToast().show(err.message || 'Erreur inconnue', 'error'); + return false; + } +} + +async function setColor(orgId: string, grantId: string, color: string): Promise { + try { + const res = await sfetch(`/api/orgs/${orgId}/agenda/access/${grantId}/color`, { + method: 'PATCH', + body: JSON.stringify({ color }) + }); + if (!res.ok) return false; + await fetchGrants(orgId); + return true; + } catch { + return false; + } +} + +// Récupère et fusionne les occurrences de tous les calendriers partagés +// actuellement visibles (accès accepté + non masqué), taguées par calendrier +// source pour l'affichage superposé. N'affecte jamais l'agenda "moi" (voir +// useAgenda.ts::fetchRange, séparé). +async function fetchSharedOccurrences(orgId: string, from: string, to: string): Promise { + const visible = acceptedSharedCalendars.value.filter(g => isVisible(orgId, g.id)); + if (visible.length === 0) { + sharedOccurrences.value = []; + return; + } + + const results = await Promise.all(visible.map(async (grant, index) => { + try { + const params = new URLSearchParams({ from, to, userId: grant.ownerId }); + const res = await sfetch(`/api/orgs/${orgId}/agenda/events?${params.toString()}`); + if (!res.ok) return []; + const data = await res.json(); + const color = colorFor(grant, index); + return (data.occurrences || []).map((o: any) => ({ ...o, sourceOwnerId: grant.ownerId, sourceColor: color })); + } catch { + return []; + } + })); + + sharedOccurrences.value = results.flat(); +} + +function resetState(): void { + asOwner.value = []; + asGrantee.value = []; + sharedOccurrences.value = []; +} + +export function useCalendarAccess() { + return { + asOwner, + asGrantee, + sharedOccurrences, + loading, + incomingRequests, + incomingInvites, + outgoingRequests, + outgoingInvites, + acceptedSharedCalendars, + + fetchGrants, + requestAccess, + inviteAccess, + respondToGrant, + revokeGrant, + setColor, + fetchSharedOccurrences, + + isVisible, + toggleVisibility, + colorFor, + + resetState + }; +} diff --git a/src/composables/useNotification.ts b/src/composables/useNotification.ts index a775f9ce..3b7bc9d5 100644 --- a/src/composables/useNotification.ts +++ b/src/composables/useNotification.ts @@ -500,6 +500,14 @@ export function useNotification() { router.push(notification.data.route); } break; + // EVENT_*/CALENDAR_ACCESS_* (et tout futur type) n'ont pas de route + // dédiée codée en dur ici — le backend fournit data.route directement + // (voir agendaService.ts / calendarAccessService.ts). + default: + if (notification.data?.route) { + router.push(notification.data.route); + } + break; } }; diff --git a/src/types/agenda.ts b/src/types/agenda.ts index 79284982..3d8ee0f2 100644 --- a/src/types/agenda.ts +++ b/src/types/agenda.ts @@ -89,6 +89,10 @@ export interface EventReminder { export interface CalendarEventWithDetails extends CalendarEvent { attendees: EventAttendee[]; reminders: EventReminder[]; // rappels de l'appelant uniquement + // Renseigné quand l'événement a été créé par un tiers ayant un accès en + // modification sur cet agenda (voir CalendarAccessGrant) — creatorId reste + // le propriétaire de l'agenda. + createdByDelegateId: string | null; } // ============================================ @@ -143,6 +147,10 @@ export interface CreateEventDTO { color?: string | null; recurrenceRule?: RecurrenceRule | null; attendeeIds?: string[]; + // Créer l'événement pour le compte d'un tiers dont on a l'accès en + // modification (voir CalendarAccessGrant) — l'événement apparaît sur son + // agenda, pas sur le sien. + onBehalfOfUserId?: string; } // PATCH accepte un sous-ensemble quelconque des mêmes champs @@ -241,3 +249,66 @@ export interface AgendaRsvpUpdatedEvent { eventId: string; attendee: EventAttendee; } + +// ============================================ +// Partage d'agenda (CalendarAccessGrant) +// ============================================ +export type CalendarAccessLevel = 'READ' | 'WRITE'; +export type CalendarAccessStatus = 'PENDING' | 'ACCEPTED' | 'DECLINED' | 'REVOKED'; +export type CalendarGrantInitiator = 'REQUESTER' | 'OWNER'; + +export interface UserSummary { + id: string; + name: string; + pseudo: string | null; + avatarUrl: string | null; +} + +export interface CalendarAccessGrant { + id: string; + organizationId: string; + ownerId: string; + granteeId: string; + level: CalendarAccessLevel; + status: CalendarAccessStatus; + initiatedBy: CalendarGrantInitiator; + color: string | null; + requestedAt: string; + respondedAt: string | null; + createdAt: string; + updatedAt: string; +} + +export interface CalendarAccessGrantAsOwner extends CalendarAccessGrant { + grantee: UserSummary; +} + +export interface CalendarAccessGrantAsGrantee extends CalendarAccessGrant { + owner: UserSummary; +} + +export interface ListMyGrantsResponse { + asOwner: CalendarAccessGrantAsOwner[]; + asGrantee: CalendarAccessGrantAsGrantee[]; +} + +export interface GrantResponse { + grant: CalendarAccessGrant; +} + +export interface RevokeGrantResponse { + success: true; + grantId: string; +} + +export interface AgendaAccessUpdatedEvent { + grant: CalendarAccessGrant; +} + +// Occurrence taguée par calendrier source, construite côté client en +// fusionnant mon agenda avec les agendas partagés visibles (voir +// useAgenda.ts::fetchRange) — jamais renvoyée telle quelle par l'API. +export interface MergedOccurrence extends OccurrenceInstance { + sourceOwnerId: string; + sourceColor: string; +} diff --git a/src/types/types.ts b/src/types/types.ts index 343c2deb..f4f9fcec 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -1,5 +1,9 @@ export type ThreadType = 'text' | 'vocal'; -export type NotificationType = 'MESSAGE' | 'CALL' | 'MENTION' | 'INVITATION' | 'CUSTOM'; +export type NotificationType = + | 'MESSAGE' | 'CALL' | 'MENTION' | 'INVITATION' | 'CUSTOM' + | 'EVENT_INVITE' | 'EVENT_RSVP' | 'EVENT_REMINDER' + | 'CALENDAR_ACCESS_REQUEST' | 'CALENDAR_ACCESS_INVITE' + | 'CALENDAR_ACCESS_GRANTED' | 'CALENDAR_ACCESS_DECLINED' | 'CALENDAR_ACCESS_REVOKED'; // export type UserStatus = 'online' | 'dnd' | 'idle' | 'offline'; export interface StoredFile { diff --git a/src/views/OrgSpace/views/Agenda/AgendaView.vue b/src/views/OrgSpace/views/Agenda/AgendaView.vue index 01b763d7..c5747e82 100644 --- a/src/views/OrgSpace/views/Agenda/AgendaView.vue +++ b/src/views/OrgSpace/views/Agenda/AgendaView.vue @@ -41,6 +41,7 @@ @pick-day="goToDay" @navigate-month="navigateMiniMonth" /> +
@@ -111,7 +112,9 @@ import DayGrid from './components/DayGrid.vue'; import MiniCalendar from './components/MiniCalendar.vue'; import EventQuickCreate from './components/EventQuickCreate.vue'; import EventPanel from './components/EventPanel.vue'; +import CalendarAccessPanel from './components/CalendarAccessPanel.vue'; import { useAgenda } from '@/composables/useAgenda'; +import { useCalendarAccess } from '@/composables/useCalendarAccess'; import useWSocket from '@/composables/useWSocket'; import sfetch from '@/assets/utils/sfetch'; import { user } from '@/assets/var'; @@ -122,7 +125,8 @@ const route = useRoute(); const router = useRouter(); const orgId = computed(() => route.params.orgId as string); -const { occurrences, loading, viewingUserId, fetchRange, updateEvent, updateOccurrence } = useAgenda(); +const { occurrences, loading, fetchRange, updateEvent, updateOccurrence } = useAgenda(); +const { sharedOccurrences, fetchGrants, fetchSharedOccurrences } = useCalendarAccess(); // ── Échéances de tâches affichées comme événements dans l'agenda ────── // Pseudo-occurrences synthétisées côté front à partir des tâches qui me @@ -174,8 +178,9 @@ const taskDeadlineOccurrences = computed(() => { }); }); -// Fusion événements réels + échéances de tâches pour l'affichage dans les grilles. -const displayOccurrences = computed(() => [...occurrences.value, ...taskDeadlineOccurrences.value]); +// Fusion événements réels (mon agenda + agendas partagés visibles, voir +// useCalendarAccess.ts) + échéances de tâches pour l'affichage dans les grilles. +const displayOccurrences = computed(() => [...occurrences.value, ...sharedOccurrences.value, ...taskDeadlineOccurrences.value]); type ViewMode = 'month' | 'week' | 'day'; const viewMode = ref('month'); @@ -237,7 +242,10 @@ function computeRangeISO(): { from: string; to: string } { async function refetch() { const { from, to } = computeRangeISO(); - await fetchRange(orgId.value, from, to); + await Promise.all([ + fetchRange(orgId.value, from, to), + fetchSharedOccurrences(orgId.value, from, to) + ]); } function goPrev() { @@ -378,11 +386,20 @@ async function onReschedule({ occ, start, end }: { occ: OccurrenceInstance; star refetch(); } -watch([viewMode, cursorDate, viewingUserId], () => { +watch([viewMode, cursorDate], () => { refetch(); }); +// Un changement d'accès (demande acceptée/refusée, partage retiré...) +// affecte quels agendas sont superposables : on recharge la liste des +// accès puis les occurrences partagées visibles en découlent. +async function onAccessUpdated() { + await fetchGrants(orgId.value); + refetch(); +} + onMounted(async () => { + await fetchGrants(orgId.value); refetch(); loadTaskDeadlines(); @@ -393,6 +410,7 @@ onMounted(async () => { socket.value?.on('agenda:occurrence-updated', refetch); socket.value?.on('agenda:occurrence-cancelled', refetch); socket.value?.on('agenda:rsvp-updated', refetch); + socket.value?.on('agenda:access-updated', onAccessUpdated); }); onUnmounted(async () => { @@ -403,6 +421,7 @@ onUnmounted(async () => { socket.value?.off('agenda:occurrence-updated', refetch); socket.value?.off('agenda:occurrence-cancelled', refetch); socket.value?.off('agenda:rsvp-updated', refetch); + socket.value?.off('agenda:access-updated', onAccessUpdated); }); diff --git a/src/views/OrgSpace/views/Agenda/components/CalendarAccessPanel.vue b/src/views/OrgSpace/views/Agenda/components/CalendarAccessPanel.vue new file mode 100644 index 00000000..1128a31f --- /dev/null +++ b/src/views/OrgSpace/views/Agenda/components/CalendarAccessPanel.vue @@ -0,0 +1,412 @@ + + + + + diff --git a/src/views/OrgSpace/views/Agenda/components/EventChip.vue b/src/views/OrgSpace/views/Agenda/components/EventChip.vue index 85c793a5..031e0f54 100644 --- a/src/views/OrgSpace/views/Agenda/components/EventChip.vue +++ b/src/views/OrgSpace/views/Agenda/components/EventChip.vue @@ -15,11 +15,11 @@