Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d95f9e782 | |||
| c766e76624 | |||
| 267cea76da | |||
| 6938616064 | |||
| 386242c84d | |||
| 41a98f93ee | |||
| aad949c10c | |||
| ad029f5c7d | |||
| 99626b89da | |||
| 94e6abcbaa | |||
| 04be081ffd | |||
| 435c7fcfc2 | |||
| 5764d8f472 | |||
| 052ef55c79 | |||
| 302d2c7221 | |||
| cf3d11a8a3 | |||
| b467dbc584 | |||
| 17a0566f77 |
@@ -113,6 +113,14 @@ services:
|
||||
|
||||
App\Module\Directory\Domain\Repository\ProspectRepositoryInterface: '@App\Module\Directory\Infrastructure\Doctrine\DoctrineProspectRepository'
|
||||
|
||||
App\Module\Directory\Domain\Repository\PrestataireRepositoryInterface: '@App\Module\Directory\Infrastructure\Doctrine\DoctrinePrestataireRepository'
|
||||
|
||||
App\Module\Directory\Domain\Repository\ContactRepositoryInterface: '@App\Module\Directory\Infrastructure\Doctrine\DoctrineContactRepository'
|
||||
|
||||
App\Module\Directory\Domain\Repository\AddressRepositoryInterface: '@App\Module\Directory\Infrastructure\Doctrine\DoctrineAddressRepository'
|
||||
|
||||
App\Module\Directory\Domain\Repository\CommercialReportRepositoryInterface: '@App\Module\Directory\Infrastructure\Doctrine\DoctrineCommercialReportRepository'
|
||||
|
||||
App\Module\Directory\Infrastructure\EventListener\CommercialReportAuthorListener:
|
||||
tags:
|
||||
- { name: doctrine.orm.entity_listener, entity: 'App\Module\Directory\Domain\Entity\CommercialReport', event: prePersist }
|
||||
|
||||
+9
-2
@@ -26,7 +26,14 @@ return [
|
||||
['label' => 'sidebar.general.myTasks', 'to' => '/my-tasks', 'icon' => 'mdi:clipboard-check-outline', 'module' => 'project-management', 'permission' => 'project-management.tasks.view'],
|
||||
['label' => 'sidebar.general.projects', 'to' => '/projects', 'icon' => 'mdi:folder-outline', 'module' => 'project-management', 'permission' => 'project-management.projects.view'],
|
||||
['label' => 'sidebar.general.timeTracking', 'to' => '/time-tracking', 'icon' => 'mdi:calendar-edit-outline', 'module' => 'time-tracking', 'permission' => 'time-tracking.entries.view'],
|
||||
// Gating module uniquement (cf. en-tête) : rendu visuel + badge gérés côté layout.
|
||||
],
|
||||
],
|
||||
[
|
||||
'label' => 'sidebar.tools.section',
|
||||
'icon' => 'mdi:tools',
|
||||
'items' => [
|
||||
// Gating module uniquement : rendu visuel + badge non-lus gérés côté layout
|
||||
// (filtré de translatedSections puis ré-injecté avec suffixe (N)).
|
||||
['label' => 'sidebar.general.mail', 'to' => '/mail', 'icon' => 'mdi:email-outline', 'module' => 'mail'],
|
||||
],
|
||||
],
|
||||
@@ -37,8 +44,8 @@ return [
|
||||
'items' => [
|
||||
['label' => 'sidebar.admin.teamAbsences', 'to' => '/team-absences', 'icon' => 'mdi:calendar-account-outline', 'module' => 'absence'],
|
||||
['label' => 'sidebar.admin.directory', 'to' => '/directory', 'icon' => 'mdi:card-account-details-outline', 'module' => 'directory'],
|
||||
['label' => 'sidebar.admin.administration', 'to' => '/admin', 'icon' => 'mdi:cog-outline', 'permission' => 'core.users.view'],
|
||||
['label' => 'sidebar.admin.reporting', 'to' => '/reporting', 'icon' => 'mdi:chart-line', 'module' => 'reporting', 'permission' => 'reporting.view'],
|
||||
['label' => 'sidebar.admin.administration', 'to' => '/admin', 'icon' => 'mdi:cog-outline', 'permission' => 'core.users.view'],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
parameters:
|
||||
app.version: '0.4.34'
|
||||
app.version: '0.4.40'
|
||||
|
||||
@@ -0,0 +1,484 @@
|
||||
# Migration sidebar vers MalioSidebar — Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Remplacer la sidebar maison de Lesstime par le composant `MalioSidebar` de `@malio/layer-ui`, en 3 groupes (Général / Outils / Administration), avec timer + version dans le footer et le logo Malio de Starseed.
|
||||
|
||||
**Architecture:** Modèle backend-driven conservé — `config/sidebar.php` filtré par `SidebarProvider` (permissions/rôles/modules côté serveur), exposé via `/api/sidebar`, consommé par `useSidebar()`. Le layout `default.vue` mappe ces sections vers le format `MalioSidebar` et fusionne les items contextuels rendus côté client (Kanban/Groupes/Archives, Documents, Mail+badge, Mes absences).
|
||||
|
||||
**Tech Stack:** Nuxt 4 (SPA), Vue 3 `<script setup>` TS, Pinia, `@malio/layer-ui` ^1.7.16, i18n (@nuxtjs/i18n), Symfony 8 / API Platform 4 (backend config PHP).
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- **Ne jamais modifier `@malio/layer-ui`** (lib externe). Source de référence en lecture seule : `frontend/node_modules/@malio/layer-ui/app/components/malio/sidebar/Sidebar.vue`.
|
||||
- `MalioSidebar` : props `sections` (requis), `modelValue` (v-model collapse bool), `sidebarClass`, `toggleClass`. Item = `{ label: string; to: string; exact?: boolean }` (pas d'icône ni de badge par item). Section = `{ label?: string; icon?: string; items: SidebarItem[] }`. Slots : `#logo`, `#logo-collapsed`, `#footer`, `#footer-collapsed`.
|
||||
- **TypeScript strict** ; indentation **4 espaces** (frontend).
|
||||
- Backend : `declare(strict_types=1)` en tête des fichiers PHP.
|
||||
- Commits format projet : `type(scope) : message` (espaces autour du `:`), types autorisés minuscules (`feat`, `fix`, `refactor`, `chore`, …). **Ne committer que sur demande de l'utilisateur** (règle CLAUDE.md). Travailler sur une branche dédiée (pas directement sur `develop`).
|
||||
- **Pas de runner de test frontend** dans ce projet → vérification par `npm run build` (Nuxt, échoue sur erreur TS/template) + **QA manuelle navigateur** (`make dev-nuxt`, port 3002). Ne PAS introduire de framework de test (hors scope).
|
||||
- Décisions validées : 3 groupes ; badge mail = **suffixe `(N)`** sur le label.
|
||||
|
||||
## File Structure
|
||||
|
||||
- `config/sidebar.php` — **Modify** : re-catégorisation en 3 sections.
|
||||
- `frontend/i18n/locales/fr.json` — **Modify** : clés de sections/items.
|
||||
- `frontend/i18n/locales/*.json` (autres langues présentes) — **Modify si existantes** : mêmes clés.
|
||||
- `frontend/public/LOGO_MALIO.png` — **Create** (copie Starseed).
|
||||
- `frontend/public/LOGO_MALIO_COLLAPSED.png` — **Create** (copie Starseed).
|
||||
- `frontend/app/layouts/default.vue` — **Modify** : réécriture du template sidebar + logique `mergedSections`.
|
||||
- `frontend/components/ui/SidebarLink.vue` — **Possible delete** (si plus aucun usage après migration).
|
||||
|
||||
---
|
||||
|
||||
## Task 0 : Branche de travail
|
||||
|
||||
**Files:** aucun (git).
|
||||
|
||||
- [ ] **Step 1 : Créer la branche depuis `develop`**
|
||||
|
||||
```bash
|
||||
cd /home/m-tristan/workspace/Lesstime
|
||||
git checkout develop && git pull --ff-only
|
||||
git checkout -b feat/malio-sidebar
|
||||
```
|
||||
|
||||
Expected : sur la branche `feat/malio-sidebar`.
|
||||
|
||||
---
|
||||
|
||||
## Task 1 : Backend — re-catégorisation `config/sidebar.php` + i18n
|
||||
|
||||
**Files:**
|
||||
- Modify: `config/sidebar.php`
|
||||
- Modify: `frontend/i18n/locales/fr.json`
|
||||
- Modify: autres `frontend/i18n/locales/*.json` si présentes (mêmes clés)
|
||||
|
||||
**Interfaces:**
|
||||
- Produces : `/api/sidebar` renvoie des sections dont les `label` sont les clés `sidebar.general.section`, `sidebar.tools.section`, `sidebar.admin.section`. Items inchangés en `to` ; gates (`module`/`roles`/`permission`) inchangés, juste réorganisés.
|
||||
|
||||
- [ ] **Step 1 : Réécrire `config/sidebar.php` en 3 sections**
|
||||
|
||||
Remplacer le `return [...]` (lignes 20-44) par :
|
||||
|
||||
```php
|
||||
return [
|
||||
[
|
||||
'label' => 'sidebar.general.section',
|
||||
'icon' => 'mdi:view-dashboard-outline',
|
||||
'items' => [
|
||||
['label' => 'sidebar.general.dashboard', 'to' => '/', 'icon' => 'mdi:view-dashboard-outline'],
|
||||
['label' => 'sidebar.general.myTasks', 'to' => '/my-tasks', 'icon' => 'mdi:clipboard-check-outline', 'module' => 'project-management', 'permission' => 'project-management.tasks.view'],
|
||||
['label' => 'sidebar.general.projects', 'to' => '/projects', 'icon' => 'mdi:folder-outline', 'module' => 'project-management', 'permission' => 'project-management.projects.view'],
|
||||
['label' => 'sidebar.general.timeTracking', 'to' => '/time-tracking', 'icon' => 'mdi:calendar-edit-outline', 'module' => 'time-tracking', 'permission' => 'time-tracking.entries.view'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'label' => 'sidebar.tools.section',
|
||||
'icon' => 'mdi:tools',
|
||||
'items' => [
|
||||
// Gating module uniquement : rendu visuel + badge non-lus gérés côté layout
|
||||
// (filtré de translatedSections puis ré-injecté avec suffixe (N)).
|
||||
['label' => 'sidebar.general.mail', 'to' => '/mail', 'icon' => 'mdi:email-outline', 'module' => 'mail'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'label' => 'sidebar.admin.section',
|
||||
'icon' => 'mdi:cog-outline',
|
||||
'roles' => ['ROLE_ADMIN'],
|
||||
'items' => [
|
||||
['label' => 'sidebar.admin.teamAbsences', 'to' => '/team-absences', 'icon' => 'mdi:calendar-account-outline', 'module' => 'absence'],
|
||||
['label' => 'sidebar.admin.directory', 'to' => '/directory', 'icon' => 'mdi:card-account-details-outline', 'module' => 'directory'],
|
||||
['label' => 'sidebar.admin.reporting', 'to' => '/reporting', 'icon' => 'mdi:chart-line', 'module' => 'reporting', 'permission' => 'reporting.view'],
|
||||
['label' => 'sidebar.admin.administration', 'to' => '/admin', 'icon' => 'mdi:cog-outline', 'permission' => 'core.users.view'],
|
||||
],
|
||||
],
|
||||
];
|
||||
```
|
||||
|
||||
> Mettre aussi à jour le commentaire d'en-tête si nécessaire (le bloc décrivant Mail/contextuels reste valable).
|
||||
|
||||
- [ ] **Step 2 : Mettre à jour les clés i18n FR**
|
||||
|
||||
Dans `frontend/i18n/locales/fr.json`, bloc `sidebar` :
|
||||
- `sidebar.general.section` : remplacer la valeur par `"Général"`.
|
||||
- Ajouter `sidebar.tools.section` : `"Outils"`.
|
||||
- Conserver `sidebar.general.dashboard|myTasks|projects|timeTracking|mail` et `sidebar.admin.*`.
|
||||
- Ajouter les clés pour items client (utilisées en Task 3) :
|
||||
- `sidebar.general.myAbsences` : `"Mes absences"`
|
||||
- `sidebar.project.kanban` : `"Kanban"`
|
||||
- `sidebar.project.groups` : `"Groupes"`
|
||||
- `sidebar.project.archives` : `"Archives"`
|
||||
|
||||
Résultat attendu du bloc (extrait) :
|
||||
|
||||
```json
|
||||
"sidebar": {
|
||||
"general": {
|
||||
"section": "Général",
|
||||
"dashboard": "Tableau de bord",
|
||||
"myTasks": "Mes tâches",
|
||||
"projects": "Projets",
|
||||
"timeTracking": "Suivi de temps",
|
||||
"mail": "Messagerie",
|
||||
"myAbsences": "Mes absences"
|
||||
},
|
||||
"tools": {
|
||||
"section": "Outils"
|
||||
},
|
||||
"project": {
|
||||
"kanban": "Kanban",
|
||||
"groups": "Groupes",
|
||||
"archives": "Archives"
|
||||
},
|
||||
"admin": {
|
||||
"section": "Administration",
|
||||
"teamAbsences": "Absences équipe",
|
||||
"directory": "Répertoire",
|
||||
"administration": "Administration",
|
||||
"reporting": "Rapports"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3 : Répliquer les clés dans les autres locales si présentes**
|
||||
|
||||
```bash
|
||||
ls /home/m-tristan/workspace/Lesstime/frontend/i18n/locales/
|
||||
```
|
||||
|
||||
Pour chaque fichier autre que `fr.json`, ajouter `tools.section`, `general.myAbsences`, `project.kanban|groups|archives` et ajuster `general.section`. S'il n'existe que `fr.json`, ne rien faire de plus.
|
||||
|
||||
- [ ] **Step 4 : Vérifier `/api/sidebar` (admin)**
|
||||
|
||||
```bash
|
||||
docker exec -i php-lesstime-fpm php -r 'var_dump(require "/var/www/config/sidebar.php");' | head -5
|
||||
```
|
||||
|
||||
Expected : le fichier PHP se parse sans erreur (3 entrées de premier niveau). (Le chemin exact dans le container peut différer — sinon, vérifier via `make cache-clear` qui échouerait sur une erreur de syntaxe PHP.)
|
||||
|
||||
```bash
|
||||
make cache-clear
|
||||
```
|
||||
|
||||
Expected : succès, pas d'erreur de parse.
|
||||
|
||||
- [ ] **Step 5 : Commit (sur demande utilisateur)**
|
||||
|
||||
```bash
|
||||
git add config/sidebar.php frontend/i18n/locales/
|
||||
git commit -m "refactor(sidebar) : re-catégorisation en 3 groupes (Général / Outils / Administration)"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 2 : Frontend — assets logo
|
||||
|
||||
**Files:**
|
||||
- Create: `frontend/public/LOGO_MALIO.png`
|
||||
- Create: `frontend/public/LOGO_MALIO_COLLAPSED.png`
|
||||
|
||||
**Interfaces:**
|
||||
- Produces : assets statiques servis à `/LOGO_MALIO.png` et `/LOGO_MALIO_COLLAPSED.png`.
|
||||
|
||||
- [ ] **Step 1 : Copier les logos depuis Starseed**
|
||||
|
||||
```bash
|
||||
cp /home/m-tristan/workspace/Starseed/frontend/public/LOGO_MALIO.png \
|
||||
/home/m-tristan/workspace/Lesstime/frontend/public/LOGO_MALIO.png
|
||||
cp /home/m-tristan/workspace/Starseed/frontend/public/LOGO_MALIO_COLLAPSED.png \
|
||||
/home/m-tristan/workspace/Lesstime/frontend/public/LOGO_MALIO_COLLAPSED.png
|
||||
```
|
||||
|
||||
- [ ] **Step 2 : Vérifier**
|
||||
|
||||
```bash
|
||||
ls -la /home/m-tristan/workspace/Lesstime/frontend/public/LOGO_MALIO*.png
|
||||
```
|
||||
|
||||
Expected : deux fichiers présents (~5.8K et ~2.2K).
|
||||
|
||||
- [ ] **Step 3 : Commit (sur demande utilisateur)**
|
||||
|
||||
```bash
|
||||
git add frontend/public/LOGO_MALIO.png frontend/public/LOGO_MALIO_COLLAPSED.png
|
||||
git commit -m "chore(sidebar) : ajout des logos Malio (déplié / replié)"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 3 : Frontend — migration du layout vers `MalioSidebar`
|
||||
|
||||
**Files:**
|
||||
- Modify: `frontend/app/layouts/default.vue`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes : `useSidebar().sections` (clés i18n des Task 1), `useUiStore().sidebarCollapsed`, `SidebarTimer` (`:collapsed`), `useAppVersion().version`, `useMailStore().globalUnreadCount`, `useShareStatus()`, `auth.user.isEmployee`, `auth.user.roles`, `useI18n().t`.
|
||||
- Produces : layout rendant `<MalioSidebar>`.
|
||||
|
||||
> Ce task est une réécriture cohérente d'un seul fichier : la sidebar doit rester fonctionnelle (toutes features préservées) à la fin du task. On ne committe pas d'état intermédiaire cassé.
|
||||
|
||||
- [ ] **Step 1 : Remplacer le bloc `<aside>…</aside>` (lignes 13-104) par `<MalioSidebar>`**
|
||||
|
||||
Nouveau template de la zone sidebar (remplace l'overlay mobile lignes 5-11 **et** l'`<aside>`) :
|
||||
|
||||
```vue
|
||||
<MalioSidebar
|
||||
v-model="ui.sidebarCollapsed"
|
||||
:sections="mergedSections"
|
||||
:sidebar-class="ui.sidebarCollapsed ? '' : 'w-[232px]'"
|
||||
>
|
||||
<template #logo>
|
||||
<img src="/LOGO_MALIO.png" alt="Malio"/>
|
||||
</template>
|
||||
<template #logo-collapsed>
|
||||
<img src="/LOGO_MALIO_COLLAPSED.png" alt="Malio"/>
|
||||
</template>
|
||||
<template #footer>
|
||||
<div class="flex flex-col gap-2">
|
||||
<SidebarTimer :collapsed="false" />
|
||||
<p v-if="version" class="text-center text-sm font-bold">v {{ version }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer-collapsed>
|
||||
<SidebarTimer :collapsed="true" />
|
||||
</template>
|
||||
</MalioSidebar>
|
||||
```
|
||||
|
||||
Le bloc `<div class="h-full flex-1 …">` (AppTopNav + `<main>` + `<slot/>`) et le `<TimeEntryDrawer>` restent **inchangés**.
|
||||
|
||||
- [ ] **Step 2 : Remplacer la logique `translatedSections` par `mergedSections` dans le `<script setup>`**
|
||||
|
||||
Supprimer le computed `translatedSections` (lignes 144-156) et le remplacer par :
|
||||
|
||||
```ts
|
||||
type MalioItem = { label: string; to: string; exact?: boolean }
|
||||
type MalioSection = { label: string; icon: string; items: MalioItem[] }
|
||||
|
||||
// Ordre d'affichage canonique des sections.
|
||||
const SECTION_ORDER = [
|
||||
'sidebar.general.section',
|
||||
'sidebar.tools.section',
|
||||
'sidebar.admin.section',
|
||||
] as const
|
||||
|
||||
// Icônes de secours pour les sections créées côté client (absentes du backend,
|
||||
// ex. module mail off mais partage actif → section Outils à recréer).
|
||||
const SECTION_ICON: Record<string, string> = {
|
||||
'sidebar.general.section': 'mdi:view-dashboard-outline',
|
||||
'sidebar.tools.section': 'mdi:tools',
|
||||
'sidebar.admin.section': 'mdi:cog-outline',
|
||||
}
|
||||
|
||||
// Items rendus côté client (dépendent d'un état runtime ignoré du backend).
|
||||
function clientItemsFor(key: string): MalioItem[] {
|
||||
if (key === 'sidebar.general.section') {
|
||||
const items: MalioItem[] = []
|
||||
if (currentProjectId.value) {
|
||||
const id = currentProjectId.value
|
||||
items.push({ label: t('sidebar.project.kanban'), to: `/projects/${id}`, exact: true })
|
||||
items.push({ label: t('sidebar.project.groups'), to: `/projects/${id}/groups` })
|
||||
items.push({ label: t('sidebar.project.archives'), to: `/projects/${id}/archives` })
|
||||
}
|
||||
if (isEmployee.value) {
|
||||
items.push({ label: t('sidebar.general.myAbsences'), to: '/absences' })
|
||||
}
|
||||
return items
|
||||
}
|
||||
if (key === 'sidebar.tools.section') {
|
||||
const items: MalioItem[] = []
|
||||
if (isMailVisible.value) {
|
||||
const n = mailStore.globalUnreadCount
|
||||
const suffix = n > 0 ? ` (${n > 99 ? '99+' : n})` : ''
|
||||
items.push({ label: `${t('mail.sidebar.title')}${suffix}`, to: '/mail' })
|
||||
}
|
||||
if (isDocumentsVisible.value) {
|
||||
items.push({ label: t('sharedFiles.sidebar.title'), to: '/documents' })
|
||||
}
|
||||
return items
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
const mergedSections = computed<MalioSection[]>(() => {
|
||||
// 1. Sections backend (déjà filtrées par permissions), mail retiré (ré-injecté côté client).
|
||||
const backend = new Map<string, MalioSection>()
|
||||
for (const section of sections.value) {
|
||||
backend.set(section.label, {
|
||||
label: t(section.label),
|
||||
icon: section.icon,
|
||||
items: section.items
|
||||
.filter((item) => item.to !== '/mail')
|
||||
.map((item) => ({ label: t(item.label), to: item.to })),
|
||||
})
|
||||
}
|
||||
|
||||
// 2. Fusion dans l'ordre canonique.
|
||||
const result: MalioSection[] = []
|
||||
for (const key of SECTION_ORDER) {
|
||||
const base = backend.get(key)
|
||||
const extra = clientItemsFor(key)
|
||||
if (base) {
|
||||
base.items.push(...extra)
|
||||
if (base.items.length > 0) {
|
||||
result.push(base)
|
||||
}
|
||||
} else if (extra.length > 0) {
|
||||
result.push({ label: t(key), icon: SECTION_ICON[key], items: extra })
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Garde-fou : toute section backend hors ordre canonique n'est pas perdue.
|
||||
for (const [key, section] of backend) {
|
||||
if (!(SECTION_ORDER as readonly string[]).includes(key) && section.items.length > 0) {
|
||||
result.push(section)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
```
|
||||
|
||||
> `isDocumentsVisible` existe déjà (ligne 166). `isMailVisible`, `isEmployee`, `currentProjectId`, `sections`, `mailStore`, `t`, `version`, `ui` sont déjà déclarés — ne pas les redéclarer.
|
||||
|
||||
- [ ] **Step 3 : Nettoyer le `<script>` et les imports devenus inutiles**
|
||||
|
||||
- Supprimer `sidebarIsCollapsed` (computed lignes 169-172) **si** plus utilisé après suppression de l'`<aside>` (l'était pour le rendu manuel). Vérifier qu'aucune autre référence ne subsiste :
|
||||
|
||||
```bash
|
||||
grep -n "sidebarIsCollapsed" frontend/app/layouts/default.vue
|
||||
```
|
||||
|
||||
S'il ne reste aucune occurrence hors déclaration, supprimer le computed.
|
||||
|
||||
- Conserver `watch(() => route.path, () => { ui.closeMobileSidebar() })` (fermeture mobile sur navigation).
|
||||
- Vérifier que `SidebarLink` n'est plus référencé dans ce fichier (le composant Malio le remplace) :
|
||||
|
||||
```bash
|
||||
grep -n "SidebarLink" frontend/app/layouts/default.vue
|
||||
```
|
||||
|
||||
Expected : aucune occurrence.
|
||||
|
||||
- [ ] **Step 4 : Build de vérification**
|
||||
|
||||
```bash
|
||||
cd /home/m-tristan/workspace/Lesstime/frontend && npm run build
|
||||
```
|
||||
|
||||
Expected : build Nuxt réussi, **aucune erreur TypeScript** ni de template. (Si `mergedSections`/types invalides, le build échoue ici.)
|
||||
|
||||
- [ ] **Step 5 : QA manuelle (dev server)**
|
||||
|
||||
```bash
|
||||
make dev-nuxt # port 3002
|
||||
```
|
||||
|
||||
Vérifier en **admin** (`admin`/`admin`) :
|
||||
- 3 groupes : Général, Outils, Administration.
|
||||
- Général : Tableau de bord, Mes tâches, Projets, Suivi de temps.
|
||||
- En ouvrant un projet (`/projects/<id>`) : Kanban/Groupes/Archives apparaissent dans Général ; Kanban actif uniquement sur la page kanban (exact).
|
||||
- Outils : Messagerie (+ `(N)` si non-lus), Documents (si partage activé).
|
||||
- Administration : Absences équipe, Répertoire, Rapports, Administration.
|
||||
- Footer : timer cliquable (start/stop) + `v <version>` ; en replié, le timer reste (icône) et la version disparaît.
|
||||
- Logo Malio déplié + replié (collapsed via toggle du composant).
|
||||
- Route active surlignée ; pas de doublon `/mail`.
|
||||
|
||||
Vérifier en **utilisateur non-admin** (`alice`/`alice`) :
|
||||
- **Pas** de groupe Administration.
|
||||
- Items gated par permission absents si l'utilisateur n'a pas la permission.
|
||||
- Mes absences visible uniquement si `isEmployee`.
|
||||
|
||||
- [ ] **Step 6 : Vérifier le comportement mobile (largeur < lg)**
|
||||
|
||||
Réduire la fenêtre / activer le responsive devtools.
|
||||
- Vérifier l'ouverture/fermeture de la sidebar sur mobile.
|
||||
- Vérifier le bouton hamburger éventuel de `AppTopNav` :
|
||||
|
||||
```bash
|
||||
grep -rn "openMobileSidebar\|sidebarOpen\|closeMobileSidebar" frontend/app/components/ frontend/components/ frontend/app/layouts/default.vue
|
||||
```
|
||||
|
||||
- Si `MalioSidebar` gère le responsive et que l'overlay supprimé n'est plus nécessaire : OK.
|
||||
- Si l'ouverture mobile ne fonctionne plus (ex. AppTopNav appelait `openMobileSidebar` pour l'ancien overlay) : adapter **sans modifier la lib** — a minima conserver le repli/déploiement via `ui.sidebarCollapsed`, ou conserver un déclencheur. Documenter le choix retenu dans le commit.
|
||||
|
||||
- [ ] **Step 7 : Commit (sur demande utilisateur)**
|
||||
|
||||
```bash
|
||||
git add frontend/app/layouts/default.vue
|
||||
git commit -m "feat(sidebar) : migration du layout vers MalioSidebar (footer timer + version, logo Malio)"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 4 : Nettoyage des éléments obsolètes
|
||||
|
||||
**Files:**
|
||||
- Possible delete: `frontend/components/ui/SidebarLink.vue`
|
||||
- Possible delete: anciens logos `frontend/public/malio.png`, `frontend/public/LOGO_CARRE.png`
|
||||
|
||||
**Interfaces:** aucun (suppression sûre uniquement si zéro référence).
|
||||
|
||||
- [ ] **Step 1 : Vérifier les usages restants de `SidebarLink`**
|
||||
|
||||
```bash
|
||||
grep -rn "SidebarLink" /home/m-tristan/workspace/Lesstime/frontend --include="*.vue" --include="*.ts" | grep -v node_modules
|
||||
```
|
||||
|
||||
- Si **aucune** occurrence : supprimer le fichier.
|
||||
|
||||
```bash
|
||||
git rm frontend/components/ui/SidebarLink.vue
|
||||
```
|
||||
|
||||
- Si encore référencé ailleurs : **ne pas supprimer**, laisser tel quel.
|
||||
|
||||
- [ ] **Step 2 : Vérifier les usages des anciens logos**
|
||||
|
||||
```bash
|
||||
grep -rn "malio.png\|LOGO_CARRE.png" /home/m-tristan/workspace/Lesstime/frontend --include="*.vue" --include="*.ts" --include="*.css" | grep -v node_modules
|
||||
```
|
||||
|
||||
- Si **aucune** occurrence : supprimer les deux PNG.
|
||||
|
||||
```bash
|
||||
git rm frontend/public/malio.png frontend/public/LOGO_CARRE.png
|
||||
```
|
||||
|
||||
- Sinon : conserver.
|
||||
|
||||
- [ ] **Step 3 : Build final**
|
||||
|
||||
```bash
|
||||
cd /home/m-tristan/workspace/Lesstime/frontend && npm run build
|
||||
```
|
||||
|
||||
Expected : build réussi.
|
||||
|
||||
- [ ] **Step 4 : Commit (sur demande utilisateur)**
|
||||
|
||||
```bash
|
||||
git add -A
|
||||
git commit -m "chore(sidebar) : suppression des composants/assets obsolètes de l'ancienne sidebar"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Self-Review (auteur du plan)
|
||||
|
||||
**Spec coverage :**
|
||||
- Remplacement par MalioSidebar → Task 3 ✓
|
||||
- Permissions serveur préservées → Task 1 (gates inchangés) + Task 3 (mail filtré/ré-injecté, garde-fou sections) ✓
|
||||
- 3 groupes Général/Outils/Administration → Task 1 + Task 3 (ordre canonique) ✓
|
||||
- Footer timer + version → Task 3 Step 1 ✓
|
||||
- Logo Malio Starseed → Task 2 + Task 3 ✓
|
||||
- Items contextuels (Kanban/Groupes/Archives, Documents, Mes absences) → Task 3 `clientItemsFor` ✓
|
||||
- Badge mail = suffixe `(N)` → Task 3 `clientItemsFor` ✓
|
||||
- Mobile → Task 3 Step 6 ✓
|
||||
- Nettoyage → Task 4 ✓
|
||||
|
||||
**Placeholder scan :** pas de TBD ; les branches conditionnelles de suppression (Task 4) et d'adaptation mobile (Task 3 Step 6) sont des décisions binaires basées sur un `grep`, pas des placeholders.
|
||||
|
||||
**Type consistency :** `MalioItem`/`MalioSection` définis une fois (Task 3) et utilisés de façon cohérente ; `clientItemsFor`/`mergedSections`/`SECTION_ORDER`/`SECTION_ICON` cohérents. Items produits conformes au type attendu par `MalioSidebar` (`{label, to, exact?}`).
|
||||
|
||||
**Réserve connue :** absence de runner de test FE → vérification par build + QA manuelle (assumé, conforme à l'état du repo).
|
||||
@@ -0,0 +1,200 @@
|
||||
# Migration de la sidebar vers `MalioSidebar` (@malio/layer-ui)
|
||||
|
||||
**Date** : 2026-06-25
|
||||
**Statut** : Design validé
|
||||
**Scope** : Frontend (layout) + backend (config sidebar) + assets
|
||||
|
||||
## Contexte
|
||||
|
||||
La sidebar actuelle de Lesstime est un `<aside>` fait main dans
|
||||
`frontend/app/layouts/default.vue`, qui itère sur les sections renvoyées par
|
||||
`/api/sidebar` et rend chaque item via le composant maison `SidebarLink`. Le
|
||||
timer et la version sont empilés en bas du `<aside>`, le toggle collapse et
|
||||
l'overlay mobile sont gérés manuellement.
|
||||
|
||||
La librairie `@malio/layer-ui` (mise à jour) fournit désormais un composant
|
||||
`MalioSidebar`. Le projet **Starseed** a déjà effectué cette migration sur une
|
||||
architecture identique (`config/sidebar.php` → `SidebarProvider` → composable
|
||||
`useSidebar` → layout). Cette spec applique la même migration à Lesstime, avec
|
||||
trois spécificités Lesstime : footer (timer + version), re-catégorisation des
|
||||
onglets, et plusieurs items contextuels rendus côté client.
|
||||
|
||||
On **ne modifie pas** la lib `@malio/layer-ui` (règle CLAUDE.md).
|
||||
|
||||
## Objectifs
|
||||
|
||||
1. Remplacer le `<aside>` maison par `<MalioSidebar>`.
|
||||
2. Préserver le filtrage des permissions/rôles/modules **côté serveur**.
|
||||
3. Re-catégoriser la navigation en 3 groupes : **Général / Outils / Administration**.
|
||||
4. Mettre le timer et la version dans le **footer** du composant.
|
||||
5. Reprendre le **logo Malio** de Starseed.
|
||||
|
||||
## Décisions validées
|
||||
|
||||
- **Catégorisation** : 3 groupes (option B).
|
||||
- **Badge mail** : le compteur de non-lus devient un **suffixe sur le label**
|
||||
(`Messagerie (3)`), faute de slot badge/icône par item dans `MalioSidebar`.
|
||||
|
||||
## Contraintes du composant `MalioSidebar`
|
||||
|
||||
Source : `frontend/node_modules/@malio/layer-ui/app/components/malio/sidebar/Sidebar.vue`.
|
||||
|
||||
- **Props** : `sections` (requis), `modelValue` (v-model collapse, bool),
|
||||
`id`, `sidebarClass`, `toggleClass`.
|
||||
- **Types** :
|
||||
- `SidebarItem = { label: string; to: string; exact?: boolean }`
|
||||
- `SidebarSection = { label?: string; icon?: string; items: SidebarItem[] }`
|
||||
- **Slots** : `#logo`, `#logo-collapsed`, `#footer`, `#footer-collapsed`.
|
||||
- **Events** : `update:modelValue(boolean)`.
|
||||
- **Item** : pas d'icône par item ni de badge — uniquement l'icône de section.
|
||||
Route active = match exact ou par préfixe (`exact: true` pour exact strict).
|
||||
- Largeurs fixes : 232px (déplié) / 72px (replié). Toggle interne.
|
||||
|
||||
### Conséquences (compromis assumés)
|
||||
|
||||
- Perte de l'**icône par item** (design malioUI = texte + icône de section).
|
||||
Starseed fonctionne ainsi.
|
||||
- Le **badge mail** ne peut pas être une pastille → suffixe `(N)` dans le label.
|
||||
|
||||
## Architecture cible
|
||||
|
||||
Modèle **backend-driven** conservé (sécurité serveur intacte). Le frontend
|
||||
mappe les sections renvoyées par `/api/sidebar` vers le format `MalioSidebar`
|
||||
et **fusionne** les items contextuels (qui dépendent d'un état runtime non
|
||||
connu du backend).
|
||||
|
||||
### 1. Backend — `config/sidebar.php`
|
||||
|
||||
Re-catégorisation en 3 sections (gates inchangés, juste réorganisés) :
|
||||
|
||||
```
|
||||
GÉNÉRAL (sidebar.general.section, icon mdi:view-dashboard-outline)
|
||||
Tableau de bord / —
|
||||
Mes tâches /my-tasks module project-management, perm tasks.view
|
||||
Projets /projects module project-management, perm projects.view
|
||||
Suivi de temps /time-tracking module time-tracking, perm entries.view
|
||||
|
||||
OUTILS (sidebar.tools.section, icon mdi:tools)
|
||||
Messagerie /mail module mail
|
||||
(filtré du rendu backend côté front, ré-injecté avec badge)
|
||||
|
||||
ADMINISTRATION (sidebar.admin.section, icon mdi:cog-outline, roles [ROLE_ADMIN])
|
||||
Absences équipe /team-absences module absence
|
||||
Répertoire /directory module directory
|
||||
Rapports /reporting module reporting, perm reporting.view
|
||||
Administration /admin perm core.users.view
|
||||
```
|
||||
|
||||
> `/mail` reste déclaré pour le gating module (`disabledRoutes`), mais est
|
||||
> filtré des sections rendues et ré-injecté côté client avec son badge, comme
|
||||
> aujourd'hui.
|
||||
|
||||
### 2. i18n — `frontend/i18n/locales/fr.json`
|
||||
|
||||
- Renommer `sidebar.general.section` : « Gestion de projet » → « Général ».
|
||||
- Ajouter `sidebar.tools.section` : « Outils ».
|
||||
- Conserver les clés d'items existantes. Items client : réutiliser les clés
|
||||
existantes quand elles existent (`sharedFiles.sidebar.title` pour Documents,
|
||||
`mail.sidebar.title`/`sidebar.general.mail` pour Messagerie) ; ajouter une
|
||||
clé pour « Mes absences » (aujourd'hui en dur) et pour les contextuels
|
||||
(Kanban/Groupes/Archives, aujourd'hui en dur) si on souhaite les traduire,
|
||||
sinon conserver les libellés en dur actuels.
|
||||
|
||||
### 3. Frontend — `frontend/app/layouts/default.vue`
|
||||
|
||||
Réécriture du template autour de `<MalioSidebar>` :
|
||||
|
||||
```vue
|
||||
<MalioSidebar v-model="ui.sidebarCollapsed" :sections="mergedSections"
|
||||
:sidebar-class="ui.sidebarCollapsed ? '' : 'w-[232px]'">
|
||||
<template #logo> <img src="/LOGO_MALIO.png" alt="Malio"/></template>
|
||||
<template #logo-collapsed> <img src="/LOGO_MALIO_COLLAPSED.png" alt="Malio"/></template>
|
||||
<template #footer>
|
||||
<SidebarTimer :collapsed="false" />
|
||||
<p class="font-bold">v {{ version }}</p>
|
||||
</template>
|
||||
<template #footer-collapsed>
|
||||
<SidebarTimer :collapsed="true" />
|
||||
</template>
|
||||
</MalioSidebar>
|
||||
```
|
||||
|
||||
**Computed `mergedSections`** : construit les sections finales dans l'ordre
|
||||
canonique `[général, outils, administration]`.
|
||||
|
||||
Logique de fusion :
|
||||
1. Partir des sections backend (déjà filtrées), mappées en
|
||||
`{ label: t(label), icon, items: items.filter(to !== '/mail').map({label: t, to}) }`.
|
||||
2. Définir une table `clientItems` indexée par clé de section :
|
||||
- `sidebar.general.section` → (si `currentProjectId`) Kanban (`exact`),
|
||||
Groupes, Archives ; puis (si `isEmployee`) Mes absences.
|
||||
- `sidebar.tools.section` → (si `isMailVisible`) Messagerie avec label
|
||||
`Messagerie` + suffixe `(N)` quand `mailStore.globalUnreadCount > 0`
|
||||
(`99+` au-delà) ; puis (si `shareEnabled`) Documents.
|
||||
3. Pour chaque section backend, **append** ses items client.
|
||||
4. Si une clé de `clientItems` produit des items mais que la section
|
||||
correspondante n'est **pas** présente dans la réponse backend (ex. module
|
||||
mail off mais partage on → pas de section « Outils » côté backend), **créer**
|
||||
la section côté front (label + icône depuis une table locale).
|
||||
5. **Supprimer** les sections finales sans items.
|
||||
6. Trier selon l'ordre canonique des clés.
|
||||
|
||||
Le reste du `<script>` (timer title watchers, `refData`/`TimeEntryDrawer`,
|
||||
polling mail, `ensureShareStatus`, `currentProjectId`, `isEmployee`,
|
||||
`isMailVisible`, `shareEnabled`) est **conservé tel quel**.
|
||||
|
||||
### 4. Mobile
|
||||
|
||||
Starseed a **supprimé l'overlay mobile custom** et ne garde que
|
||||
`watch(route) → ui.closeMobileSidebar()`. On s'aligne : suppression du markup
|
||||
overlay (`ui.sidebarOpen`, `.sidebar-overlay`) si `MalioSidebar` gère le
|
||||
responsive. **À vérifier à l'implémentation** : comportement mobile réel du
|
||||
composant ; si l'ouverture mobile n'est pas couverte, adapter a minima sans
|
||||
modifier la lib.
|
||||
|
||||
### 5. Assets — logo
|
||||
|
||||
Copier depuis Starseed vers `frontend/public/` :
|
||||
- `LOGO_MALIO.png` (128×44)
|
||||
- `LOGO_MALIO_COLLAPSED.png` (34×40)
|
||||
|
||||
Les anciens `/malio.png` et `/LOGO_CARRE.png` ne sont plus référencés par le
|
||||
layout (les laisser ou les retirer si plus aucun usage — à vérifier).
|
||||
|
||||
## Composants / éléments réutilisés
|
||||
|
||||
- `SidebarTimer` (`components/ui/SidebarTimer.vue`) : inchangé, déjà piloté par
|
||||
`:collapsed`.
|
||||
- `useAppVersion()` : inchangé.
|
||||
- `useSidebar()` : inchangé.
|
||||
- `usePermissions()` : inchangé (le filtrage permission reste backend ; les
|
||||
flags client `isEmployee`/`isMailVisible`/`shareEnabled` restent locaux).
|
||||
|
||||
## Éléments supprimés
|
||||
|
||||
- Le `<aside>` manuel et son markup (logo, nav, toggle, overlay) dans
|
||||
`default.vue`.
|
||||
- L'usage de `SidebarLink` dans le layout (le composant peut rester s'il est
|
||||
utilisé ailleurs — à vérifier ; sinon suppression possible).
|
||||
|
||||
## Critères d'acceptation
|
||||
|
||||
1. La sidebar est rendue par `<MalioSidebar>`.
|
||||
2. 3 groupes : Général, Outils, Administration (Administration visible
|
||||
uniquement pour `ROLE_ADMIN` / permissions, comme avant).
|
||||
3. Toutes les permissions/rôles/modules sont respectés à l'identique (aucune
|
||||
régression de visibilité pour user/admin).
|
||||
4. Items contextuels présents : Kanban/Groupes/Archives (dans un projet),
|
||||
Documents (partage activé), Mes absences (employé).
|
||||
5. Messagerie affiche `(N)` quand il y a des non-lus.
|
||||
6. Footer : timer fonctionnel + version (version masquée en replié).
|
||||
7. Logo Malio de Starseed affiché (déplié + replié).
|
||||
8. Collapse/expand et route active fonctionnent.
|
||||
9. Pas de doublon `/mail`. Pas de section vide affichée.
|
||||
10. Build Nuxt OK, pas d'erreur TS.
|
||||
|
||||
## Hors scope
|
||||
|
||||
- Refonte du `SiteSelector` (n'existe pas dans Lesstime).
|
||||
- Modification de la lib `@malio/layer-ui`.
|
||||
- Changement du modèle de permissions backend.
|
||||
+126
-141
@@ -1,112 +1,31 @@
|
||||
<template>
|
||||
<div class="h-screen overflow-hidden">
|
||||
<div class="flex h-full">
|
||||
<!-- Mobile sidebar overlay -->
|
||||
<Transition name="sidebar-overlay">
|
||||
<div
|
||||
v-if="ui.sidebarOpen"
|
||||
class="fixed inset-0 z-40 bg-black/50 lg:hidden"
|
||||
@click="ui.closeMobileSidebar()"
|
||||
/>
|
||||
</Transition>
|
||||
|
||||
<aside
|
||||
class="fixed inset-y-0 left-0 z-50 flex h-full flex-shrink-0 flex-col border-r border-neutral-200 bg-tertiary-500 transition-transform duration-300 lg:static lg:z-auto lg:translate-x-0"
|
||||
:class="[
|
||||
ui.sidebarCollapsed ? 'lg:w-16' : 'lg:w-64',
|
||||
ui.sidebarOpen ? 'w-64 translate-x-0' : '-translate-x-full',
|
||||
]"
|
||||
<MalioSidebar
|
||||
v-model="ui.sidebarCollapsed"
|
||||
:sections="mergedSections"
|
||||
:sidebar-class="ui.sidebarCollapsed ? '' : 'w-[232px]'"
|
||||
>
|
||||
<div class="flex items-center overflow-hidden" :class="sidebarIsCollapsed ? 'justify-center p-3' : 'justify-between'">
|
||||
<img
|
||||
v-if="!sidebarIsCollapsed"
|
||||
src="/malio.png"
|
||||
alt="Logo"
|
||||
class="w-auto"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
src="/LOGO_CARRE.png"
|
||||
alt="Logo"
|
||||
class="w-[46px] h-[55px]"
|
||||
/>
|
||||
<button
|
||||
class="mr-2 rounded-md p-2 text-neutral-500 hover:bg-neutral-200 hover:text-neutral-700 transition-colors lg:hidden"
|
||||
@click="ui.closeMobileSidebar()"
|
||||
>
|
||||
<Icon name="mdi:close" size="20" />
|
||||
</button>
|
||||
</div>
|
||||
<nav class="flex-1 overflow-hidden" :class="sidebarIsCollapsed ? 'px-1 pb-6' : 'px-4 pb-6'">
|
||||
<!-- Sections dynamiques (/api/sidebar) : navigation globale + sections gated par rôle -->
|
||||
<template v-for="(section, sIndex) in translatedSections" :key="section.label">
|
||||
<p v-if="!sidebarIsCollapsed" class="px-4 pt-5 pb-1 text-xs font-semibold uppercase tracking-wider text-neutral-400">
|
||||
{{ section.label }}
|
||||
</p>
|
||||
<div v-else class="mx-2 my-3 border-t border-secondary-500" />
|
||||
<SidebarLink
|
||||
v-for="item in section.items"
|
||||
:key="item.to"
|
||||
:to="item.to"
|
||||
:icon="item.icon"
|
||||
:label="item.label"
|
||||
:collapsed="sidebarIsCollapsed"
|
||||
@click="ui.closeMobileSidebar()"
|
||||
/>
|
||||
|
||||
<!-- Items conservés côté client, insérés après la 1re section (cf. décision 3) -->
|
||||
<template v-if="sIndex === 0">
|
||||
<!-- Contextuel projet -->
|
||||
<template v-if="currentProjectId">
|
||||
<SidebarLink :to="`/projects/${currentProjectId}`" icon="mdi:view-column-outline" label="Kanban" :collapsed="sidebarIsCollapsed" sub exact @click="ui.closeMobileSidebar()" />
|
||||
<SidebarLink :to="`/projects/${currentProjectId}/groups`" icon="mdi:tag-multiple-outline" label="Groupes" :collapsed="sidebarIsCollapsed" sub @click="ui.closeMobileSidebar()" />
|
||||
<SidebarLink :to="`/projects/${currentProjectId}/archives`" icon="mdi:archive-outline" label="Archives" :collapsed="sidebarIsCollapsed" sub @click="ui.closeMobileSidebar()" />
|
||||
</template>
|
||||
<!-- Feature-flag : Documents -->
|
||||
<SidebarLink v-if="isDocumentsVisible" to="/documents" icon="mdi:folder-network-outline" :label="$t('sharedFiles.sidebar.title')" :collapsed="sidebarIsCollapsed" @click="ui.closeMobileSidebar()" />
|
||||
<!-- Feature-flag : Mail + badge -->
|
||||
<div v-if="isMailVisible" class="relative">
|
||||
<SidebarLink to="/mail" icon="mdi:email-outline" :label="$t('mail.sidebar.title')" :collapsed="sidebarIsCollapsed" @click="ui.closeMobileSidebar()" />
|
||||
<span
|
||||
v-if="mailStore.globalUnreadCount > 0"
|
||||
class="pointer-events-none absolute right-3 top-1/2 flex h-5 min-w-5 -translate-y-1/2 items-center justify-center rounded-full bg-red-500 px-1 text-xs font-bold text-white"
|
||||
:class="{ 'right-1 top-1 translate-y-0': sidebarIsCollapsed }"
|
||||
:aria-label="`${mailStore.globalUnreadCount} messages non lus`"
|
||||
>
|
||||
{{ mailStore.globalUnreadCount > 99 ? '99+' : mailStore.globalUnreadCount }}
|
||||
</span>
|
||||
</div>
|
||||
<!-- User-flag : Mes absences (isEmployee — non couvert par le gate rôle) -->
|
||||
<SidebarLink v-if="isEmployee" to="/absences" icon="mdi:umbrella-beach-outline" label="Mes absences" :collapsed="sidebarIsCollapsed" @click="ui.closeMobileSidebar()" />
|
||||
</template>
|
||||
</template>
|
||||
</nav>
|
||||
|
||||
<div class="px-4 py-3">
|
||||
<SidebarTimer :collapsed="sidebarIsCollapsed" />
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-center p-4">
|
||||
<p v-if="!sidebarIsCollapsed" class="font-bold">v {{ version }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Collapse toggle button centered vertically on the sidebar edge -->
|
||||
<button
|
||||
class="absolute top-1/2 -right-4 z-10 hidden h-8 w-8 -translate-y-1/2 items-center justify-center rounded-full border border-neutral-200 bg-white text-neutral-400 shadow-sm hover:text-neutral-700 transition-colors lg:flex"
|
||||
:title="ui.sidebarCollapsed ? 'Ouvrir le menu' : 'Réduire le menu'"
|
||||
@click="ui.toggleSidebar()"
|
||||
>
|
||||
<Icon
|
||||
:name="ui.sidebarCollapsed ? 'mdi:chevron-right' : 'mdi:chevron-left'"
|
||||
size="18"
|
||||
/>
|
||||
</button>
|
||||
</aside>
|
||||
<template #logo>
|
||||
<img src="/LOGO_MALIO.png" alt="Malio"/>
|
||||
</template>
|
||||
<template #logo-collapsed>
|
||||
<img src="/LOGO_MALIO_COLLAPSED.png" alt="Malio"/>
|
||||
</template>
|
||||
<template #footer>
|
||||
<div class="flex flex-col gap-2">
|
||||
<SidebarTimer :collapsed="false" />
|
||||
<p v-if="version" class="text-center text-sm font-bold">v {{ version }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer-collapsed>
|
||||
<SidebarTimer :collapsed="true" />
|
||||
</template>
|
||||
</MalioSidebar>
|
||||
|
||||
<div class="h-full flex-1 flex flex-col min-h-0 min-w-0">
|
||||
<AppTopNav :user="auth.user" />
|
||||
<main class="flex flex-1 flex-col overflow-y-auto overflow-x-hidden bg-white px-4 pb-24 sm:px-8 lg:px-16">
|
||||
<div aria-hidden="true" class="pointer-events-none sticky top-0 z-30 h-8 flex-shrink-0 bg-white sm:h-12" />
|
||||
<main class="flex flex-1 flex-col overflow-y-auto overflow-x-hidden bg-white px-4 pb-24 sm:px-6 lg:px-12 xl:px-11">
|
||||
<slot/>
|
||||
</main>
|
||||
</div>
|
||||
@@ -139,23 +58,6 @@ const route = useRoute()
|
||||
const { t } = useI18n()
|
||||
const { sections } = useSidebar()
|
||||
|
||||
// `/mail` est déclaré dans config/sidebar.php pour le gating module (disabledRoutes),
|
||||
// mais son rendu visuel + badge non-lus est géré manuellement ci-dessous (feature-flag Mail).
|
||||
// On le filtre des sections dynamiques pour éviter un doublon dans la nav.
|
||||
const translatedSections = computed(() =>
|
||||
sections.value.map((section) => ({
|
||||
label: t(section.label),
|
||||
icon: section.icon,
|
||||
items: section.items
|
||||
.filter((item) => item.to !== '/mail')
|
||||
.map((item) => ({
|
||||
label: t(item.label),
|
||||
to: item.to,
|
||||
icon: item.icon,
|
||||
})),
|
||||
})),
|
||||
)
|
||||
|
||||
const isEmployee = computed(() => Boolean(auth.user?.isEmployee))
|
||||
|
||||
const isMailVisible = computed(() => {
|
||||
@@ -166,22 +68,116 @@ const isMailVisible = computed(() => {
|
||||
const { enabled: shareEnabled, ensureLoaded: ensureShareStatus } = useShareStatus()
|
||||
const isDocumentsVisible = computed(() => shareEnabled.value === true)
|
||||
|
||||
// On mobile, sidebar is always expanded (not collapsed icon mode)
|
||||
const sidebarIsCollapsed = computed(() => {
|
||||
if (ui.sidebarOpen) return false
|
||||
return ui.sidebarCollapsed
|
||||
})
|
||||
|
||||
// Close mobile sidebar on route change
|
||||
watch(() => route.path, () => {
|
||||
ui.closeMobileSidebar()
|
||||
})
|
||||
|
||||
const currentProjectId = computed(() => {
|
||||
const match = route.path.match(/^\/projects\/(\d+)/)
|
||||
return match ? match[1] : null
|
||||
})
|
||||
|
||||
type MalioItem = { label: string; to: string; exact?: boolean }
|
||||
type MalioSection = { label: string; icon: string; items: MalioItem[] }
|
||||
|
||||
// Ordre d'affichage canonique des sections.
|
||||
const SECTION_ORDER = [
|
||||
'sidebar.general.section',
|
||||
'sidebar.tools.section',
|
||||
'sidebar.admin.section',
|
||||
] as const
|
||||
|
||||
// Icônes de secours pour les sections créées côté client (absentes du backend,
|
||||
// ex. module mail off mais partage actif → section Outils à recréer).
|
||||
const SECTION_ICON: Record<string, string> = {
|
||||
'sidebar.general.section': 'mdi:view-dashboard-outline',
|
||||
'sidebar.tools.section': 'mdi:tools',
|
||||
'sidebar.admin.section': 'mdi:cog-outline',
|
||||
}
|
||||
|
||||
// Item client avec ancre optionnelle : `after` = `to` de l'item après lequel l'insérer
|
||||
// (sinon ajouté en fin de section).
|
||||
type ClientItem = MalioItem & { after?: string }
|
||||
|
||||
// Items rendus côté client (dépendent d'un état runtime ignoré du backend).
|
||||
function clientItemsFor(key: string): ClientItem[] {
|
||||
if (key === 'sidebar.general.section') {
|
||||
const items: ClientItem[] = []
|
||||
if (currentProjectId.value) {
|
||||
const id = currentProjectId.value
|
||||
// Insérés juste sous « Projets », dans l'ordre via ancres chaînées.
|
||||
items.push({ label: t('sidebar.project.kanban'), to: `/projects/${id}`, exact: true, after: '/projects' })
|
||||
items.push({ label: t('sidebar.project.groups'), to: `/projects/${id}/groups`, after: `/projects/${id}` })
|
||||
items.push({ label: t('sidebar.project.archives'), to: `/projects/${id}/archives`, after: `/projects/${id}/groups` })
|
||||
}
|
||||
if (isEmployee.value) {
|
||||
items.push({ label: t('sidebar.general.myAbsences'), to: '/absences' })
|
||||
}
|
||||
return items
|
||||
}
|
||||
if (key === 'sidebar.tools.section') {
|
||||
const items: ClientItem[] = []
|
||||
if (isMailVisible.value) {
|
||||
const n = mailStore.globalUnreadCount
|
||||
const suffix = n > 0 ? ` (${n > 99 ? '99+' : n})` : ''
|
||||
items.push({ label: `${t('mail.sidebar.title')}${suffix}`, to: '/mail' })
|
||||
}
|
||||
if (isDocumentsVisible.value) {
|
||||
items.push({ label: t('sharedFiles.sidebar.title'), to: '/documents' })
|
||||
}
|
||||
return items
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
// Insère les items client après leur ancre (`after`), sinon en fin de liste.
|
||||
function mergeClientItems(base: MalioItem[], extra: ClientItem[]): MalioItem[] {
|
||||
const result = [...base]
|
||||
for (const { after, ...item } of extra) {
|
||||
const idx = after ? result.findIndex((i) => i.to === after) : -1
|
||||
if (idx !== -1) {
|
||||
result.splice(idx + 1, 0, item)
|
||||
} else {
|
||||
result.push(item)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
const mergedSections = computed<MalioSection[]>(() => {
|
||||
// 1. Sections backend (déjà filtrées par permissions), mail retiré (ré-injecté côté client).
|
||||
const backend = new Map<string, MalioSection>()
|
||||
for (const section of sections.value) {
|
||||
backend.set(section.label, {
|
||||
label: t(section.label),
|
||||
icon: section.icon,
|
||||
items: section.items
|
||||
.filter((item) => item.to !== '/mail')
|
||||
.map((item) => ({ label: t(item.label), to: item.to })),
|
||||
})
|
||||
}
|
||||
|
||||
// 2. Fusion dans l'ordre canonique.
|
||||
const result: MalioSection[] = []
|
||||
for (const key of SECTION_ORDER) {
|
||||
const base = backend.get(key)
|
||||
const extra = clientItemsFor(key)
|
||||
if (base) {
|
||||
base.items = mergeClientItems(base.items, extra)
|
||||
if (base.items.length > 0) {
|
||||
result.push(base)
|
||||
}
|
||||
} else if (extra.length > 0) {
|
||||
result.push({ label: t(key), icon: SECTION_ICON[key] ?? '', items: mergeClientItems([], extra) })
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Garde-fou : toute section backend hors ordre canonique n'est pas perdue.
|
||||
for (const [key, section] of backend) {
|
||||
if (!(SECTION_ORDER as readonly string[]).includes(key) && section.items.length > 0) {
|
||||
result.push(section)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
|
||||
const timerStore = useTimerStore()
|
||||
|
||||
const baseTitle = ref('Lesstime')
|
||||
@@ -269,14 +265,3 @@ function onCompleteSaved() {
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sidebar-overlay-enter-active,
|
||||
.sidebar-overlay-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.sidebar-overlay-enter-from,
|
||||
.sidebar-overlay-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
<div class="flex h-full items-center justify-between">
|
||||
<MalioButtonIcon
|
||||
icon="mdi:menu"
|
||||
aria-label="Menu"
|
||||
aria-label="Replier ou déplier le menu"
|
||||
variant="ghost"
|
||||
icon-size="24"
|
||||
button-class="lg:hidden text-white hover:bg-primary-600"
|
||||
@click="ui.openMobileSidebar()"
|
||||
@click="ui.toggleSidebar()"
|
||||
/>
|
||||
<div class="hidden items-center gap-2 lg:flex">
|
||||
<h1 class="text-lg font-bold tracking-tight">Lesstime</h1>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<!-- Entête de page standard : source unique du style des titres.
|
||||
Toujours sticky en haut du <main> scrollable : reste visible au scroll.
|
||||
Fond blanc + pt-[38px]/pb-[30px] (au lieu de marges) pour que le contenu
|
||||
défilant soit masqué sous l'entête (espaces haut ET bas compris) et que
|
||||
l'entête soit collée sous l'AppTopNav sans trou.
|
||||
Slots :
|
||||
- défaut : texte du titre
|
||||
- #actions : boutons à droite du titre
|
||||
- #subheader : barre de filtres / onglets rendue SOUS le titre, dans le
|
||||
même bloc sticky (reste donc collée avec le titre). La
|
||||
marge titre -> sous-entête est portée par le contenu passé
|
||||
(ex. mt-4) pour laisser chaque page régler son cas. -->
|
||||
<div class="sticky top-0 z-20 bg-white pt-[38px] pb-[30px]">
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<h1 class="text-[30px] font-semibold text-primary-500">
|
||||
<slot/>
|
||||
</h1>
|
||||
<div v-if="$slots.actions" class="shrink-0">
|
||||
<slot name="actions"/>
|
||||
</div>
|
||||
</div>
|
||||
<slot name="subheader"/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,52 +0,0 @@
|
||||
<template>
|
||||
<NuxtLink
|
||||
:to="to"
|
||||
class="group/link relative flex items-center transition-colors hover:text-primary-500"
|
||||
:class="linkClasses"
|
||||
:active-class="exact ? '' : activeClass"
|
||||
:exact-active-class="exact ? activeClass : ''"
|
||||
>
|
||||
<Icon :name="icon" :size="sub ? '20' : '24'" class="flex-shrink-0" />
|
||||
<span
|
||||
v-if="!collapsed"
|
||||
class="self-baseline whitespace-nowrap overflow-hidden transition-opacity duration-300"
|
||||
:class="sub ? 'text-sm' : 'text-md'"
|
||||
>
|
||||
{{ label }}
|
||||
</span>
|
||||
<div
|
||||
v-if="collapsed"
|
||||
class="pointer-events-none absolute left-full z-50 ml-2 rounded-md bg-neutral-800 px-2 py-1 text-xs text-white opacity-0 shadow-lg transition-opacity group-hover/link:pointer-events-auto group-hover/link:opacity-100 whitespace-nowrap"
|
||||
>
|
||||
{{ label }}
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{
|
||||
to: string
|
||||
icon: string
|
||||
label: string
|
||||
collapsed: boolean
|
||||
sub?: boolean
|
||||
exact?: boolean
|
||||
}>()
|
||||
|
||||
const activeClass = computed(() => {
|
||||
if (props.collapsed) {
|
||||
return '!text-primary-500 bg-primary-500/10'
|
||||
}
|
||||
return '!text-primary-500 bg-tertiary-500'
|
||||
})
|
||||
|
||||
const linkClasses = computed(() => {
|
||||
if (props.collapsed) {
|
||||
return 'justify-center w-10 h-10 mx-auto my-1 p-2 rounded-lg text-neutral-600 hover:text-primary-500 hover:bg-primary-500/10'
|
||||
}
|
||||
if (props.sub) {
|
||||
return 'gap-3 px-4 py-2 pl-12 text-sm font-semibold text-neutral-700'
|
||||
}
|
||||
return 'gap-3 px-4 py-3 text-md font-semibold text-neutral-700'
|
||||
})
|
||||
</script>
|
||||
@@ -349,21 +349,29 @@
|
||||
}
|
||||
},
|
||||
"sidebar": {
|
||||
"myTasks": "Mes tâches",
|
||||
"general": {
|
||||
"section": "Gestion de projet",
|
||||
"section": "Général",
|
||||
"dashboard": "Tableau de bord",
|
||||
"myTasks": "Mes tâches",
|
||||
"projects": "Projets",
|
||||
"timeTracking": "Suivi de temps",
|
||||
"mail": "Messagerie"
|
||||
"mail": "Messagerie",
|
||||
"myAbsences": "Mes absences"
|
||||
},
|
||||
"tools": {
|
||||
"section": "Outils"
|
||||
},
|
||||
"project": {
|
||||
"kanban": "Kanban",
|
||||
"groups": "Groupes",
|
||||
"archives": "Archives"
|
||||
},
|
||||
"admin": {
|
||||
"section": "Administration",
|
||||
"teamAbsences": "Absences équipe",
|
||||
"administration": "Administration",
|
||||
"directory": "Répertoire",
|
||||
"reporting": "Rapports"
|
||||
"reporting": "Rapports",
|
||||
"administration": "Administration"
|
||||
}
|
||||
},
|
||||
"reporting": {
|
||||
@@ -917,6 +925,7 @@
|
||||
"company": "Société",
|
||||
"email": "Email",
|
||||
"phone": "Téléphone",
|
||||
"website": "Site web",
|
||||
"street": "Rue",
|
||||
"city": "Ville",
|
||||
"postalCode": "Code postal",
|
||||
@@ -932,7 +941,23 @@
|
||||
"lost": "Perdu"
|
||||
},
|
||||
"validation": {
|
||||
"nameRequired": "Le nom est requis"
|
||||
"nameRequired": "Le nom est requis",
|
||||
"companyRequired": "La société est requise"
|
||||
}
|
||||
},
|
||||
"prestataires": {
|
||||
"created": "Prestataire créé avec succès.",
|
||||
"updated": "Prestataire mis à jour avec succès.",
|
||||
"deleted": "Prestataire supprimé avec succès.",
|
||||
"addPrestataire": "Ajouter un prestataire",
|
||||
"editPrestataire": "Modifier un prestataire",
|
||||
"deleteConfirmTitle": "Supprimer le prestataire",
|
||||
"deleteConfirmMessage": "Êtes-vous sûr de vouloir supprimer le prestataire « {name} » ? Cette action est irréversible.",
|
||||
"fields": {
|
||||
"name": "Nom / Société",
|
||||
"email": "Email",
|
||||
"phone": "Téléphone",
|
||||
"website": "Site web"
|
||||
}
|
||||
},
|
||||
"directory": {
|
||||
@@ -941,6 +966,7 @@
|
||||
"info": "Informations",
|
||||
"clients": "Clients",
|
||||
"prospects": "Prospects",
|
||||
"prestataires": "Prestataires",
|
||||
"contact": "Contact",
|
||||
"address": "Adresse",
|
||||
"report": "Rapport"
|
||||
@@ -949,12 +975,16 @@
|
||||
"fields": {
|
||||
"name": "Nom",
|
||||
"email": "Email",
|
||||
"phone": "Téléphone"
|
||||
"phone": "Téléphone",
|
||||
"website": "Site web"
|
||||
}
|
||||
},
|
||||
"validation": {
|
||||
"nameRequired": "Le nom est requis.",
|
||||
"subjectRequired": "L'objet est requis."
|
||||
"subjectRequired": "L'objet est requis.",
|
||||
"emailInvalid": "Adresse email invalide.",
|
||||
"phoneInvalid": "Numéro de téléphone invalide (ex. 0549200910).",
|
||||
"urlInvalid": "URL invalide (ex. https://exemple.fr)."
|
||||
},
|
||||
"clients": {
|
||||
"add": "Ajouter un client",
|
||||
@@ -965,6 +995,10 @@
|
||||
"empty": "Aucun prospect trouvé.",
|
||||
"allStatuses": "Tous les statuts"
|
||||
},
|
||||
"prestataires": {
|
||||
"add": "Ajouter un prestataire",
|
||||
"empty": "Aucun prestataire trouvé."
|
||||
},
|
||||
"contacts": {
|
||||
"add": "Ajouter un contact",
|
||||
"item": "Contact {n}",
|
||||
@@ -984,6 +1018,8 @@
|
||||
"item": "Adresse {n}",
|
||||
"saved": "Adresse enregistrée.",
|
||||
"deleted": "Adresse supprimée.",
|
||||
"streetNotFound": "Aucune adresse trouvée — saisie libre possible.",
|
||||
"autocompleteUnavailable": "Recherche d'adresse indisponible : saisissez l'adresse manuellement.",
|
||||
"fields": {
|
||||
"label": "Libellé",
|
||||
"street": "Rue",
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-2xl font-bold text-neutral-900">{{ $t('absences.title') }}</h1>
|
||||
<MalioButton
|
||||
:label="$t('absences.newRequest')"
|
||||
icon-name="mdi:plus"
|
||||
icon-position="left"
|
||||
@click="requestDrawerOpen = true"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<PageHeader>
|
||||
{{ $t('absences.title') }}
|
||||
<template #actions>
|
||||
<MalioButton
|
||||
:label="$t('absences.newRequest')"
|
||||
icon-name="mdi:plus"
|
||||
icon-position="left"
|
||||
@click="requestDrawerOpen = true"
|
||||
/>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<AbsenceBalanceCards :balances="balances" />
|
||||
|
||||
<!-- Filters -->
|
||||
@@ -65,6 +68,7 @@
|
||||
:can-cancel="selected?.status === 'pending'"
|
||||
@cancelled="reload"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-6">
|
||||
<h1 class="text-2xl font-bold text-neutral-900">
|
||||
<div>
|
||||
<PageHeader>
|
||||
{{ $t("absences.teamTitle") }}
|
||||
</h1>
|
||||
</PageHeader>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<!-- KPIs -->
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-3">
|
||||
<div class="rounded-lg border border-neutral-200 bg-white p-4">
|
||||
@@ -189,6 +190,7 @@
|
||||
:user="selectedEmployee"
|
||||
@saved="loadEmployees"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<NuxtLayout name="default">
|
||||
<div class="mx-auto max-w-lg px-4 py-10">
|
||||
<h1 class="mb-8 text-2xl font-bold text-neutral-900">{{ $t('profile.title') }}</h1>
|
||||
<PageHeader>{{ $t('profile.title') }}</PageHeader>
|
||||
|
||||
<div class="flex flex-col items-center gap-6 rounded-xl border border-neutral-200 bg-white p-8 shadow-sm">
|
||||
<!-- Current avatar -->
|
||||
|
||||
@@ -54,7 +54,7 @@ import { useCommercialReportService } from '~/modules/directory/services/commerc
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
report: CommercialReport | null
|
||||
owner: { client?: string, prospect?: string }
|
||||
owner: { client?: string, prospect?: string, prestataire?: string }
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
||||
@@ -141,7 +141,7 @@ import { useCommercialReportService } from '~/modules/directory/services/commerc
|
||||
import { useReportDocumentService } from '~/modules/directory/services/report-documents'
|
||||
|
||||
const props = defineProps<{
|
||||
owner: { client?: string, prospect?: string }
|
||||
owner: { client?: string, prospect?: string, prestataire?: string }
|
||||
canManage: boolean
|
||||
}>()
|
||||
|
||||
|
||||
@@ -19,13 +19,33 @@
|
||||
:readonly="readonly"
|
||||
@update:model-value="update('label', $event)"
|
||||
/>
|
||||
<MalioInputText
|
||||
class="col-span-2"
|
||||
:label="$t('directory.addresses.fields.street')"
|
||||
:model-value="modelValue.street ?? ''"
|
||||
:readonly="readonly"
|
||||
@update:model-value="update('street', $event)"
|
||||
/>
|
||||
|
||||
<!-- Rue : saisie assistée (BAN) en édition, champ texte en lecture seule.
|
||||
allow-create conserve le texte saisi si la BAN ne propose rien
|
||||
(erreur/timeout). Choisir une suggestion remplit rue + CP + ville. -->
|
||||
<div class="col-span-2">
|
||||
<MalioInputAutocomplete
|
||||
v-if="!readonly"
|
||||
:model-value="modelValue.street ?? ''"
|
||||
:options="addressOptions"
|
||||
:loading="addressLoading"
|
||||
:min-search-length="3"
|
||||
:allow-create="true"
|
||||
:label="$t('directory.addresses.fields.street')"
|
||||
:no-results-text="$t('directory.addresses.streetNotFound')"
|
||||
@update:model-value="(v) => update('street', v === null ? '' : String(v))"
|
||||
@search="onAddressSearch"
|
||||
@select="onAddressSelect"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-else
|
||||
:label="$t('directory.addresses.fields.street')"
|
||||
:model-value="modelValue.street ?? ''"
|
||||
:readonly="readonly"
|
||||
@update:model-value="update('street', $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<MalioInputText
|
||||
class="col-span-2"
|
||||
:label="$t('directory.addresses.fields.streetComplement')"
|
||||
@@ -33,13 +53,27 @@
|
||||
:readonly="readonly"
|
||||
@update:model-value="update('streetComplement', $event)"
|
||||
/>
|
||||
|
||||
<MalioInputText
|
||||
:label="$t('directory.addresses.fields.postalCode')"
|
||||
:model-value="modelValue.postalCode ?? ''"
|
||||
:readonly="readonly"
|
||||
@update:model-value="update('postalCode', $event)"
|
||||
@update:model-value="onPostalCodeInput"
|
||||
/>
|
||||
|
||||
<!-- Ville : select alimenté par le code postal (BAN). En mode dégradé
|
||||
(BAN indispo) ou lecture seule, on bascule en saisie libre. -->
|
||||
<MalioSelect
|
||||
v-if="!readonly && !degraded"
|
||||
:model-value="modelValue.city ?? ''"
|
||||
:options="cityOptions"
|
||||
:label="$t('directory.addresses.fields.city')"
|
||||
empty-option-label=""
|
||||
group-class="w-full"
|
||||
@update:model-value="(v) => update('city', v === null ? '' : String(v))"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-else
|
||||
:label="$t('directory.addresses.fields.city')"
|
||||
:model-value="modelValue.city ?? ''"
|
||||
:readonly="readonly"
|
||||
@@ -50,6 +84,10 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Address } from '~/modules/directory/services/dto/address'
|
||||
import {
|
||||
useAddressAutocomplete,
|
||||
type AddressSuggestion,
|
||||
} from '~/modules/directory/composables/useAddressAutocomplete'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: Address
|
||||
@@ -63,7 +101,98 @@ const emit = defineEmits<{
|
||||
'remove': []
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const toast = useToast()
|
||||
const autocomplete = useAddressAutocomplete()
|
||||
|
||||
type Option = { label: string, value: string | number }
|
||||
|
||||
const addressOptions = ref<Option[]>([])
|
||||
// Villes renvoyées par la BAN pour le code postal courant.
|
||||
const fetchedCityOptions = ref<Option[]>([])
|
||||
const addressLoading = ref(false)
|
||||
|
||||
// Le select Ville n'affiche que les valeurs présentes dans ses options : on
|
||||
// garantit donc que la ville déjà enregistrée (chargement d'une fiche) ou
|
||||
// pré-remplie par l'autocomplétion d'adresse figure toujours dans la liste,
|
||||
// même avant toute recherche par code postal — sinon elle s'afficherait vide.
|
||||
const cityOptions = computed<Option[]>(() => {
|
||||
const current = (props.modelValue.city ?? '').trim()
|
||||
const options = [...fetchedCityOptions.value]
|
||||
if (current && !options.some(o => o.value === current)) {
|
||||
options.unshift({ value: current, label: current })
|
||||
}
|
||||
return options
|
||||
})
|
||||
// Mode dégradé : BAN indisponible → la ville passe en saisie libre.
|
||||
const degraded = ref(false)
|
||||
let lastAddressSuggestions: AddressSuggestion[] = []
|
||||
let notified = false
|
||||
|
||||
function update(field: keyof Address, value: string): void {
|
||||
emit('update:modelValue', { ...props.modelValue, [field]: value === '' ? null : value })
|
||||
}
|
||||
|
||||
// Avertit une seule fois que l'autocomplétion est indisponible (saisie libre).
|
||||
function notifyUnavailable(): void {
|
||||
if (notified) return
|
||||
notified = true
|
||||
toast.info({ title: '', message: t('directory.addresses.autocompleteUnavailable') })
|
||||
}
|
||||
|
||||
/** Recherche d'adresse assistée (event de MalioInputAutocomplete). */
|
||||
async function onAddressSearch(query: string): Promise<void> {
|
||||
if (query.trim().length < 3) {
|
||||
addressOptions.value = []
|
||||
return
|
||||
}
|
||||
addressLoading.value = true
|
||||
try {
|
||||
const postalCode = (props.modelValue.postalCode ?? '').replace(/\D/g, '') || undefined
|
||||
const suggestions = await autocomplete.searchAddress(query, postalCode)
|
||||
lastAddressSuggestions = suggestions
|
||||
addressOptions.value = suggestions.map(s => ({ value: s.street, label: s.label }))
|
||||
}
|
||||
catch {
|
||||
addressOptions.value = []
|
||||
notifyUnavailable()
|
||||
}
|
||||
finally {
|
||||
addressLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** Sélection d'une suggestion → remplit rue + ville + code postal. */
|
||||
function onAddressSelect(option: Option | null): void {
|
||||
if (option === null) return
|
||||
// Matching par `label` (adresse complète, unique côté BAN) plutôt que par
|
||||
// rue : deux communes peuvent partager le même libellé de voie.
|
||||
const suggestion = lastAddressSuggestions.find(s => s.label === option.label)
|
||||
if (!suggestion) {
|
||||
update('street', String(option.value))
|
||||
return
|
||||
}
|
||||
emit('update:modelValue', {
|
||||
...props.modelValue,
|
||||
street: suggestion.street,
|
||||
city: suggestion.city || props.modelValue.city,
|
||||
postalCode: suggestion.postalCode || props.modelValue.postalCode,
|
||||
})
|
||||
}
|
||||
|
||||
/** Saisie du code postal → met à jour le champ + interroge la BAN pour la ville. */
|
||||
async function onPostalCodeInput(value: string): Promise<void> {
|
||||
update('postalCode', value)
|
||||
const digits = (value ?? '').replace(/\D/g, '')
|
||||
if (digits.length < 5) return
|
||||
try {
|
||||
const suggestions = await autocomplete.searchCity(digits)
|
||||
fetchedCityOptions.value = suggestions.map(s => ({ value: s.city, label: s.city }))
|
||||
degraded.value = false
|
||||
}
|
||||
catch {
|
||||
degraded.value = true
|
||||
notifyUnavailable()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -35,18 +35,21 @@
|
||||
:label="$t('directory.contacts.fields.email')"
|
||||
:model-value="modelValue.email ?? ''"
|
||||
:readonly="readonly"
|
||||
:error="emailError"
|
||||
@update:model-value="update('email', $event)"
|
||||
/>
|
||||
<MalioInputText
|
||||
:label="$t('directory.contacts.fields.phonePrimary')"
|
||||
:model-value="modelValue.phonePrimary ?? ''"
|
||||
:readonly="readonly"
|
||||
:error="phonePrimaryError"
|
||||
@update:model-value="update('phonePrimary', $event)"
|
||||
/>
|
||||
<MalioInputText
|
||||
:label="$t('directory.contacts.fields.phoneSecondary')"
|
||||
:model-value="modelValue.phoneSecondary ?? ''"
|
||||
:readonly="readonly"
|
||||
:error="phoneSecondaryError"
|
||||
@update:model-value="update('phoneSecondary', $event)"
|
||||
/>
|
||||
</div>
|
||||
@@ -54,6 +57,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Contact } from '~/modules/directory/services/dto/contact'
|
||||
import { isValidEmail, isValidFrPhone } from '~/modules/directory/utils/validation'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: Contact
|
||||
@@ -67,6 +71,18 @@ const emit = defineEmits<{
|
||||
'remove': []
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const emailError = computed(() =>
|
||||
isValidEmail(props.modelValue.email) ? '' : t('directory.validation.emailInvalid'),
|
||||
)
|
||||
const phonePrimaryError = computed(() =>
|
||||
isValidFrPhone(props.modelValue.phonePrimary) ? '' : t('directory.validation.phoneInvalid'),
|
||||
)
|
||||
const phoneSecondaryError = computed(() =>
|
||||
isValidFrPhone(props.modelValue.phoneSecondary) ? '' : t('directory.validation.phoneInvalid'),
|
||||
)
|
||||
|
||||
function update(field: keyof Contact, value: string): void {
|
||||
emit('update:modelValue', { ...props.modelValue, [field]: value === '' ? null : value })
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<MalioDrawer v-model="isOpen">
|
||||
<template #header>
|
||||
<h2 class="text-xl font-bold">{{ isEditing ? $t('prestataires.editPrestataire') : $t('prestataires.addPrestataire') }}</h2>
|
||||
</template>
|
||||
<form @submit.prevent="handleSubmit" class="flex flex-col gap-2">
|
||||
<MalioInputText
|
||||
v-model="form.name"
|
||||
:label="$t('prestataires.fields.name')"
|
||||
input-class="w-full"
|
||||
:error="touched.name && !form.name.trim() ? $t('directory.validation.nameRequired') : ''"
|
||||
@blur="touched.name = true"
|
||||
/>
|
||||
|
||||
<div class="mt-6 flex justify-end">
|
||||
<MalioButton
|
||||
:label="$t('common.save')"
|
||||
button-class="w-auto px-6"
|
||||
:disabled="isSubmitting"
|
||||
@click="handleSubmit"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</MalioDrawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Prestataire, PrestataireWrite } from '~/modules/directory/services/dto/prestataire'
|
||||
import { usePrestataireService } from '~/modules/directory/services/prestataires'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
prestataire: Prestataire | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'saved'): void
|
||||
}>()
|
||||
|
||||
const isOpen = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v),
|
||||
})
|
||||
|
||||
const isEditing = computed(() => !!props.prestataire)
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
name: '',
|
||||
})
|
||||
|
||||
const touched = reactive({
|
||||
name: false,
|
||||
})
|
||||
|
||||
watch(() => props.modelValue, (open) => {
|
||||
if (open) {
|
||||
form.name = props.prestataire?.name ?? ''
|
||||
touched.name = false
|
||||
}
|
||||
})
|
||||
|
||||
const { create, update } = usePrestataireService()
|
||||
|
||||
async function handleSubmit() {
|
||||
touched.name = true
|
||||
if (!form.name.trim()) return
|
||||
|
||||
isSubmitting.value = true
|
||||
try {
|
||||
const payload: PrestataireWrite = {
|
||||
name: form.name.trim(),
|
||||
}
|
||||
|
||||
if (isEditing.value && props.prestataire) {
|
||||
await update(props.prestataire.id, payload)
|
||||
} else {
|
||||
await create(payload)
|
||||
}
|
||||
|
||||
emit('saved')
|
||||
isOpen.value = false
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -5,11 +5,11 @@
|
||||
</template>
|
||||
<form @submit.prevent="handleSubmit" class="flex flex-col gap-2">
|
||||
<MalioInputText
|
||||
v-model="form.name"
|
||||
label="Nom société"
|
||||
v-model="form.company"
|
||||
:label="$t('prospects.fields.company')"
|
||||
input-class="w-full"
|
||||
:error="touched.name && !form.name.trim() ? $t('prospects.validation.nameRequired') : ''"
|
||||
@blur="touched.name = true"
|
||||
:error="touched.company && !form.company.trim() ? $t('prospects.validation.companyRequired') : ''"
|
||||
@blur="touched.company = true"
|
||||
/>
|
||||
|
||||
<div class="mt-6 flex items-center justify-between gap-2">
|
||||
@@ -62,30 +62,30 @@ const isConverted = computed(() => !!props.prospect?.convertedClient)
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
name: '',
|
||||
company: '',
|
||||
})
|
||||
|
||||
const touched = reactive({
|
||||
name: false,
|
||||
company: false,
|
||||
})
|
||||
|
||||
watch(() => props.modelValue, (open) => {
|
||||
if (open) {
|
||||
form.name = props.prospect?.name ?? ''
|
||||
touched.name = false
|
||||
form.company = props.prospect?.company ?? ''
|
||||
touched.company = false
|
||||
}
|
||||
})
|
||||
|
||||
const { create, update, convert } = useProspectService()
|
||||
|
||||
async function handleSubmit() {
|
||||
touched.name = true
|
||||
if (!form.name.trim()) return
|
||||
touched.company = true
|
||||
if (!form.company.trim()) return
|
||||
|
||||
isSubmitting.value = true
|
||||
try {
|
||||
const payload: ProspectWrite = {
|
||||
name: form.name.trim(),
|
||||
company: form.company.trim(),
|
||||
}
|
||||
|
||||
if (isEditing.value && props.prospect) {
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import { httpExternal } from '~/utils/httpExternal'
|
||||
|
||||
// Autocomplétion d'adresse branchée sur la Base Adresse Nationale (BAN),
|
||||
// `api-adresse.data.gouv.fr` — service public français, gratuit, CORS ouvert.
|
||||
//
|
||||
// Appel HTTP DIRECT depuis le front (pas de proxy back) : la BAN est un domaine
|
||||
// externe, sans cookie de session ni enveloppe Hydra → on passe par
|
||||
// `httpExternal` et NON `useApi()`.
|
||||
//
|
||||
// Contrat :
|
||||
// searchCity(postalCode) -> liste { city, postalCode }
|
||||
// searchAddress(query, cp?) -> liste { label, street, postalCode, city }
|
||||
// En cas d'erreur/timeout, la méthode THROW une
|
||||
// AddressAutocompleteUnavailableError. Le composant consommateur catch,
|
||||
// avertit l'utilisateur et bascule en saisie libre.
|
||||
|
||||
/** URL de l'endpoint de recherche BAN. */
|
||||
const BAN_SEARCH_URL = 'https://api-adresse.data.gouv.fr/search/'
|
||||
|
||||
/** Une suggestion de ville renvoyée à partir d'un code postal. */
|
||||
export interface CitySuggestion {
|
||||
city: string
|
||||
postalCode: string
|
||||
}
|
||||
|
||||
/** Une suggestion d'adresse complète (saisie assistée du champ « Rue »). */
|
||||
export interface AddressSuggestion {
|
||||
label: string
|
||||
street: string
|
||||
postalCode: string
|
||||
city: string
|
||||
}
|
||||
|
||||
export interface AddressAutocomplete {
|
||||
searchCity(postalCode: string): Promise<CitySuggestion[]>
|
||||
searchAddress(query: string, postalCode?: string): Promise<AddressSuggestion[]>
|
||||
}
|
||||
|
||||
/** Erreur signalant que le service d'autocomplétion BAN n'est pas disponible. */
|
||||
export class AddressAutocompleteUnavailableError extends Error {
|
||||
constructor() {
|
||||
super('Address autocomplete (BAN) is not available.')
|
||||
this.name = 'AddressAutocompleteUnavailableError'
|
||||
}
|
||||
}
|
||||
|
||||
/** Propriétés d'une « feature » GeoJSON renvoyée par la BAN (champs utilisés). */
|
||||
interface BanFeatureProperties {
|
||||
label?: string
|
||||
name?: string
|
||||
street?: string
|
||||
postcode?: string
|
||||
city?: string
|
||||
}
|
||||
|
||||
/** Réponse GeoJSON FeatureCollection de la BAN. */
|
||||
interface BanResponse {
|
||||
features?: { properties?: BanFeatureProperties }[]
|
||||
}
|
||||
|
||||
export function useAddressAutocomplete(): AddressAutocomplete {
|
||||
return {
|
||||
async searchCity(postalCode: string): Promise<CitySuggestion[]> {
|
||||
let res: BanResponse
|
||||
try {
|
||||
res = await httpExternal<BanResponse>(BAN_SEARCH_URL, {
|
||||
query: { q: postalCode, type: 'municipality' },
|
||||
})
|
||||
}
|
||||
catch {
|
||||
throw new AddressAutocompleteUnavailableError()
|
||||
}
|
||||
|
||||
return (res.features ?? []).map((feature) => {
|
||||
const props = feature.properties ?? {}
|
||||
return {
|
||||
city: props.city ?? props.name ?? '',
|
||||
postalCode: props.postcode ?? '',
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async searchAddress(query: string, postalCode?: string): Promise<AddressSuggestion[]> {
|
||||
// Pas de `type=housenumber` ici : sans filtre, la BAN classe rues +
|
||||
// numéros par pertinence (comportement d'autocomplétion attendu).
|
||||
// On n'ajoute `postcode` que s'il est fourni (sinon recherche large).
|
||||
const banQuery: Record<string, string> = { q: query }
|
||||
if (postalCode) {
|
||||
banQuery.postcode = postalCode
|
||||
}
|
||||
|
||||
let res: BanResponse
|
||||
try {
|
||||
res = await httpExternal<BanResponse>(BAN_SEARCH_URL, { query: banQuery })
|
||||
}
|
||||
catch {
|
||||
throw new AddressAutocompleteUnavailableError()
|
||||
}
|
||||
|
||||
return (res.features ?? []).map((feature) => {
|
||||
const props = feature.properties ?? {}
|
||||
return {
|
||||
label: props.label ?? '',
|
||||
// `name` porte la ligne d'adresse complète (numéro + voie) ;
|
||||
// `street` ne contient que la voie. On privilégie `name`.
|
||||
street: props.name ?? props.street ?? '',
|
||||
postalCode: props.postcode ?? '',
|
||||
city: props.city ?? '',
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import type { Address } from '~/modules/directory/services/dto/address'
|
||||
import { useContactService } from '~/modules/directory/services/contacts'
|
||||
import { useAddressService } from '~/modules/directory/services/addresses'
|
||||
|
||||
type Owner = { client?: string, prospect?: string }
|
||||
type Owner = { client?: string, prospect?: string, prestataire?: string }
|
||||
|
||||
/**
|
||||
* Logique partagée des fiches détail Client/Prospect : blocs répétables Contact
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-6">
|
||||
<div class="flex items-center gap-3 pt-4">
|
||||
<MalioButtonIcon icon="mdi:arrow-left" :aria-label="$t('common.back')" @click="goBack" />
|
||||
<h1 class="text-2xl font-bold text-neutral-900">{{ client?.name ?? '…' }}</h1>
|
||||
</div>
|
||||
<div>
|
||||
<PageHeader>
|
||||
<span class="inline-flex items-center gap-3">
|
||||
<MalioButtonIcon icon="mdi:arrow-left" :aria-label="$t('common.back')" @click="goBack" />
|
||||
{{ client?.name ?? '…' }}
|
||||
</span>
|
||||
</PageHeader>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<p v-if="loading">{{ $t('common.loading') }}</p>
|
||||
<template v-else-if="client">
|
||||
<MalioTabList v-model="activeTab" :tabs="tabs">
|
||||
@@ -21,17 +24,25 @@
|
||||
<MalioInputText
|
||||
v-model="info.email"
|
||||
:label="$t('directory.info.fields.email')"
|
||||
:error="emailError"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.phone"
|
||||
:label="$t('directory.info.fields.phone')"
|
||||
:error="phoneError"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.website"
|
||||
class="col-span-2"
|
||||
:label="$t('directory.info.fields.website')"
|
||||
:error="websiteError"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-center pt-2">
|
||||
<MalioButton
|
||||
button-class="w-auto px-6"
|
||||
:label="$t('common.save')"
|
||||
:disabled="savingInfo"
|
||||
:disabled="savingInfo || !infoValid"
|
||||
@click="saveInfo"
|
||||
/>
|
||||
</div>
|
||||
@@ -103,12 +114,14 @@
|
||||
</template>
|
||||
</MalioTabList>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Client } from '~/modules/directory/services/dto/client'
|
||||
import { useClientService } from '~/modules/directory/services/clients'
|
||||
import { isValidEmail, isValidFrPhone, isValidUrl } from '~/modules/directory/utils/validation'
|
||||
|
||||
definePageMeta({ middleware: ['admin'] })
|
||||
|
||||
@@ -153,19 +166,25 @@ const tabs = [
|
||||
|
||||
// Champs de base de la fiche, édités en mémoire et persistés au clic sur
|
||||
// « Enregistrer » (PATCH), comme les onglets Contact/Adresse.
|
||||
const info = reactive({ name: '', email: '', phone: '' })
|
||||
const info = reactive({ name: '', email: '', phone: '', website: '' })
|
||||
const infoTouched = reactive({ name: false })
|
||||
const savingInfo = ref(false)
|
||||
|
||||
const emailError = computed(() => (isValidEmail(info.email) ? '' : t('directory.validation.emailInvalid')))
|
||||
const phoneError = computed(() => (isValidFrPhone(info.phone) ? '' : t('directory.validation.phoneInvalid')))
|
||||
const websiteError = computed(() => (isValidUrl(info.website) ? '' : t('directory.validation.urlInvalid')))
|
||||
const infoValid = computed(() => !emailError.value && !phoneError.value && !websiteError.value)
|
||||
|
||||
async function saveInfo(): Promise<void> {
|
||||
infoTouched.name = true
|
||||
if (!info.name.trim() || savingInfo.value) return
|
||||
if (!info.name.trim() || !infoValid.value || savingInfo.value) return
|
||||
savingInfo.value = true
|
||||
try {
|
||||
client.value = await clientService.update(id, {
|
||||
name: info.name.trim(),
|
||||
email: info.email.trim() || null,
|
||||
phone: info.phone.trim() || null,
|
||||
website: info.website.trim() || null,
|
||||
})
|
||||
} finally {
|
||||
savingInfo.value = false
|
||||
@@ -181,6 +200,7 @@ onMounted(async () => {
|
||||
info.name = client.value.name ?? ''
|
||||
info.email = client.value.email ?? ''
|
||||
info.phone = client.value.phone ?? ''
|
||||
info.website = client.value.website ?? ''
|
||||
await load()
|
||||
loading.value = false
|
||||
})
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-6">
|
||||
<h1 class="text-2xl font-bold text-neutral-900">
|
||||
<div>
|
||||
<PageHeader>
|
||||
{{ $t('directory.title') }}
|
||||
</h1>
|
||||
</PageHeader>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<MalioTabList v-model="activeTab" :tabs="tabs">
|
||||
<!-- Clients -->
|
||||
<template #clients>
|
||||
@@ -107,6 +108,46 @@
|
||||
</MalioDataTable>
|
||||
</div>
|
||||
</template>
|
||||
<!-- Prestataires -->
|
||||
<template #prestataires>
|
||||
<div class="flex min-h-[30rem] flex-col gap-4 pt-10">
|
||||
<div class="flex items-center justify-end">
|
||||
<MalioButton
|
||||
icon-name="mdi:plus"
|
||||
icon-position="left"
|
||||
button-class="w-auto px-4"
|
||||
:label="$t('directory.prestataires.add')"
|
||||
@click="openCreatePrestataire"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<MalioDataTable
|
||||
:columns="prestataireColumns"
|
||||
:items="prestataires"
|
||||
:total-items="prestataires.length"
|
||||
:empty-message="$t('directory.prestataires.empty')"
|
||||
@row-click="openEditPrestataire"
|
||||
>
|
||||
<template #cell-email="{ item }">
|
||||
{{ (item as Prestataire).email ?? '—' }}
|
||||
</template>
|
||||
<template #cell-phone="{ item }">
|
||||
{{ (item as Prestataire).phone ?? '—' }}
|
||||
</template>
|
||||
<template #cell-actions="{ item }">
|
||||
<div class="flex justify-end" @click.stop>
|
||||
<MalioButtonIcon
|
||||
icon="mdi:trash-can-outline"
|
||||
:aria-label="$t('common.delete')"
|
||||
button-class="!bg-red-100 !text-red-700"
|
||||
:icon-size="18"
|
||||
@click="askDeletePrestataire(item as Prestataire)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</MalioDataTable>
|
||||
</div>
|
||||
</template>
|
||||
</MalioTabList>
|
||||
|
||||
<ClientDrawer
|
||||
@@ -119,6 +160,11 @@
|
||||
:prospect="selectedProspect"
|
||||
@saved="onProspectSaved"
|
||||
/>
|
||||
<PrestataireDrawer
|
||||
v-model="prestataireDrawerOpen"
|
||||
:prestataire="selectedPrestataire"
|
||||
@saved="loadPrestataires"
|
||||
/>
|
||||
|
||||
<ConfirmDeleteModal
|
||||
v-model="deleteModalOpen"
|
||||
@@ -126,6 +172,7 @@
|
||||
:message="deleteModalMessage"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -134,6 +181,8 @@ import type { Client } from '~/modules/directory/services/dto/client'
|
||||
import { useClientService } from '~/modules/directory/services/clients'
|
||||
import type { Prospect, ProspectStatus } from '~/modules/directory/services/dto/prospect'
|
||||
import { useProspectService } from '~/modules/directory/services/prospects'
|
||||
import type { Prestataire } from '~/modules/directory/services/dto/prestataire'
|
||||
import { usePrestataireService } from '~/modules/directory/services/prestataires'
|
||||
|
||||
definePageMeta({ middleware: ['admin'] })
|
||||
|
||||
@@ -144,11 +193,13 @@ useHead({ title: t('directory.title') })
|
||||
|
||||
const clientService = useClientService()
|
||||
const prospectService = useProspectService()
|
||||
const prestataireService = usePrestataireService()
|
||||
|
||||
const activeTab = ref('clients')
|
||||
const tabs = [
|
||||
{ key: 'clients', label: t('directory.tabs.clients'), icon: 'mdi:account-tie-outline' },
|
||||
{ key: 'prospects', label: t('directory.tabs.prospects'), icon: 'mdi:account-search-outline' },
|
||||
{ key: 'prestataires', label: t('directory.tabs.prestataires'), icon: 'mdi:account-hard-hat-outline' },
|
||||
]
|
||||
|
||||
// --- Clients ---
|
||||
@@ -157,7 +208,7 @@ const clientDrawerOpen = ref(false)
|
||||
const selectedClient = ref<Client | null>(null)
|
||||
|
||||
const clientColumns = [
|
||||
{ key: 'name', label: t('prospects.fields.name') },
|
||||
{ key: 'name', label: t('prospects.fields.company') },
|
||||
{ key: 'email', label: t('prospects.fields.email') },
|
||||
{ key: 'phone', label: t('prospects.fields.phone') },
|
||||
{ key: 'actions', label: '' },
|
||||
@@ -191,7 +242,6 @@ const statusOptions = [
|
||||
]
|
||||
|
||||
const prospectColumns = [
|
||||
{ key: 'name', label: t('prospects.fields.name') },
|
||||
{ key: 'company', label: t('prospects.fields.company') },
|
||||
{ key: 'status', label: t('prospects.fields.status') },
|
||||
{ key: 'email', label: t('prospects.fields.email') },
|
||||
@@ -247,26 +297,62 @@ async function onProspectSaved() {
|
||||
await Promise.all([loadProspects(), loadClients()])
|
||||
}
|
||||
|
||||
// --- Suppression (clients & prospects) ---
|
||||
// --- Prestataires ---
|
||||
const prestataires = ref<Prestataire[]>([])
|
||||
const prestataireDrawerOpen = ref(false)
|
||||
const selectedPrestataire = ref<Prestataire | null>(null)
|
||||
|
||||
const prestataireColumns = [
|
||||
{ key: 'name', label: t('prospects.fields.company') },
|
||||
{ key: 'email', label: t('prospects.fields.email') },
|
||||
{ key: 'phone', label: t('prospects.fields.phone') },
|
||||
{ key: 'actions', label: '' },
|
||||
]
|
||||
|
||||
async function loadPrestataires() {
|
||||
prestataires.value = await prestataireService.getAll()
|
||||
}
|
||||
|
||||
function openCreatePrestataire() {
|
||||
selectedPrestataire.value = null
|
||||
prestataireDrawerOpen.value = true
|
||||
}
|
||||
|
||||
function openEditPrestataire(item: Record<string, unknown>) {
|
||||
navigateTo(`/directory/prestataires/${(item as Prestataire).id}`)
|
||||
}
|
||||
|
||||
// --- Suppression (clients, prospects & prestataires) ---
|
||||
type DeleteTarget =
|
||||
| { type: 'client'; item: Client }
|
||||
| { type: 'prospect'; item: Prospect }
|
||||
| { type: 'prestataire'; item: Prestataire }
|
||||
|
||||
const deleteModalOpen = ref(false)
|
||||
const deleteTarget = ref<DeleteTarget | null>(null)
|
||||
|
||||
const deleteModalTitle = computed(() =>
|
||||
deleteTarget.value?.type === 'prospect'
|
||||
? t('prospects.deleteConfirmTitle')
|
||||
: t('clients.deleteConfirmTitle'),
|
||||
)
|
||||
const deleteModalTitle = computed(() => {
|
||||
switch (deleteTarget.value?.type) {
|
||||
case 'prospect':
|
||||
return t('prospects.deleteConfirmTitle')
|
||||
case 'prestataire':
|
||||
return t('prestataires.deleteConfirmTitle')
|
||||
default:
|
||||
return t('clients.deleteConfirmTitle')
|
||||
}
|
||||
})
|
||||
|
||||
const deleteModalMessage = computed(() => {
|
||||
if (!deleteTarget.value) return ''
|
||||
const name = deleteTarget.value.item.name
|
||||
return deleteTarget.value.type === 'prospect'
|
||||
? t('prospects.deleteConfirmMessage', { name })
|
||||
: t('clients.deleteConfirmMessage', { name })
|
||||
const target = deleteTarget.value
|
||||
if (!target) return ''
|
||||
switch (target.type) {
|
||||
case 'prospect':
|
||||
return t('prospects.deleteConfirmMessage', { name: target.item.company })
|
||||
case 'prestataire':
|
||||
return t('prestataires.deleteConfirmMessage', { name: target.item.name })
|
||||
default:
|
||||
return t('clients.deleteConfirmMessage', { name: target.item.name })
|
||||
}
|
||||
})
|
||||
|
||||
function askDeleteClient(item: Client) {
|
||||
@@ -279,6 +365,11 @@ function askDeleteProspect(item: Prospect) {
|
||||
deleteModalOpen.value = true
|
||||
}
|
||||
|
||||
function askDeletePrestataire(item: Prestataire) {
|
||||
deleteTarget.value = { type: 'prestataire', item }
|
||||
deleteModalOpen.value = true
|
||||
}
|
||||
|
||||
async function confirmDelete() {
|
||||
const target = deleteTarget.value
|
||||
if (!target) return
|
||||
@@ -286,9 +377,12 @@ async function confirmDelete() {
|
||||
if (target.type === 'client') {
|
||||
await clientService.remove(target.item.id)
|
||||
await loadClients()
|
||||
} else {
|
||||
} else if (target.type === 'prospect') {
|
||||
await prospectService.remove(target.item.id)
|
||||
await loadProspects()
|
||||
} else {
|
||||
await prestataireService.remove(target.item.id)
|
||||
await loadPrestataires()
|
||||
}
|
||||
|
||||
deleteModalOpen.value = false
|
||||
@@ -298,7 +392,7 @@ async function confirmDelete() {
|
||||
watch(statusFilter, loadProspects)
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([loadClients(), loadProspects()])
|
||||
await Promise.all([loadClients(), loadProspects(), loadPrestataires()])
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader>
|
||||
<span class="inline-flex items-center gap-3">
|
||||
<MalioButtonIcon icon="mdi:arrow-left" :aria-label="$t('common.back')" @click="goBack" />
|
||||
{{ prestataire?.name ?? '…' }}
|
||||
</span>
|
||||
</PageHeader>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<p v-if="loading">{{ $t('common.loading') }}</p>
|
||||
<template v-else-if="prestataire">
|
||||
<MalioTabList v-model="activeTab" :tabs="tabs">
|
||||
<template #info>
|
||||
<div class="flex flex-col gap-4 pt-6">
|
||||
<div class="relative grid grid-cols-2 gap-x-[44px] gap-y-4 rounded-lg bg-white px-7 py-5 shadow-[0_4px_4px_0_rgba(0,0,0,0.10)]">
|
||||
<MalioInputText
|
||||
v-model="info.name"
|
||||
class="col-span-2"
|
||||
:label="$t('directory.info.fields.name')"
|
||||
:error="infoTouched.name && !info.name.trim() ? $t('directory.validation.nameRequired') : ''"
|
||||
@blur="infoTouched.name = true"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.email"
|
||||
:label="$t('directory.info.fields.email')"
|
||||
:error="emailError"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.phone"
|
||||
:label="$t('directory.info.fields.phone')"
|
||||
:error="phoneError"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.website"
|
||||
class="col-span-2"
|
||||
:label="$t('directory.info.fields.website')"
|
||||
:error="websiteError"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex justify-center pt-2">
|
||||
<MalioButton
|
||||
button-class="w-auto px-6"
|
||||
:label="$t('common.save')"
|
||||
:disabled="savingInfo || !infoValid"
|
||||
@click="saveInfo"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #contact>
|
||||
<div class="flex flex-col gap-4 pt-6">
|
||||
<DirectoryContactBlock
|
||||
v-for="(contact, i) in contacts"
|
||||
:key="contact.id || `new-${i}`"
|
||||
:model-value="contact"
|
||||
:title="$t('directory.contacts.item', { n: i + 1 })"
|
||||
:removable="contacts.length > 0"
|
||||
@update:model-value="(v) => onContactInput(i, v)"
|
||||
@remove="removeContact(i)"
|
||||
/>
|
||||
<div class="flex justify-center gap-3 pt-2">
|
||||
<MalioButton
|
||||
variant="tertiary"
|
||||
icon-name="mdi:plus"
|
||||
icon-position="left"
|
||||
button-class="w-auto px-4"
|
||||
:label="$t('directory.contacts.add')"
|
||||
@click="addContact"
|
||||
/>
|
||||
<MalioButton
|
||||
button-class="w-auto px-6"
|
||||
:label="$t('common.save')"
|
||||
:disabled="savingContacts"
|
||||
@click="saveContacts"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #address>
|
||||
<div class="flex flex-col gap-4 pt-6">
|
||||
<DirectoryAddressBlock
|
||||
v-for="(address, i) in addresses"
|
||||
:key="address.id || `new-${i}`"
|
||||
:model-value="address"
|
||||
:title="$t('directory.addresses.item', { n: i + 1 })"
|
||||
:removable="addresses.length > 0"
|
||||
@update:model-value="(v) => onAddressInput(i, v)"
|
||||
@remove="removeAddress(i)"
|
||||
/>
|
||||
<div class="flex justify-center gap-3 pt-2">
|
||||
<MalioButton
|
||||
variant="tertiary"
|
||||
icon-name="mdi:plus"
|
||||
icon-position="left"
|
||||
button-class="w-auto px-4"
|
||||
:label="$t('directory.addresses.add')"
|
||||
@click="addAddress"
|
||||
/>
|
||||
<MalioButton
|
||||
button-class="w-auto px-6"
|
||||
:label="$t('common.save')"
|
||||
:disabled="savingAddresses"
|
||||
@click="saveAddresses"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #report>
|
||||
<CommercialReportTab :owner="owner" :can-manage="canManage" />
|
||||
</template>
|
||||
</MalioTabList>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Prestataire } from '~/modules/directory/services/dto/prestataire'
|
||||
import { usePrestataireService } from '~/modules/directory/services/prestataires'
|
||||
import { isValidEmail, isValidFrPhone, isValidUrl } from '~/modules/directory/utils/validation'
|
||||
|
||||
definePageMeta({ middleware: ['admin'] })
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { t } = useI18n()
|
||||
|
||||
const id = Number(route.params.id)
|
||||
const ownerIri = `/api/prestataires/${id}`
|
||||
const owner = { prestataire: ownerIri }
|
||||
|
||||
const prestataireService = usePrestataireService()
|
||||
const {
|
||||
contacts,
|
||||
addresses,
|
||||
savingContacts,
|
||||
savingAddresses,
|
||||
onContactInput,
|
||||
addContact,
|
||||
removeContact,
|
||||
saveContacts,
|
||||
onAddressInput,
|
||||
addAddress,
|
||||
removeAddress,
|
||||
saveAddresses,
|
||||
load,
|
||||
} = useDirectoryDetail(owner)
|
||||
|
||||
const { can } = usePermissions()
|
||||
const canManage = computed(() => can('directory.providers.manage'))
|
||||
|
||||
const prestataire = ref<Prestataire | null>(null)
|
||||
const loading = ref(true)
|
||||
|
||||
const activeTab = ref('info')
|
||||
const tabs = [
|
||||
{ key: 'info', label: t('directory.tabs.info'), icon: 'mdi:information-outline' },
|
||||
{ key: 'contact', label: t('directory.tabs.contact'), icon: 'mdi:account-outline' },
|
||||
{ key: 'address', label: t('directory.tabs.address'), icon: 'mdi:map-marker-outline' },
|
||||
{ key: 'report', label: t('directory.tabs.report'), icon: 'mdi:file-document-outline' },
|
||||
]
|
||||
|
||||
const info = reactive({ name: '', email: '', phone: '', website: '' })
|
||||
const infoTouched = reactive({ name: false })
|
||||
const savingInfo = ref(false)
|
||||
|
||||
const emailError = computed(() => (isValidEmail(info.email) ? '' : t('directory.validation.emailInvalid')))
|
||||
const phoneError = computed(() => (isValidFrPhone(info.phone) ? '' : t('directory.validation.phoneInvalid')))
|
||||
const websiteError = computed(() => (isValidUrl(info.website) ? '' : t('directory.validation.urlInvalid')))
|
||||
const infoValid = computed(() => !emailError.value && !phoneError.value && !websiteError.value)
|
||||
|
||||
async function saveInfo(): Promise<void> {
|
||||
infoTouched.name = true
|
||||
if (!info.name.trim() || !infoValid.value || savingInfo.value) return
|
||||
savingInfo.value = true
|
||||
try {
|
||||
prestataire.value = await prestataireService.update(id, {
|
||||
name: info.name.trim(),
|
||||
email: info.email.trim() || null,
|
||||
phone: info.phone.trim() || null,
|
||||
website: info.website.trim() || null,
|
||||
})
|
||||
} finally {
|
||||
savingInfo.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function goBack(): void {
|
||||
router.push('/directory')
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
prestataire.value = await prestataireService.getById(id)
|
||||
info.name = prestataire.value.name ?? ''
|
||||
info.email = prestataire.value.email ?? ''
|
||||
info.phone = prestataire.value.phone ?? ''
|
||||
info.website = prestataire.value.website ?? ''
|
||||
await load()
|
||||
loading.value = false
|
||||
})
|
||||
</script>
|
||||
@@ -1,26 +1,25 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-6">
|
||||
<div class="flex items-center gap-3 pt-4">
|
||||
<MalioButtonIcon icon="mdi:arrow-left" :aria-label="$t('common.back')" @click="goBack" />
|
||||
<h1 class="text-2xl font-bold text-neutral-900">{{ prospect?.name ?? '…' }}</h1>
|
||||
</div>
|
||||
<div>
|
||||
<PageHeader>
|
||||
<span class="inline-flex items-center gap-3">
|
||||
<MalioButtonIcon icon="mdi:arrow-left" :aria-label="$t('common.back')" @click="goBack" />
|
||||
{{ prospect?.company ?? '…' }}
|
||||
</span>
|
||||
</PageHeader>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<p v-if="loading">{{ $t('common.loading') }}</p>
|
||||
<template v-else-if="prospect">
|
||||
<MalioTabList v-model="activeTab" :tabs="tabs">
|
||||
<template #info>
|
||||
<div class="flex flex-col gap-4 pt-6">
|
||||
<div class="relative grid grid-cols-2 gap-x-[44px] gap-y-4 rounded-lg bg-white px-7 py-5 shadow-[0_4px_4px_0_rgba(0,0,0,0.10)]">
|
||||
<MalioInputText
|
||||
v-model="info.name"
|
||||
class="col-span-2"
|
||||
:label="$t('prospects.fields.name')"
|
||||
:error="infoTouched.name && !info.name.trim() ? $t('prospects.validation.nameRequired') : ''"
|
||||
@blur="infoTouched.name = true"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.company"
|
||||
class="col-span-2"
|
||||
:label="$t('prospects.fields.company')"
|
||||
:error="infoTouched.company && !info.company.trim() ? $t('prospects.validation.companyRequired') : ''"
|
||||
@blur="infoTouched.company = true"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="info.status"
|
||||
@@ -28,13 +27,20 @@
|
||||
:options="statusOptions"
|
||||
group-class="w-full"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.website"
|
||||
:label="$t('prospects.fields.website')"
|
||||
:error="websiteError"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.email"
|
||||
:label="$t('prospects.fields.email')"
|
||||
:error="emailError"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.phone"
|
||||
:label="$t('prospects.fields.phone')"
|
||||
:error="phoneError"
|
||||
/>
|
||||
<MalioInputText
|
||||
v-model="info.source"
|
||||
@@ -51,7 +57,7 @@
|
||||
<MalioButton
|
||||
button-class="w-auto px-6"
|
||||
:label="$t('common.save')"
|
||||
:disabled="savingInfo"
|
||||
:disabled="savingInfo || !infoValid"
|
||||
@click="saveInfo"
|
||||
/>
|
||||
</div>
|
||||
@@ -123,12 +129,14 @@
|
||||
</template>
|
||||
</MalioTabList>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Prospect, ProspectStatus } from '~/modules/directory/services/dto/prospect'
|
||||
import { useProspectService } from '~/modules/directory/services/prospects'
|
||||
import { isValidEmail, isValidFrPhone, isValidUrl } from '~/modules/directory/utils/validation'
|
||||
|
||||
definePageMeta({ middleware: ['admin'] })
|
||||
|
||||
@@ -182,27 +190,32 @@ const statusOptions = [
|
||||
// Champs de base de la fiche, édités en mémoire et persistés au clic sur
|
||||
// « Enregistrer » (PATCH), comme les onglets Contact/Adresse.
|
||||
const info = reactive<{
|
||||
name: string
|
||||
company: string
|
||||
email: string
|
||||
phone: string
|
||||
website: string
|
||||
status: ProspectStatus
|
||||
source: string
|
||||
notes: string
|
||||
}>({ name: '', company: '', email: '', phone: '', status: 'new', source: '', notes: '' })
|
||||
const infoTouched = reactive({ name: false })
|
||||
}>({ company: '', email: '', phone: '', website: '', status: 'new', source: '', notes: '' })
|
||||
const infoTouched = reactive({ company: false })
|
||||
const savingInfo = ref(false)
|
||||
|
||||
const emailError = computed(() => (isValidEmail(info.email) ? '' : t('directory.validation.emailInvalid')))
|
||||
const phoneError = computed(() => (isValidFrPhone(info.phone) ? '' : t('directory.validation.phoneInvalid')))
|
||||
const websiteError = computed(() => (isValidUrl(info.website) ? '' : t('directory.validation.urlInvalid')))
|
||||
const infoValid = computed(() => !emailError.value && !phoneError.value && !websiteError.value)
|
||||
|
||||
async function saveInfo(): Promise<void> {
|
||||
infoTouched.name = true
|
||||
if (!info.name.trim() || savingInfo.value) return
|
||||
infoTouched.company = true
|
||||
if (!info.company.trim() || !infoValid.value || savingInfo.value) return
|
||||
savingInfo.value = true
|
||||
try {
|
||||
prospect.value = await prospectService.update(id, {
|
||||
name: info.name.trim(),
|
||||
company: info.company.trim() || null,
|
||||
company: info.company.trim(),
|
||||
email: info.email.trim() || null,
|
||||
phone: info.phone.trim() || null,
|
||||
website: info.website.trim() || null,
|
||||
status: info.status,
|
||||
source: info.source.trim() || null,
|
||||
notes: info.notes.trim() || null,
|
||||
@@ -218,10 +231,10 @@ function goBack(): void {
|
||||
|
||||
onMounted(async () => {
|
||||
prospect.value = await prospectService.getById(id)
|
||||
info.name = prospect.value.name ?? ''
|
||||
info.company = prospect.value.company ?? ''
|
||||
info.email = prospect.value.email ?? ''
|
||||
info.phone = prospect.value.phone ?? ''
|
||||
info.website = prospect.value.website ?? ''
|
||||
info.status = prospect.value.status ?? 'new'
|
||||
info.source = prospect.value.source ?? ''
|
||||
info.notes = prospect.value.notes ?? ''
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Address, AddressWrite } from './dto/address'
|
||||
import type { HydraCollection } from '~/utils/api'
|
||||
import { extractHydraMembers } from '~/utils/api'
|
||||
|
||||
type Owner = { client?: string, prospect?: string }
|
||||
type Owner = { client?: string, prospect?: string, prestataire?: string }
|
||||
|
||||
export function useAddressService() {
|
||||
const api = useApi()
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { CommercialReport, CommercialReportWrite } from './dto/commercial-r
|
||||
import type { HydraCollection } from '~/utils/api'
|
||||
import { extractHydraMembers } from '~/utils/api'
|
||||
|
||||
type Owner = { client?: string, prospect?: string }
|
||||
type Owner = { client?: string, prospect?: string, prestataire?: string }
|
||||
|
||||
export function useCommercialReportService() {
|
||||
const api = useApi()
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Contact, ContactWrite } from './dto/contact'
|
||||
import type { HydraCollection } from '~/utils/api'
|
||||
import { extractHydraMembers } from '~/utils/api'
|
||||
|
||||
type Owner = { client?: string, prospect?: string }
|
||||
type Owner = { client?: string, prospect?: string, prestataire?: string }
|
||||
|
||||
export function useContactService() {
|
||||
const api = useApi()
|
||||
|
||||
@@ -9,6 +9,7 @@ export type Address = {
|
||||
country: string
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
export type AddressWrite = {
|
||||
@@ -20,4 +21,5 @@ export type AddressWrite = {
|
||||
country: string
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ export type Client = {
|
||||
name: string
|
||||
email: string | null
|
||||
phone: string | null
|
||||
website: string | null
|
||||
}
|
||||
|
||||
export type ClientWrite = {
|
||||
name: string
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
website?: string | null
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ export type CommercialReport = {
|
||||
author?: { id: number, username: string } | null
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
documents?: ReportDocument[]
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
@@ -24,4 +25,5 @@ export type CommercialReportWrite = {
|
||||
type: ReportType
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ export type Contact = {
|
||||
phoneSecondary: string | null
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
export type ContactWrite = {
|
||||
@@ -20,4 +21,5 @@ export type ContactWrite = {
|
||||
phoneSecondary: string | null
|
||||
client?: string | null
|
||||
prospect?: string | null
|
||||
prestataire?: string | null
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export type Prestataire = {
|
||||
id: number
|
||||
'@id'?: string
|
||||
name: string
|
||||
email: string | null
|
||||
phone: string | null
|
||||
website: string | null
|
||||
}
|
||||
|
||||
export type PrestataireWrite = {
|
||||
name: string
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
website?: string | null
|
||||
}
|
||||
@@ -5,10 +5,10 @@ export type ProspectStatus = 'new' | 'contacted' | 'qualified' | 'won' | 'lost'
|
||||
export type Prospect = {
|
||||
id: number
|
||||
'@id'?: string
|
||||
name: string
|
||||
company: string | null
|
||||
company: string
|
||||
email: string | null
|
||||
phone: string | null
|
||||
website: string | null
|
||||
status: ProspectStatus
|
||||
source: string | null
|
||||
notes: string | null
|
||||
@@ -18,10 +18,10 @@ export type Prospect = {
|
||||
}
|
||||
|
||||
export type ProspectWrite = {
|
||||
name: string
|
||||
company?: string | null
|
||||
company: string
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
website?: string | null
|
||||
status?: ProspectStatus
|
||||
source?: string | null
|
||||
notes?: string | null
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { Prestataire, PrestataireWrite } from './dto/prestataire'
|
||||
import type { HydraCollection } from '~/utils/api'
|
||||
import { extractHydraMembers } from '~/utils/api'
|
||||
|
||||
export function usePrestataireService() {
|
||||
const api = useApi()
|
||||
|
||||
async function getAll(): Promise<Prestataire[]> {
|
||||
const data = await api.get<HydraCollection<Prestataire>>('/prestataires')
|
||||
return extractHydraMembers(data)
|
||||
}
|
||||
|
||||
async function getById(id: number): Promise<Prestataire> {
|
||||
return api.get<Prestataire>(`/prestataires/${id}`)
|
||||
}
|
||||
|
||||
async function create(payload: PrestataireWrite): Promise<Prestataire> {
|
||||
return api.post<Prestataire>('/prestataires', payload as Record<string, unknown>, {
|
||||
toastSuccessKey: 'prestataires.created',
|
||||
})
|
||||
}
|
||||
|
||||
async function update(id: number, payload: Partial<PrestataireWrite>): Promise<Prestataire> {
|
||||
return api.patch<Prestataire>(`/prestataires/${id}`, payload as Record<string, unknown>, {
|
||||
toastSuccessKey: 'prestataires.updated',
|
||||
})
|
||||
}
|
||||
|
||||
async function remove(id: number): Promise<void> {
|
||||
await api.delete(`/prestataires/${id}`, {}, {
|
||||
toastSuccessKey: 'prestataires.deleted',
|
||||
})
|
||||
}
|
||||
|
||||
return { getAll, getById, create, update, remove }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Validateurs partagés du répertoire (annuaire). Chaque validateur considère
|
||||
// une valeur VIDE comme valide : les champs email/téléphone/site web sont
|
||||
// facultatifs — la validation ne porte que sur le format quand c'est renseigné.
|
||||
|
||||
/** Email basique (présence d'un @ entouré de caractères, un point dans le domaine). */
|
||||
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
||||
|
||||
/**
|
||||
* Téléphone français : 10 chiffres commençant par 0 (ex. `0549200910`) — format
|
||||
* saisi par l'utilisateur, sans séparateurs — ou notation internationale
|
||||
* `+33XXXXXXXXX` (9 chiffres après l'indicatif). Les espaces, points et tirets
|
||||
* sont tolérés à la frappe (retirés avant contrôle).
|
||||
*/
|
||||
const FR_PHONE_NATIONAL_RE = /^0\d{9}$/
|
||||
const FR_PHONE_INTL_RE = /^\+33\d{9}$/
|
||||
|
||||
const URL_RE = /^https?:\/\/[^\s.]+\.[^\s]+$/
|
||||
|
||||
/** Retire les séparateurs usuels d'un numéro (espaces, points, tirets, parenthèses). */
|
||||
export function stripPhoneSeparators(value: string): string {
|
||||
return value.replace(/[\s.\-()]/g, '')
|
||||
}
|
||||
|
||||
export function isValidEmail(value: string | null | undefined): boolean {
|
||||
const v = (value ?? '').trim()
|
||||
if (v === '') return true
|
||||
return EMAIL_RE.test(v)
|
||||
}
|
||||
|
||||
export function isValidFrPhone(value: string | null | undefined): boolean {
|
||||
const v = stripPhoneSeparators((value ?? '').trim())
|
||||
if (v === '') return true
|
||||
return FR_PHONE_NATIONAL_RE.test(v) || FR_PHONE_INTL_RE.test(v)
|
||||
}
|
||||
|
||||
export function isValidUrl(value: string | null | undefined): boolean {
|
||||
const v = (value ?? '').trim()
|
||||
if (v === '') return true
|
||||
return URL_RE.test(v)
|
||||
}
|
||||
@@ -95,11 +95,13 @@ function handleTaskLinked(_taskId: number): void {
|
||||
|
||||
<template>
|
||||
<div class="flex h-full flex-col overflow-hidden">
|
||||
<div class="flex flex-shrink-0 items-center justify-between border-b border-neutral-200 bg-white px-4 py-3">
|
||||
<h1 class="text-lg font-semibold text-neutral-900">
|
||||
<div class="flex-shrink-0">
|
||||
<PageHeader>
|
||||
{{ t('mail.title') }}
|
||||
</h1>
|
||||
<MailRefreshButton />
|
||||
<template #actions>
|
||||
<MailRefreshButton />
|
||||
</template>
|
||||
</PageHeader>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-1 overflow-hidden">
|
||||
|
||||
@@ -355,9 +355,9 @@ onMounted(async () => {
|
||||
<template>
|
||||
<div class="min-w-0">
|
||||
<!-- Header + Filters -->
|
||||
<div class="sticky top-8 z-20 bg-white pb-4 sm:top-12">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">{{ $t('myTasks.title') }}</h1>
|
||||
<PageHeader>
|
||||
{{ $t('myTasks.title') }}
|
||||
<template #actions>
|
||||
<div class="flex items-center gap-2">
|
||||
<MalioButton
|
||||
icon-name="mdi:plus"
|
||||
@@ -378,78 +378,79 @@ onMounted(async () => {
|
||||
<Icon name="mdi:format-list-bulleted" size="20" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex flex-wrap gap-3">
|
||||
<MalioSelect
|
||||
v-model="selectedProjectId"
|
||||
:options="projectOptions"
|
||||
label="Projet"
|
||||
:empty-option-label="$t('myTasks.allProjects')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedGroupId"
|
||||
:options="groupOptions"
|
||||
label="Groupe"
|
||||
:empty-option-label="$t('myTasks.allGroups')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedTagId"
|
||||
:options="tagOptions"
|
||||
label="Type"
|
||||
:empty-option-label="$t('myTasks.allTypes')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedPriorityId"
|
||||
:options="priorityOptions"
|
||||
label="Priorité"
|
||||
:empty-option-label="$t('myTasks.allPriorities')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedEffortId"
|
||||
:options="effortOptions"
|
||||
label="Effort"
|
||||
:empty-option-label="$t('myTasks.allEfforts')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedAssigneeId"
|
||||
:options="assigneeOptions"
|
||||
label="Assigné"
|
||||
:empty-option-label="$t('myTasks.allAssignees')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="sortById"
|
||||
:options="sortOptions"
|
||||
:label="$t('myTasks.sortBy')"
|
||||
:empty-option-label="$t('myTasks.sortDefault')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #subheader>
|
||||
<div class="mt-4 flex flex-wrap gap-3">
|
||||
<MalioSelect
|
||||
v-model="selectedProjectId"
|
||||
:options="projectOptions"
|
||||
label="Projet"
|
||||
:empty-option-label="$t('myTasks.allProjects')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedGroupId"
|
||||
:options="groupOptions"
|
||||
label="Groupe"
|
||||
:empty-option-label="$t('myTasks.allGroups')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedTagId"
|
||||
:options="tagOptions"
|
||||
label="Type"
|
||||
:empty-option-label="$t('myTasks.allTypes')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedPriorityId"
|
||||
:options="priorityOptions"
|
||||
label="Priorité"
|
||||
:empty-option-label="$t('myTasks.allPriorities')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedEffortId"
|
||||
:options="effortOptions"
|
||||
label="Effort"
|
||||
:empty-option-label="$t('myTasks.allEfforts')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedAssigneeId"
|
||||
:options="assigneeOptions"
|
||||
label="Assigné"
|
||||
:empty-option-label="$t('myTasks.allAssignees')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="sortById"
|
||||
:options="sortOptions"
|
||||
:label="$t('myTasks.sortBy')"
|
||||
:empty-option-label="$t('myTasks.sortDefault')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<!-- Kanban View — grouped by canonical category -->
|
||||
<div v-if="viewMode === 'kanban'">
|
||||
<div class="mt-6 flex h-[calc(100vh-260px)] gap-3 overflow-x-auto pb-4">
|
||||
<div class="flex h-[calc(100vh-260px)] gap-3 overflow-x-auto pb-4">
|
||||
<div
|
||||
v-for="cat in CATEGORIES"
|
||||
:key="cat"
|
||||
@@ -509,7 +510,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<!-- List View -->
|
||||
<div v-if="viewMode === 'list'" class="mt-6 flex flex-col gap-2.5 rounded-[10px] bg-tertiary-500 p-2.5">
|
||||
<div v-if="viewMode === 'list'" class="flex flex-col gap-2.5 rounded-[10px] bg-tertiary-500 p-2.5">
|
||||
<TaskBulkActions
|
||||
:selected-count="selectedTaskIds.size"
|
||||
:total-count="tasks.length"
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="sticky top-8 z-20 bg-white pb-4 sm:top-12">
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">{{ project?.name ?? '' }} — {{ $t('archive.title') }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<MalioSelect
|
||||
v-model="selectedGroupId"
|
||||
:options="groupFilterOptions"
|
||||
label="Groupe"
|
||||
empty-option-label="Tous les groupes"
|
||||
group-class="w-64"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<PageHeader>
|
||||
{{ project?.name ?? '' }} — {{ $t('archive.title') }}
|
||||
<template #subheader>
|
||||
<div class="mt-4">
|
||||
<MalioSelect
|
||||
v-model="selectedGroupId"
|
||||
:options="groupFilterOptions"
|
||||
label="Groupe"
|
||||
empty-option-label="Tous les groupes"
|
||||
group-class="w-64"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<div>
|
||||
<p v-if="filteredTasks.length === 0" class="text-sm text-neutral-400">
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="sticky top-8 z-20 bg-white pb-4 sm:top-12">
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">{{ project?.name ?? '' }} — Groupes</h1>
|
||||
</div>
|
||||
</div>
|
||||
<PageHeader>{{ project?.name ?? '' }} — Groupes</PageHeader>
|
||||
|
||||
<div>
|
||||
<ProjectGroupTab :project-id="projectId" />
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="min-w-0">
|
||||
<div class="sticky top-8 z-20 bg-white pb-4 sm:top-12">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">{{ project?.name ?? '' }}</h1>
|
||||
<PageHeader>
|
||||
{{ project?.name ?? '' }}
|
||||
<template #actions>
|
||||
<div class="flex items-center gap-2">
|
||||
<MalioButton
|
||||
icon-name="mdi:plus"
|
||||
@@ -30,66 +30,67 @@
|
||||
@click="projectDrawerOpen = true"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex flex-wrap gap-3">
|
||||
<MalioSelect
|
||||
v-model="selectedGroupId"
|
||||
:options="groupFilterOptions"
|
||||
label="Groupe"
|
||||
empty-option-label="Tous les groupes"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedTagId"
|
||||
:options="tagFilterOptions"
|
||||
label="Tags"
|
||||
empty-option-label="Tous les tags"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedAssigneeId"
|
||||
:options="userFilterOptions"
|
||||
label="User"
|
||||
empty-option-label="Tous les users"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-if="viewMode === 'list'"
|
||||
v-model="selectedStatusId"
|
||||
:options="statusFilterOptions"
|
||||
label="Status"
|
||||
empty-option-label="Tous les status"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedPriorityId"
|
||||
:options="priorityFilterOptions"
|
||||
label="Priorité"
|
||||
empty-option-label="Toutes"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedEffortId"
|
||||
:options="effortFilterOptions"
|
||||
label="Effort"
|
||||
empty-option-label="Tous"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #subheader>
|
||||
<div class="mt-4 flex flex-wrap gap-3">
|
||||
<MalioSelect
|
||||
v-model="selectedGroupId"
|
||||
:options="groupFilterOptions"
|
||||
label="Groupe"
|
||||
empty-option-label="Tous les groupes"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedTagId"
|
||||
:options="tagFilterOptions"
|
||||
label="Tags"
|
||||
empty-option-label="Tous les tags"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedAssigneeId"
|
||||
:options="userFilterOptions"
|
||||
label="User"
|
||||
empty-option-label="Tous les users"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-if="viewMode === 'list'"
|
||||
v-model="selectedStatusId"
|
||||
:options="statusFilterOptions"
|
||||
label="Status"
|
||||
empty-option-label="Tous les status"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedPriorityId"
|
||||
:options="priorityFilterOptions"
|
||||
label="Priorité"
|
||||
empty-option-label="Toutes"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedEffortId"
|
||||
:options="effortFilterOptions"
|
||||
label="Effort"
|
||||
empty-option-label="Tous"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<!-- Kanban -->
|
||||
<div v-if="viewMode === 'kanban'" class="mt-6 flex h-[calc(100vh-200px)] gap-3 overflow-x-auto pb-4">
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="sticky top-8 z-20 bg-white pb-4 sm:top-12">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">{{ $t('projects.title') }}</h1>
|
||||
<PageHeader>
|
||||
{{ $t('projects.title') }}
|
||||
<template #actions>
|
||||
<div class="flex items-center gap-2 sm:gap-3">
|
||||
<MalioButton
|
||||
variant="tertiary"
|
||||
@@ -23,8 +23,8 @@
|
||||
<span class="sm:hidden">{{ $t('projects.addProjectShort') }}</span>
|
||||
</MalioButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
<div
|
||||
|
||||
@@ -1,60 +1,59 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="sticky top-8 z-20 bg-white pb-4 sm:top-12">
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">
|
||||
{{ $t('reporting.title') }}
|
||||
</h1>
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="mt-4 flex flex-wrap items-end gap-3">
|
||||
<MalioSelect
|
||||
v-model="selectedPeriod"
|
||||
:options="periodOptions"
|
||||
:label="$t('reporting.filters.period')"
|
||||
group-class="!w-48"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<div class="w-40">
|
||||
<label class="mb-1 block text-sm font-medium text-neutral-700">
|
||||
{{ $t('reporting.filters.from') }}
|
||||
</label>
|
||||
<MalioDate
|
||||
v-model="customFrom"
|
||||
:disabled="selectedPeriod !== 'custom'"
|
||||
group-class="w-full"
|
||||
<PageHeader>
|
||||
{{ $t('reporting.title') }}
|
||||
<template #subheader>
|
||||
<!-- Filters -->
|
||||
<div class="mt-4 flex flex-wrap items-end gap-3">
|
||||
<MalioSelect
|
||||
v-model="selectedPeriod"
|
||||
:options="periodOptions"
|
||||
:label="$t('reporting.filters.period')"
|
||||
group-class="!w-48"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<div class="w-40">
|
||||
<label class="mb-1 block text-sm font-medium text-neutral-700">
|
||||
{{ $t('reporting.filters.from') }}
|
||||
</label>
|
||||
<MalioDate
|
||||
v-model="customFrom"
|
||||
:disabled="selectedPeriod !== 'custom'"
|
||||
group-class="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div class="w-40">
|
||||
<label class="mb-1 block text-sm font-medium text-neutral-700">
|
||||
{{ $t('reporting.filters.to') }}
|
||||
</label>
|
||||
<MalioDate
|
||||
v-model="customTo"
|
||||
:disabled="selectedPeriod !== 'custom'"
|
||||
group-class="w-full"
|
||||
/>
|
||||
</div>
|
||||
<MalioSelect
|
||||
v-model="selectedProjectId"
|
||||
:options="projectOptions"
|
||||
:label="$t('reporting.filters.project')"
|
||||
:empty-option-label="$t('reporting.filters.allProjects')"
|
||||
group-class="!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedUserId"
|
||||
:options="userOptions"
|
||||
:label="$t('reporting.filters.user')"
|
||||
:empty-option-label="$t('reporting.filters.allUsers')"
|
||||
group-class="!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div class="w-40">
|
||||
<label class="mb-1 block text-sm font-medium text-neutral-700">
|
||||
{{ $t('reporting.filters.to') }}
|
||||
</label>
|
||||
<MalioDate
|
||||
v-model="customTo"
|
||||
:disabled="selectedPeriod !== 'custom'"
|
||||
group-class="w-full"
|
||||
/>
|
||||
</div>
|
||||
<MalioSelect
|
||||
v-model="selectedProjectId"
|
||||
:options="projectOptions"
|
||||
:label="$t('reporting.filters.project')"
|
||||
:empty-option-label="$t('reporting.filters.allProjects')"
|
||||
group-class="!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedUserId"
|
||||
:options="userOptions"
|
||||
:label="$t('reporting.filters.user')"
|
||||
:empty-option-label="$t('reporting.filters.allUsers')"
|
||||
group-class="!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<!-- Loading -->
|
||||
<div v-if="isLoading" class="mt-12 flex items-center justify-center">
|
||||
|
||||
@@ -1,101 +1,104 @@
|
||||
<template>
|
||||
<div class="flex min-h-0 flex-1 flex-col">
|
||||
<div ref="pageHeaderEl" class="sticky top-8 z-20 flex-shrink-0 bg-white pb-4 sm:top-12">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">Suivi des temps</h1>
|
||||
<MalioButton
|
||||
icon-name="mdi:plus"
|
||||
icon-position="left"
|
||||
button-class="shrink-0"
|
||||
@click="openCreateDrawer()"
|
||||
>
|
||||
<span class="hidden sm:inline">Ajouter une Activité</span>
|
||||
<span class="sm:hidden">Activité</span>
|
||||
</MalioButton>
|
||||
</div>
|
||||
|
||||
<div class="relative z-30 mt-4 flex flex-wrap items-center gap-3 sm:gap-4">
|
||||
<div class="flex shrink-0 items-center gap-1 h-8">
|
||||
<MalioButtonIcon
|
||||
icon="mdi:chevron-left"
|
||||
aria-label="Précédent"
|
||||
variant="ghost"
|
||||
@click="navigatePrev"
|
||||
/>
|
||||
<DateFilter v-model="selectedDateFilter" :picker-mode="viewMode === 'day' ? 'day' : 'week'" />
|
||||
<h2 class="shrink-0 whitespace-nowrap text-lg font-bold leading-8 text-orange-500">
|
||||
{{ currentMonthLabel }}
|
||||
</h2>
|
||||
<MalioButtonIcon
|
||||
icon="mdi:chevron-right"
|
||||
aria-label="Suivant"
|
||||
variant="ghost"
|
||||
@click="navigateNext"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center rounded-full bg-neutral-100 p-1">
|
||||
<button
|
||||
v-for="mode in (['week', 'day', 'list'] as const)"
|
||||
:key="mode"
|
||||
class="rounded-full px-4 py-1.5 text-sm font-semibold transition-all"
|
||||
:class="viewMode === mode
|
||||
? 'bg-primary-500 text-white shadow-sm'
|
||||
: 'text-neutral-500 hover:text-neutral-700'"
|
||||
@click="viewMode = mode"
|
||||
<div ref="pageHeaderEl" class="flex-shrink-0">
|
||||
<PageHeader>
|
||||
Suivi des temps
|
||||
<template #actions>
|
||||
<MalioButton
|
||||
icon-name="mdi:plus"
|
||||
icon-position="left"
|
||||
button-class="shrink-0"
|
||||
@click="openCreateDrawer()"
|
||||
>
|
||||
{{ mode === 'week' ? 'Semaine' : mode === 'day' ? 'Jour' : 'Liste' }}
|
||||
</button>
|
||||
</div>
|
||||
<span class="hidden sm:inline">Ajouter une Activité</span>
|
||||
<span class="sm:hidden">Activité</span>
|
||||
</MalioButton>
|
||||
</template>
|
||||
<template #subheader>
|
||||
<div class="relative z-30 mt-4 flex flex-wrap items-center gap-3 sm:gap-4">
|
||||
<div class="flex shrink-0 items-center gap-1 h-8">
|
||||
<MalioButtonIcon
|
||||
icon="mdi:chevron-left"
|
||||
aria-label="Précédent"
|
||||
variant="ghost"
|
||||
@click="navigatePrev"
|
||||
/>
|
||||
<DateFilter v-model="selectedDateFilter" :picker-mode="viewMode === 'day' ? 'day' : 'week'" />
|
||||
<h2 class="shrink-0 whitespace-nowrap text-lg font-bold leading-8 text-orange-500">
|
||||
{{ currentMonthLabel }}
|
||||
</h2>
|
||||
<MalioButtonIcon
|
||||
icon="mdi:chevron-right"
|
||||
aria-label="Suivant"
|
||||
variant="ghost"
|
||||
@click="navigateNext"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="[&>div]:!mt-0">
|
||||
<MalioSelect
|
||||
v-model="selectedUserId"
|
||||
:options="userOptions"
|
||||
group-class="!w-36 sm:!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
label="User"
|
||||
empty-option-label="Tous"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex items-center rounded-full bg-neutral-100 p-1">
|
||||
<button
|
||||
v-for="mode in (['week', 'day', 'list'] as const)"
|
||||
:key="mode"
|
||||
class="rounded-full px-4 py-1.5 text-sm font-semibold transition-all"
|
||||
:class="viewMode === mode
|
||||
? 'bg-primary-500 text-white shadow-sm'
|
||||
: 'text-neutral-500 hover:text-neutral-700'"
|
||||
@click="viewMode = mode"
|
||||
>
|
||||
{{ mode === 'week' ? 'Semaine' : mode === 'day' ? 'Jour' : 'Liste' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="[&>div]:!mt-0">
|
||||
<MalioSelect
|
||||
v-model="selectedProjectId"
|
||||
:options="projectOptions"
|
||||
empty-option-label="Tous"
|
||||
label="Projet"
|
||||
group-class="!w-36 sm:!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div class="[&>div]:!mt-0">
|
||||
<MalioSelect
|
||||
v-model="selectedUserId"
|
||||
:options="userOptions"
|
||||
group-class="!w-36 sm:!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
label="User"
|
||||
empty-option-label="Tous"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="[&>div]:!mt-0">
|
||||
<MalioSelect
|
||||
v-model="selectedTagId"
|
||||
:options="tagOptions"
|
||||
empty-option-label="Tous"
|
||||
label="Tag"
|
||||
group-class="!w-36 sm:!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div class="[&>div]:!mt-0">
|
||||
<MalioSelect
|
||||
v-model="selectedProjectId"
|
||||
:options="projectOptions"
|
||||
empty-option-label="Tous"
|
||||
label="Projet"
|
||||
group-class="!w-36 sm:!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<MalioButton
|
||||
:label="$t('timeEntries.export')"
|
||||
variant="secondary"
|
||||
icon-name="mdi:download"
|
||||
icon-position="left"
|
||||
button-class="w-auto px-4"
|
||||
@click="exportDrawerOpen = true"
|
||||
/>
|
||||
</div>
|
||||
<div class="[&>div]:!mt-0">
|
||||
<MalioSelect
|
||||
v-model="selectedTagId"
|
||||
:options="tagOptions"
|
||||
empty-option-label="Tous"
|
||||
label="Tag"
|
||||
group-class="!w-36 sm:!w-44"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<MalioButton
|
||||
:label="$t('timeEntries.export')"
|
||||
variant="secondary"
|
||||
icon-name="mdi:download"
|
||||
icon-position="left"
|
||||
button-class="w-auto px-4"
|
||||
@click="exportDrawerOpen = true"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
</div>
|
||||
|
||||
<div class="relative z-0 mt-4 -mb-24 min-h-0 flex-1">
|
||||
<div class="relative z-0 -mb-24 min-h-0 flex-1">
|
||||
<TimeEntryList
|
||||
v-if="viewMode === 'list'"
|
||||
:entries="filteredEntries"
|
||||
|
||||
Generated
+4
-4
@@ -7,7 +7,7 @@
|
||||
"name": "nuxt-app",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@malio/layer-ui": "^1.7.5",
|
||||
"@malio/layer-ui": "^1.7.16",
|
||||
"@nuxt/icon": "^2.2.1",
|
||||
"@nuxtjs/i18n": "^10.2.3",
|
||||
"@nuxtjs/tailwindcss": "^6.14.0",
|
||||
@@ -2220,9 +2220,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@malio/layer-ui": {
|
||||
"version": "1.7.5",
|
||||
"resolved": "https://gitea.malio.fr/api/packages/MALIO-DEV/npm/%40malio%2Flayer-ui/-/1.7.5/layer-ui-1.7.5.tgz",
|
||||
"integrity": "sha512-xryrAYgVgX3eurEWXT/d0p4r/MBYNBB3mBnvV6xVcFhzxW+HfOra8hsVHLvrCtd+m5E1t7PDRzjw1FObkV6fdQ==",
|
||||
"version": "1.7.16",
|
||||
"resolved": "https://gitea.malio.fr/api/packages/MALIO-DEV/npm/%40malio%2Flayer-ui/-/1.7.16/layer-ui-1.7.16.tgz",
|
||||
"integrity": "sha512-24scQzhfnwLJr+JTlusiiazkjEK8pqwPp5NZGLdFbP32f+J9RpwoJf/U0ztwIJssXEeYvJB4cdLDYow7dZJv6Q==",
|
||||
"dependencies": {
|
||||
"@nuxt/icon": "^2.2.1",
|
||||
"@nuxtjs/tailwindcss": "^6.14.0",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"build:dist": "nuxt generate && rm -rf dist && cp -R .output/public dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@malio/layer-ui": "^1.7.5",
|
||||
"@malio/layer-ui": "^1.7.16",
|
||||
"@nuxt/icon": "^2.2.1",
|
||||
"@nuxtjs/i18n": "^10.2.3",
|
||||
"@nuxtjs/tailwindcss": "^6.14.0",
|
||||
|
||||
+21
-22
@@ -1,27 +1,27 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="sticky top-8 z-20 bg-white pb-4 sm:top-12">
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">Administration</h1>
|
||||
|
||||
<div class="mt-6 border-b border-neutral-200 overflow-x-auto">
|
||||
<nav class="flex gap-4 sm:gap-6">
|
||||
<button
|
||||
v-for="tab in visibleTabs"
|
||||
:key="tab.key"
|
||||
class="whitespace-nowrap px-1 pb-3 text-sm font-semibold transition"
|
||||
:class="activeTab === tab.key
|
||||
? 'border-b-2 border-primary-500 text-primary-500'
|
||||
: 'text-neutral-500 hover:text-neutral-700'"
|
||||
@click="activeTab = tab.key"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<PageHeader>
|
||||
Administration
|
||||
<template #subheader>
|
||||
<div class="mt-6 border-b border-neutral-200 overflow-x-auto">
|
||||
<nav class="flex gap-4 sm:gap-6">
|
||||
<button
|
||||
v-for="tab in visibleTabs"
|
||||
:key="tab.key"
|
||||
class="whitespace-nowrap px-1 pb-3 text-sm font-semibold transition"
|
||||
:class="activeTab === tab.key
|
||||
? 'border-b-2 border-primary-500 text-primary-500'
|
||||
: 'text-neutral-500 hover:text-neutral-700'"
|
||||
@click="activeTab = tab.key"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<div>
|
||||
<AdminClientTab v-if="activeTab === 'clients'" />
|
||||
<AdminWorkflowTab v-if="activeTab === 'workflows'" />
|
||||
<AdminEffortTab v-if="activeTab === 'efforts'" />
|
||||
<AdminPriorityTab v-if="activeTab === 'priorities'" />
|
||||
@@ -50,7 +50,6 @@ const canViewRoles = computed(() => can('core.roles.view'))
|
||||
const canViewAudit = computed(() => can('core.audit_log.view'))
|
||||
|
||||
const tabs = [
|
||||
{ key: 'clients', label: 'Clients' },
|
||||
{ key: 'workflows', label: 'Workflows' },
|
||||
{ key: 'efforts', label: 'Efforts' },
|
||||
{ key: 'priorities', label: 'Priorités' },
|
||||
@@ -72,5 +71,5 @@ const visibleTabs = computed(() =>
|
||||
tabs.filter((tab) => !('permission' in tab) || can(tab.permission)),
|
||||
)
|
||||
|
||||
const activeTab = ref<TabKey>('clients')
|
||||
const activeTab = ref<TabKey>('workflows')
|
||||
</script>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">{{ $t('sharedFiles.title') }}</h1>
|
||||
<PageHeader>{{ $t('sharedFiles.title') }}</PageHeader>
|
||||
|
||||
<!-- Fil d'Ariane -->
|
||||
<nav class="mt-4 flex flex-wrap items-center gap-1 text-sm text-neutral-500">
|
||||
<nav class="flex flex-wrap items-center gap-1 text-sm text-neutral-500">
|
||||
<button class="hover:text-primary-500" @click="openPath('')">{{ $t('sharedFiles.root') }}</button>
|
||||
<template v-for="crumb in breadcrumb" :key="crumb.path">
|
||||
<span>/</span>
|
||||
@@ -12,7 +12,7 @@
|
||||
</nav>
|
||||
|
||||
<!-- Filtre local + rechargement -->
|
||||
<div class="mt-4 flex items-center gap-2">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="max-w-sm flex-1">
|
||||
<MalioInputText
|
||||
v-model="filter"
|
||||
|
||||
+35
-34
@@ -506,39 +506,40 @@ const lineOptions = {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="sticky top-8 z-20 bg-white pb-4 sm:top-12">
|
||||
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">{{ $t('dashboard.title') }}</h1>
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="mt-4 flex flex-wrap gap-3">
|
||||
<MalioSelect
|
||||
v-model="selectedPeriod"
|
||||
:options="periodOptions"
|
||||
:label="$t('dashboard.filters.period')"
|
||||
group-class="!w-48"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedProjectId"
|
||||
:options="projectOptions"
|
||||
:label="$t('dashboard.filters.project')"
|
||||
:empty-option-label="$t('dashboard.filters.allProjects')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedUserId"
|
||||
:options="userOptions"
|
||||
:label="$t('dashboard.filters.user')"
|
||||
:empty-option-label="$t('dashboard.filters.allUsers')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<PageHeader>
|
||||
{{ $t('dashboard.title') }}
|
||||
<template #subheader>
|
||||
<!-- Filters -->
|
||||
<div class="mt-4 flex flex-wrap gap-3">
|
||||
<MalioSelect
|
||||
v-model="selectedPeriod"
|
||||
:options="periodOptions"
|
||||
:label="$t('dashboard.filters.period')"
|
||||
group-class="!w-48"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedProjectId"
|
||||
:options="projectOptions"
|
||||
:label="$t('dashboard.filters.project')"
|
||||
:empty-option-label="$t('dashboard.filters.allProjects')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
<MalioSelect
|
||||
v-model="selectedUserId"
|
||||
:options="userOptions"
|
||||
:label="$t('dashboard.filters.user')"
|
||||
:empty-option-label="$t('dashboard.filters.allUsers')"
|
||||
group-class="!w-40"
|
||||
text-field="text-sm"
|
||||
text-value="text-sm"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<!-- Loading -->
|
||||
<div v-if="isLoading" class="mt-12 flex items-center justify-center">
|
||||
@@ -547,7 +548,7 @@ const lineOptions = {
|
||||
|
||||
<template v-else>
|
||||
<!-- KPI Cards -->
|
||||
<div class="mt-6 grid grid-cols-2 gap-4 lg:grid-cols-4">
|
||||
<div class="grid grid-cols-2 gap-4 lg:grid-cols-4">
|
||||
<div class="rounded-xl border border-neutral-100 bg-neutral-50 p-5">
|
||||
<p class="text-xs font-medium uppercase tracking-wider text-neutral-400">
|
||||
{{ $t('dashboard.stats.hoursPeriod') }}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -1,6 +1,5 @@
|
||||
export const useUiStore = defineStore('ui', () => {
|
||||
const sidebarCollapsed = ref(false)
|
||||
const sidebarOpen = ref(false)
|
||||
const darkMode = ref(false)
|
||||
|
||||
if (import.meta.client) {
|
||||
@@ -45,13 +44,5 @@ export const useUiStore = defineStore('ui', () => {
|
||||
sidebarCollapsed.value = !sidebarCollapsed.value
|
||||
}
|
||||
|
||||
function openMobileSidebar() {
|
||||
sidebarOpen.value = true
|
||||
}
|
||||
|
||||
function closeMobileSidebar() {
|
||||
sidebarOpen.value = false
|
||||
}
|
||||
|
||||
return { sidebarCollapsed, sidebarOpen, darkMode, toggleSidebar, openMobileSidebar, closeMobileSidebar, toggleDarkMode }
|
||||
return { sidebarCollapsed, darkMode, toggleSidebar, toggleDarkMode }
|
||||
})
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { $fetch } from 'ofetch'
|
||||
|
||||
/**
|
||||
* Appel HTTP vers un service EXTERNE (hors API Lesstime) : pas de cookie de
|
||||
* session, pas d'enveloppe Hydra, timeout court. Utilisé par l'autocomplétion
|
||||
* d'adresse branchée sur la Base Adresse Nationale (api-adresse.data.gouv.fr).
|
||||
* Ne jamais passer par `useApi()` pour ces domaines tiers.
|
||||
*/
|
||||
export interface HttpExternalOptions {
|
||||
/** Paramètres de query string (encodés par ofetch). */
|
||||
query?: Record<string, string | number | undefined>
|
||||
/** Timeout en millisecondes avant abandon (défaut 5000). */
|
||||
timeoutMs?: number
|
||||
}
|
||||
|
||||
export async function httpExternal<T>(
|
||||
url: string,
|
||||
opts: HttpExternalOptions = {},
|
||||
): Promise<T> {
|
||||
return $fetch<T>(url, {
|
||||
query: opts.query,
|
||||
credentials: 'omit',
|
||||
retry: 0,
|
||||
timeout: opts.timeoutMs ?? 5000,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260624153709 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Directory: prestataire entity + website on client/prospect/prestataire + prestataire ownership on contacts/addresses/reports + prospect company-only';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE prestataire (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) DEFAULT NULL, phone VARCHAR(50) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_by INT DEFAULT NULL, updated_by INT DEFAULT NULL, PRIMARY KEY (id))');
|
||||
$this->addSql('CREATE INDEX IDX_60A26480DE12AB56 ON prestataire (created_by)');
|
||||
$this->addSql('CREATE INDEX IDX_60A2648016FE72E1 ON prestataire (updated_by)');
|
||||
$this->addSql('ALTER TABLE prestataire ADD CONSTRAINT FK_60A26480DE12AB56 FOREIGN KEY (created_by) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE');
|
||||
$this->addSql('ALTER TABLE prestataire ADD CONSTRAINT FK_60A2648016FE72E1 FOREIGN KEY (updated_by) REFERENCES "user" (id) ON DELETE SET NULL NOT DEFERRABLE');
|
||||
$this->addSql('ALTER TABLE client ADD website VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE commercial_report ADD prestataire_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE commercial_report ADD CONSTRAINT FK_886919D8BE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id) ON DELETE CASCADE NOT DEFERRABLE');
|
||||
$this->addSql('CREATE INDEX IDX_886919D8BE3DB2B7 ON commercial_report (prestataire_id)');
|
||||
$this->addSql('ALTER TABLE directory_address ADD prestataire_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE directory_address ADD CONSTRAINT FK_6E5D9707BE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id) ON DELETE CASCADE NOT DEFERRABLE');
|
||||
$this->addSql('CREATE INDEX IDX_6E5D9707BE3DB2B7 ON directory_address (prestataire_id)');
|
||||
$this->addSql('ALTER TABLE directory_contact ADD prestataire_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE directory_contact ADD CONSTRAINT FK_2F711EBEBE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id) ON DELETE CASCADE NOT DEFERRABLE');
|
||||
$this->addSql('CREATE INDEX IDX_2F711EBEBE3DB2B7 ON directory_contact (prestataire_id)');
|
||||
|
||||
// Prospect désormais société-only : on conserve la donnée existante en
|
||||
// recopiant le nom dans la société quand celle-ci est vide, avant de
|
||||
// rendre la colonne obligatoire et de supprimer la colonne name.
|
||||
$this->addSql('ALTER TABLE prospect ADD website VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql("UPDATE prospect SET company = name WHERE company IS NULL OR company = ''");
|
||||
$this->addSql('ALTER TABLE prospect ALTER company SET NOT NULL');
|
||||
$this->addSql('ALTER TABLE prospect DROP name');
|
||||
|
||||
// Ownership CHECK constraints: chaque ligne appartient à un client,
|
||||
// un prospect OU un prestataire.
|
||||
$this->addSql('ALTER TABLE directory_contact DROP CONSTRAINT chk_contact_owner');
|
||||
$this->addSql('ALTER TABLE directory_contact ADD CONSTRAINT chk_contact_owner CHECK (client_id IS NOT NULL OR prospect_id IS NOT NULL OR prestataire_id IS NOT NULL)');
|
||||
$this->addSql('ALTER TABLE directory_address DROP CONSTRAINT chk_address_owner');
|
||||
$this->addSql('ALTER TABLE directory_address ADD CONSTRAINT chk_address_owner CHECK (client_id IS NOT NULL OR prospect_id IS NOT NULL OR prestataire_id IS NOT NULL)');
|
||||
$this->addSql('ALTER TABLE commercial_report DROP CONSTRAINT chk_report_owner');
|
||||
$this->addSql('ALTER TABLE commercial_report ADD CONSTRAINT chk_report_owner CHECK (client_id IS NOT NULL OR prospect_id IS NOT NULL OR prestataire_id IS NOT NULL)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// Rétablit les contraintes d'ownership client/prospect (sans prestataire).
|
||||
$this->addSql('ALTER TABLE directory_contact DROP CONSTRAINT chk_contact_owner');
|
||||
$this->addSql('ALTER TABLE directory_address DROP CONSTRAINT chk_address_owner');
|
||||
$this->addSql('ALTER TABLE commercial_report DROP CONSTRAINT chk_report_owner');
|
||||
|
||||
$this->addSql('ALTER TABLE commercial_report DROP CONSTRAINT FK_886919D8BE3DB2B7');
|
||||
$this->addSql('DROP INDEX IDX_886919D8BE3DB2B7');
|
||||
$this->addSql('ALTER TABLE commercial_report DROP prestataire_id');
|
||||
$this->addSql('ALTER TABLE directory_address DROP CONSTRAINT FK_6E5D9707BE3DB2B7');
|
||||
$this->addSql('DROP INDEX IDX_6E5D9707BE3DB2B7');
|
||||
$this->addSql('ALTER TABLE directory_address DROP prestataire_id');
|
||||
$this->addSql('ALTER TABLE directory_contact DROP CONSTRAINT FK_2F711EBEBE3DB2B7');
|
||||
$this->addSql('DROP INDEX IDX_2F711EBEBE3DB2B7');
|
||||
$this->addSql('ALTER TABLE directory_contact DROP prestataire_id');
|
||||
|
||||
$this->addSql('ALTER TABLE directory_contact ADD CONSTRAINT chk_contact_owner CHECK (client_id IS NOT NULL OR prospect_id IS NOT NULL)');
|
||||
$this->addSql('ALTER TABLE directory_address ADD CONSTRAINT chk_address_owner CHECK (client_id IS NOT NULL OR prospect_id IS NOT NULL)');
|
||||
$this->addSql('ALTER TABLE commercial_report ADD CONSTRAINT chk_report_owner CHECK (client_id IS NOT NULL OR prospect_id IS NOT NULL)');
|
||||
|
||||
$this->addSql('ALTER TABLE prestataire DROP CONSTRAINT FK_60A26480DE12AB56');
|
||||
$this->addSql('ALTER TABLE prestataire DROP CONSTRAINT FK_60A2648016FE72E1');
|
||||
$this->addSql('DROP TABLE prestataire');
|
||||
$this->addSql('ALTER TABLE client DROP website');
|
||||
|
||||
// Restaure la colonne name (recopiée depuis company) puis l'oblige.
|
||||
$this->addSql('ALTER TABLE prospect ADD name VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('UPDATE prospect SET name = company');
|
||||
$this->addSql('ALTER TABLE prospect ALTER name SET NOT NULL');
|
||||
$this->addSql('ALTER TABLE prospect DROP website');
|
||||
$this->addSql('ALTER TABLE prospect ALTER company DROP NOT NULL');
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,6 @@ class AppFixtures extends Fixture
|
||||
|
||||
// Prospects
|
||||
$prospectLead = new Prospect();
|
||||
$prospectLead->setName('Marie Dupont');
|
||||
$prospectLead->setCompany('Atelier Dupont');
|
||||
$prospectLead->setEmail('marie@atelier-dupont.fr');
|
||||
$prospectLead->setPhone('06 11 22 33 44');
|
||||
@@ -145,7 +144,6 @@ class AppFixtures extends Fixture
|
||||
$manager->persist($addressLead);
|
||||
|
||||
$prospectQualified = new Prospect();
|
||||
$prospectQualified->setName('Jean Martin');
|
||||
$prospectQualified->setCompany('Martin & Fils');
|
||||
$prospectQualified->setEmail('contact@martin-fils.fr');
|
||||
$prospectQualified->setPhone('07 55 66 77 88');
|
||||
@@ -163,7 +161,6 @@ class AppFixtures extends Fixture
|
||||
$manager->persist($addressQualified);
|
||||
|
||||
$prospectWon = new Prospect();
|
||||
$prospectWon->setName('Sophie Bernard');
|
||||
$prospectWon->setCompany('ACME Corp');
|
||||
$prospectWon->setEmail('contact@acme.com');
|
||||
$prospectWon->setPhone('01 23 45 67 89');
|
||||
|
||||
@@ -111,9 +111,18 @@ class AccrueLeaveCommand extends Command
|
||||
$previousBalance = null !== $previousPeriod
|
||||
? $this->balanceRepository->findOneForPeriod($user, AbsenceType::PaidLeave, $previousPeriod)
|
||||
: null;
|
||||
$balance->setAcquired(
|
||||
null !== $previousBalance ? $previousBalance->getAcquiring() : $profile->getInitialLeaveBalance(),
|
||||
);
|
||||
|
||||
if (null !== $previousBalance) {
|
||||
// Only the days *not yet taken* carry over. Leave is charged
|
||||
// oldest-first: it first consumes the previous "acquired"
|
||||
// (N-2) bucket — which expires at roll-over anyway — so only
|
||||
// days taken beyond that bucket eat into the carry-over.
|
||||
$carryOver = $previousBalance->getAcquiring()
|
||||
- max(0.0, $previousBalance->getTaken() - $previousBalance->getAcquired());
|
||||
$balance->setAcquired(max(0.0, $carryOver));
|
||||
} else {
|
||||
$balance->setAcquired($profile->getInitialLeaveBalance());
|
||||
}
|
||||
}
|
||||
|
||||
if ($monthKey === $balance->getLastAccruedMonth()) {
|
||||
|
||||
@@ -38,6 +38,8 @@ final class DirectoryModule implements ModuleInterface
|
||||
['code' => 'directory.clients.manage', 'label' => 'Gérer les clients'],
|
||||
['code' => 'directory.prospects.view', 'label' => 'Voir les prospects'],
|
||||
['code' => 'directory.prospects.manage', 'label' => 'Gérer les prospects'],
|
||||
['code' => 'directory.providers.view', 'label' => 'Voir les prestataires'],
|
||||
['code' => 'directory.providers.manage', 'label' => 'Gérer les prestataires'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
#[Auditable]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(paginationEnabled: false, security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view')"),
|
||||
new Get(security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view')"),
|
||||
new Post(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage')"),
|
||||
new Patch(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage')"),
|
||||
new Delete(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage')"),
|
||||
new GetCollection(paginationEnabled: false, security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view') or is_granted('directory.providers.view')"),
|
||||
new Get(security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view') or is_granted('directory.providers.view')"),
|
||||
new Post(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage') or is_granted('directory.providers.manage')"),
|
||||
new Patch(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage') or is_granted('directory.providers.manage')"),
|
||||
new Delete(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage') or is_granted('directory.providers.manage')"),
|
||||
],
|
||||
normalizationContext: ['groups' => ['address:read']],
|
||||
denormalizationContext: ['groups' => ['address:write']],
|
||||
order: ['id' => 'ASC'],
|
||||
)]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['client' => 'exact', 'prospect' => 'exact'])]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['client' => 'exact', 'prospect' => 'exact', 'prestataire' => 'exact'])]
|
||||
#[ORM\Entity(repositoryClass: DoctrineAddressRepository::class)]
|
||||
#[ORM\Table(name: 'directory_address')]
|
||||
class Address implements TimestampableInterface, BlamableInterface
|
||||
@@ -80,6 +80,11 @@ class Address implements TimestampableInterface, BlamableInterface
|
||||
#[Groups(['address:read', 'address:write'])]
|
||||
private ?Prospect $prospect = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Prestataire::class)]
|
||||
#[ORM\JoinColumn(name: 'prestataire_id', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')]
|
||||
#[Groups(['address:read', 'address:write'])]
|
||||
private ?Prestataire $prestataire = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -180,4 +185,16 @@ class Address implements TimestampableInterface, BlamableInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrestataire(): ?Prestataire
|
||||
{
|
||||
return $this->prestataire;
|
||||
}
|
||||
|
||||
public function setPrestataire(?Prestataire $prestataire): static
|
||||
{
|
||||
$this->prestataire = $prestataire;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,10 @@ class Client implements ClientInterface, TimestampableInterface, BlamableInterfa
|
||||
#[Groups(['client:read', 'client:write'])]
|
||||
private ?string $phone = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['client:read', 'client:write'])]
|
||||
private ?string $website = null;
|
||||
|
||||
/** @var Collection<int, ProjectInterface> */
|
||||
#[ORM\OneToMany(targetEntity: ProjectInterface::class, mappedBy: 'client')]
|
||||
private Collection $projects;
|
||||
@@ -108,6 +112,18 @@ class Client implements ClientInterface, TimestampableInterface, BlamableInterfa
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWebsite(): ?string
|
||||
{
|
||||
return $this->website;
|
||||
}
|
||||
|
||||
public function setWebsite(?string $website): static
|
||||
{
|
||||
$this->website = $website;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, ProjectInterface> */
|
||||
public function getProjects(): Collection
|
||||
{
|
||||
|
||||
@@ -26,17 +26,17 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(paginationEnabled: false, security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view')"),
|
||||
new Get(security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view')"),
|
||||
new Post(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage')"),
|
||||
new Patch(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage')"),
|
||||
new Delete(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage')"),
|
||||
new GetCollection(paginationEnabled: false, security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view') or is_granted('directory.providers.view')"),
|
||||
new Get(security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view') or is_granted('directory.providers.view')"),
|
||||
new Post(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage') or is_granted('directory.providers.manage')"),
|
||||
new Patch(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage') or is_granted('directory.providers.manage')"),
|
||||
new Delete(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage') or is_granted('directory.providers.manage')"),
|
||||
],
|
||||
normalizationContext: ['groups' => ['commercial_report:read']],
|
||||
denormalizationContext: ['groups' => ['commercial_report:write']],
|
||||
order: ['occurredAt' => 'DESC'],
|
||||
)]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['client' => 'exact', 'prospect' => 'exact'])]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['client' => 'exact', 'prospect' => 'exact', 'prestataire' => 'exact'])]
|
||||
#[ORM\Entity(repositoryClass: DoctrineCommercialReportRepository::class)]
|
||||
#[ORM\Table(name: 'commercial_report')]
|
||||
class CommercialReport implements TimestampableInterface
|
||||
@@ -80,6 +80,11 @@ class CommercialReport implements TimestampableInterface
|
||||
#[Groups(['commercial_report:read', 'commercial_report:write'])]
|
||||
private ?Prospect $prospect = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Prestataire::class)]
|
||||
#[ORM\JoinColumn(name: 'prestataire_id', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')]
|
||||
#[Groups(['commercial_report:read', 'commercial_report:write'])]
|
||||
private ?Prestataire $prestataire = null;
|
||||
|
||||
/** @var Collection<int, ReportDocument> */
|
||||
#[ORM\OneToMany(targetEntity: ReportDocument::class, mappedBy: 'commercialReport', cascade: ['remove'])]
|
||||
#[Groups(['commercial_report:read'])]
|
||||
@@ -179,6 +184,18 @@ class CommercialReport implements TimestampableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrestataire(): ?Prestataire
|
||||
{
|
||||
return $this->prestataire;
|
||||
}
|
||||
|
||||
public function setPrestataire(?Prestataire $prestataire): static
|
||||
{
|
||||
$this->prestataire = $prestataire;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, ReportDocument> */
|
||||
public function getDocuments(): Collection
|
||||
{
|
||||
|
||||
@@ -23,17 +23,17 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
#[Auditable]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(paginationEnabled: false, security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view')"),
|
||||
new Get(security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view')"),
|
||||
new Post(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage')"),
|
||||
new Patch(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage')"),
|
||||
new Delete(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage')"),
|
||||
new GetCollection(paginationEnabled: false, security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view') or is_granted('directory.providers.view')"),
|
||||
new Get(security: "is_granted('directory.clients.view') or is_granted('directory.prospects.view') or is_granted('directory.providers.view')"),
|
||||
new Post(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage') or is_granted('directory.providers.manage')"),
|
||||
new Patch(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage') or is_granted('directory.providers.manage')"),
|
||||
new Delete(security: "is_granted('directory.clients.manage') or is_granted('directory.prospects.manage') or is_granted('directory.providers.manage')"),
|
||||
],
|
||||
normalizationContext: ['groups' => ['contact:read']],
|
||||
denormalizationContext: ['groups' => ['contact:write']],
|
||||
order: ['lastName' => 'ASC'],
|
||||
)]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['client' => 'exact', 'prospect' => 'exact'])]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['client' => 'exact', 'prospect' => 'exact', 'prestataire' => 'exact'])]
|
||||
#[ORM\Entity(repositoryClass: DoctrineContactRepository::class)]
|
||||
#[ORM\Table(name: 'directory_contact')]
|
||||
class Contact implements TimestampableInterface, BlamableInterface
|
||||
@@ -80,6 +80,11 @@ class Contact implements TimestampableInterface, BlamableInterface
|
||||
#[Groups(['contact:read', 'contact:write'])]
|
||||
private ?Prospect $prospect = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Prestataire::class)]
|
||||
#[ORM\JoinColumn(name: 'prestataire_id', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')]
|
||||
#[Groups(['contact:read', 'contact:write'])]
|
||||
private ?Prestataire $prestataire = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -180,4 +185,16 @@ class Contact implements TimestampableInterface, BlamableInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrestataire(): ?Prestataire
|
||||
{
|
||||
return $this->prestataire;
|
||||
}
|
||||
|
||||
public function setPrestataire(?Prestataire $prestataire): static
|
||||
{
|
||||
$this->prestataire = $prestataire;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Domain\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Delete;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Patch;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use App\Module\Directory\Infrastructure\Doctrine\DoctrinePrestataireRepository;
|
||||
use App\Shared\Domain\Attribute\Auditable;
|
||||
use App\Shared\Domain\Contract\BlamableInterface;
|
||||
use App\Shared\Domain\Contract\TimestampableInterface;
|
||||
use App\Shared\Domain\Trait\TimestampableBlamableTrait;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[Auditable]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(paginationEnabled: false, security: "is_granted('directory.providers.view')"),
|
||||
new Get(security: "is_granted('directory.providers.view')"),
|
||||
new Post(security: "is_granted('directory.providers.manage')"),
|
||||
new Patch(security: "is_granted('directory.providers.manage')"),
|
||||
new Delete(security: "is_granted('directory.providers.manage')"),
|
||||
],
|
||||
normalizationContext: ['groups' => ['prestataire:read']],
|
||||
denormalizationContext: ['groups' => ['prestataire:write']],
|
||||
order: ['name' => 'ASC'],
|
||||
)]
|
||||
#[ORM\Entity(repositoryClass: DoctrinePrestataireRepository::class)]
|
||||
#[ORM\Table(name: 'prestataire')]
|
||||
class Prestataire implements TimestampableInterface, BlamableInterface
|
||||
{
|
||||
use TimestampableBlamableTrait;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['prestataire:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['prestataire:read', 'prestataire:write'])]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['prestataire:read', 'prestataire:write'])]
|
||||
private ?string $email = null;
|
||||
|
||||
#[ORM\Column(length: 50, nullable: true)]
|
||||
#[Groups(['prestataire:read', 'prestataire:write'])]
|
||||
private ?string $phone = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['prestataire:read', 'prestataire:write'])]
|
||||
private ?string $website = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(?string $email): static
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhone(): ?string
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function setPhone(?string $phone): static
|
||||
{
|
||||
$this->phone = $phone;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWebsite(): ?string
|
||||
{
|
||||
return $this->website;
|
||||
}
|
||||
|
||||
public function setWebsite(?string $website): static
|
||||
{
|
||||
$this->website = $website;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
],
|
||||
normalizationContext: ['groups' => ['prospect:read']],
|
||||
denormalizationContext: ['groups' => ['prospect:write']],
|
||||
order: ['name' => 'ASC'],
|
||||
order: ['company' => 'ASC'],
|
||||
)]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['status' => 'exact'])]
|
||||
#[ORM\Entity(repositoryClass: DoctrineProspectRepository::class)]
|
||||
@@ -57,10 +57,6 @@ class Prospect implements TimestampableInterface, BlamableInterface
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['prospect:read', 'prospect:write'])]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['prospect:read', 'prospect:write'])]
|
||||
private ?string $company = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
@@ -71,6 +67,10 @@ class Prospect implements TimestampableInterface, BlamableInterface
|
||||
#[Groups(['prospect:read', 'prospect:write'])]
|
||||
private ?string $phone = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['prospect:read', 'prospect:write'])]
|
||||
private ?string $website = null;
|
||||
|
||||
#[ORM\Column(type: Types::STRING, length: 32, enumType: ProspectStatus::class)]
|
||||
#[Groups(['prospect:read', 'prospect:write'])]
|
||||
private ProspectStatus $status = ProspectStatus::New;
|
||||
@@ -93,24 +93,12 @@ class Prospect implements TimestampableInterface, BlamableInterface
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCompany(): ?string
|
||||
{
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
public function setCompany(?string $company): static
|
||||
public function setCompany(string $company): static
|
||||
{
|
||||
$this->company = $company;
|
||||
|
||||
@@ -141,6 +129,18 @@ class Prospect implements TimestampableInterface, BlamableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWebsite(): ?string
|
||||
{
|
||||
return $this->website;
|
||||
}
|
||||
|
||||
public function setWebsite(?string $website): static
|
||||
{
|
||||
$this->website = $website;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatus(): ProspectStatus
|
||||
{
|
||||
return $this->status;
|
||||
|
||||
@@ -9,4 +9,12 @@ use App\Module\Directory\Domain\Entity\Address;
|
||||
interface AddressRepositoryInterface
|
||||
{
|
||||
public function findById(int $id): ?Address;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $criteria
|
||||
* @param null|array<string, string> $orderBy
|
||||
*
|
||||
* @return Address[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
}
|
||||
|
||||
@@ -9,4 +9,12 @@ use App\Module\Directory\Domain\Entity\CommercialReport;
|
||||
interface CommercialReportRepositoryInterface
|
||||
{
|
||||
public function findById(int $id): ?CommercialReport;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $criteria
|
||||
* @param null|array<string, string> $orderBy
|
||||
*
|
||||
* @return CommercialReport[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
}
|
||||
|
||||
@@ -9,4 +9,12 @@ use App\Module\Directory\Domain\Entity\Contact;
|
||||
interface ContactRepositoryInterface
|
||||
{
|
||||
public function findById(int $id): ?Contact;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $criteria
|
||||
* @param null|array<string, string> $orderBy
|
||||
*
|
||||
* @return Contact[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Domain\Repository;
|
||||
|
||||
use App\Module\Directory\Domain\Entity\Prestataire;
|
||||
|
||||
interface PrestataireRepositoryInterface
|
||||
{
|
||||
public function findById(int $id): ?Prestataire;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $criteria
|
||||
* @param null|array<string, string> $orderBy
|
||||
*
|
||||
* @return Prestataire[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
}
|
||||
@@ -46,9 +46,10 @@ final readonly class ConvertProspectProcessor implements ProcessorInterface
|
||||
}
|
||||
|
||||
$client = new Client();
|
||||
$client->setName($prospect->getCompany() ?: (string) $prospect->getName());
|
||||
$client->setName((string) $prospect->getCompany());
|
||||
$client->setEmail($prospect->getEmail());
|
||||
$client->setPhone($prospect->getPhone());
|
||||
$client->setWebsite($prospect->getWebsite());
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Doctrine;
|
||||
|
||||
use App\Module\Directory\Domain\Entity\Prestataire;
|
||||
use App\Module\Directory\Domain\Repository\PrestataireRepositoryInterface;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Prestataire>
|
||||
*/
|
||||
final class DoctrinePrestataireRepository extends ServiceEntityRepository implements PrestataireRepositoryInterface
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Prestataire::class);
|
||||
}
|
||||
|
||||
public function findById(int $id): ?Prestataire
|
||||
{
|
||||
return $this->find($id);
|
||||
}
|
||||
}
|
||||
@@ -42,9 +42,10 @@ class ConvertProspectTool
|
||||
|
||||
if (null === $prospect->getConvertedClient()) {
|
||||
$client = new Client();
|
||||
$client->setName($prospect->getCompany() ?: (string) $prospect->getName());
|
||||
$client->setName((string) $prospect->getCompany());
|
||||
$client->setEmail($prospect->getEmail());
|
||||
$client->setPhone($prospect->getPhone());
|
||||
$client->setWebsite($prospect->getWebsite());
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Entity\Address;
|
||||
use App\Module\Directory\Domain\Repository\ClientRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\PrestataireRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\ProspectRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(
|
||||
name: 'create-address',
|
||||
description: 'Create an address (admin) attached to exactly one of clientId / prospectId / prestataireId. Country defaults to FR (ISO 3166 alpha-2).'
|
||||
)]
|
||||
class CreateAddressTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly ClientRepositoryInterface $clientRepository,
|
||||
private readonly ProspectRepositoryInterface $prospectRepository,
|
||||
private readonly PrestataireRepositoryInterface $prestataireRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
?int $clientId = null,
|
||||
?int $prospectId = null,
|
||||
?int $prestataireId = null,
|
||||
?string $label = null,
|
||||
?string $street = null,
|
||||
?string $streetComplement = null,
|
||||
?string $postalCode = null,
|
||||
?string $city = null,
|
||||
?string $country = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$parents = array_filter([$clientId, $prospectId, $prestataireId], static fn ($v) => null !== $v);
|
||||
if (1 !== count($parents)) {
|
||||
throw new InvalidArgumentException('Exactly one of clientId, prospectId or prestataireId must be provided.');
|
||||
}
|
||||
|
||||
$address = new Address();
|
||||
|
||||
if (null !== $clientId) {
|
||||
$client = $this->clientRepository->findById($clientId);
|
||||
if (null === $client) {
|
||||
throw new InvalidArgumentException(sprintf('Client with ID %d not found.', $clientId));
|
||||
}
|
||||
$address->setClient($client);
|
||||
}
|
||||
if (null !== $prospectId) {
|
||||
$prospect = $this->prospectRepository->findById($prospectId);
|
||||
if (null === $prospect) {
|
||||
throw new InvalidArgumentException(sprintf('Prospect with ID %d not found.', $prospectId));
|
||||
}
|
||||
$address->setProspect($prospect);
|
||||
}
|
||||
if (null !== $prestataireId) {
|
||||
$prestataire = $this->prestataireRepository->findById($prestataireId);
|
||||
if (null === $prestataire) {
|
||||
throw new InvalidArgumentException(sprintf('Prestataire with ID %d not found.', $prestataireId));
|
||||
}
|
||||
$address->setPrestataire($prestataire);
|
||||
}
|
||||
|
||||
$address->setLabel($label);
|
||||
$address->setStreet($street);
|
||||
$address->setStreetComplement($streetComplement);
|
||||
$address->setPostalCode($postalCode);
|
||||
$address->setCity($city);
|
||||
if (null !== $country) {
|
||||
if (2 !== strlen($country)) {
|
||||
throw new InvalidArgumentException('country must be a 2-letter ISO 3166 alpha-2 code (e.g., FR, BE).');
|
||||
}
|
||||
$address->setCountry(strtoupper($country));
|
||||
}
|
||||
|
||||
$this->entityManager->persist($address);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(Serializer::address($address));
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ class CreateClientTool
|
||||
string $name,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
@@ -32,6 +33,7 @@ class CreateClientTool
|
||||
$client->setName($name);
|
||||
$client->setEmail($email);
|
||||
$client->setPhone($phone);
|
||||
$client->setWebsite($website);
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Entity\CommercialReport;
|
||||
use App\Module\Directory\Domain\Enum\ReportType;
|
||||
use App\Module\Directory\Domain\Repository\ClientRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\PrestataireRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\ProspectRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(
|
||||
name: 'create-commercial-report',
|
||||
description: 'Create a commercial report (admin) attached to exactly one of clientId / prospectId / prestataireId. Type defaults to "note". Allowed types: note, call, meeting, email. Date defaults to today if omitted.'
|
||||
)]
|
||||
class CreateCommercialReportTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly ClientRepositoryInterface $clientRepository,
|
||||
private readonly ProspectRepositoryInterface $prospectRepository,
|
||||
private readonly PrestataireRepositoryInterface $prestataireRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
string $subject,
|
||||
?int $clientId = null,
|
||||
?int $prospectId = null,
|
||||
?int $prestataireId = null,
|
||||
?string $body = null,
|
||||
?string $occurredAt = null,
|
||||
?string $type = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$parents = array_filter([$clientId, $prospectId, $prestataireId], static fn ($v) => null !== $v);
|
||||
if (1 !== count($parents)) {
|
||||
throw new InvalidArgumentException('Exactly one of clientId, prospectId or prestataireId must be provided.');
|
||||
}
|
||||
|
||||
$report = new CommercialReport();
|
||||
$report->setSubject($subject);
|
||||
$report->setBody($body);
|
||||
|
||||
if (null !== $clientId) {
|
||||
$client = $this->clientRepository->findById($clientId);
|
||||
if (null === $client) {
|
||||
throw new InvalidArgumentException(sprintf('Client with ID %d not found.', $clientId));
|
||||
}
|
||||
$report->setClient($client);
|
||||
}
|
||||
if (null !== $prospectId) {
|
||||
$prospect = $this->prospectRepository->findById($prospectId);
|
||||
if (null === $prospect) {
|
||||
throw new InvalidArgumentException(sprintf('Prospect with ID %d not found.', $prospectId));
|
||||
}
|
||||
$report->setProspect($prospect);
|
||||
}
|
||||
if (null !== $prestataireId) {
|
||||
$prestataire = $this->prestataireRepository->findById($prestataireId);
|
||||
if (null === $prestataire) {
|
||||
throw new InvalidArgumentException(sprintf('Prestataire with ID %d not found.', $prestataireId));
|
||||
}
|
||||
$report->setPrestataire($prestataire);
|
||||
}
|
||||
|
||||
try {
|
||||
$date = null === $occurredAt
|
||||
? new DateTimeImmutable('today')
|
||||
: new DateTimeImmutable($occurredAt);
|
||||
} catch (Exception $e) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid occurredAt "%s": %s', $occurredAt, $e->getMessage()));
|
||||
}
|
||||
$report->setOccurredAt($date);
|
||||
|
||||
if (null !== $type) {
|
||||
$typeEnum = ReportType::tryFrom($type);
|
||||
if (null === $typeEnum) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid type "%s". Allowed: note, call, meeting, email.', $type));
|
||||
}
|
||||
$report->setType($typeEnum);
|
||||
}
|
||||
|
||||
$this->entityManager->persist($report);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(Serializer::commercialReport($report));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Entity\Contact;
|
||||
use App\Module\Directory\Domain\Repository\ClientRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\PrestataireRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\ProspectRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(
|
||||
name: 'create-contact',
|
||||
description: 'Create a contact (admin) attached to exactly one of clientId / prospectId / prestataireId. All fields except the parent are optional.'
|
||||
)]
|
||||
class CreateContactTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly ClientRepositoryInterface $clientRepository,
|
||||
private readonly ProspectRepositoryInterface $prospectRepository,
|
||||
private readonly PrestataireRepositoryInterface $prestataireRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
?int $clientId = null,
|
||||
?int $prospectId = null,
|
||||
?int $prestataireId = null,
|
||||
?string $firstName = null,
|
||||
?string $lastName = null,
|
||||
?string $jobTitle = null,
|
||||
?string $email = null,
|
||||
?string $phonePrimary = null,
|
||||
?string $phoneSecondary = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$parents = array_filter([$clientId, $prospectId, $prestataireId], static fn ($v) => null !== $v);
|
||||
if (1 !== count($parents)) {
|
||||
throw new InvalidArgumentException('Exactly one of clientId, prospectId or prestataireId must be provided.');
|
||||
}
|
||||
|
||||
$contact = new Contact();
|
||||
|
||||
if (null !== $clientId) {
|
||||
$client = $this->clientRepository->findById($clientId);
|
||||
if (null === $client) {
|
||||
throw new InvalidArgumentException(sprintf('Client with ID %d not found.', $clientId));
|
||||
}
|
||||
$contact->setClient($client);
|
||||
}
|
||||
if (null !== $prospectId) {
|
||||
$prospect = $this->prospectRepository->findById($prospectId);
|
||||
if (null === $prospect) {
|
||||
throw new InvalidArgumentException(sprintf('Prospect with ID %d not found.', $prospectId));
|
||||
}
|
||||
$contact->setProspect($prospect);
|
||||
}
|
||||
if (null !== $prestataireId) {
|
||||
$prestataire = $this->prestataireRepository->findById($prestataireId);
|
||||
if (null === $prestataire) {
|
||||
throw new InvalidArgumentException(sprintf('Prestataire with ID %d not found.', $prestataireId));
|
||||
}
|
||||
$contact->setPrestataire($prestataire);
|
||||
}
|
||||
|
||||
$contact->setFirstName($firstName);
|
||||
$contact->setLastName($lastName);
|
||||
$contact->setJobTitle($jobTitle);
|
||||
$contact->setEmail($email);
|
||||
$contact->setPhonePrimary($phonePrimary);
|
||||
$contact->setPhoneSecondary($phoneSecondary);
|
||||
|
||||
$this->entityManager->persist($contact);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(Serializer::contact($contact));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Entity\Prestataire;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
#[McpTool(name: 'create-prestataire', description: 'Create a prestataire / service provider (admin). Only name is required.')]
|
||||
class CreatePrestataireTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
string $name,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$prestataire = new Prestataire();
|
||||
$prestataire->setName($name);
|
||||
$prestataire->setEmail($email);
|
||||
$prestataire->setPhone($phone);
|
||||
$prestataire->setWebsite($website);
|
||||
|
||||
$this->entityManager->persist($prestataire);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(Serializer::prestataire($prestataire));
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'create-prospect', description: 'Create a prospect (admin). Only name is required. Status defaults to "new".')]
|
||||
#[McpTool(name: 'create-prospect', description: 'Create a prospect (admin). Only company is required. Status defaults to "new".')]
|
||||
class CreateProspectTool
|
||||
{
|
||||
public function __construct(
|
||||
@@ -24,10 +24,10 @@ class CreateProspectTool
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
string $name,
|
||||
?string $company = null,
|
||||
string $company,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
?string $status = null,
|
||||
?string $source = null,
|
||||
?string $notes = null,
|
||||
@@ -37,10 +37,10 @@ class CreateProspectTool
|
||||
}
|
||||
|
||||
$prospect = new Prospect();
|
||||
$prospect->setName($name);
|
||||
$prospect->setCompany($company);
|
||||
$prospect->setEmail($email);
|
||||
$prospect->setPhone($phone);
|
||||
$prospect->setWebsite($website);
|
||||
$prospect->setSource($source);
|
||||
$prospect->setNotes($notes);
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\AddressRepositoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'delete-address', description: 'Delete an address (admin).')]
|
||||
class DeleteAddressTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AddressRepositoryInterface $addressRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(int $id): string
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$address = $this->addressRepository->findById($id);
|
||||
if (null === $address) {
|
||||
throw new InvalidArgumentException(sprintf('Address with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
$this->entityManager->remove($address);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(['success' => true, 'message' => sprintf('Address #%d deleted.', $id)]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\CommercialReportRepositoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'delete-commercial-report', description: 'Delete a commercial report (admin). Cascade removes its attached documents.')]
|
||||
class DeleteCommercialReportTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CommercialReportRepositoryInterface $reportRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(int $id): string
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$report = $this->reportRepository->findById($id);
|
||||
if (null === $report) {
|
||||
throw new InvalidArgumentException(sprintf('CommercialReport with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
$this->entityManager->remove($report);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(['success' => true, 'message' => sprintf('CommercialReport #%d deleted.', $id)]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\ContactRepositoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'delete-contact', description: 'Delete a contact (admin).')]
|
||||
class DeleteContactTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ContactRepositoryInterface $contactRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(int $id): string
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$contact = $this->contactRepository->findById($id);
|
||||
if (null === $contact) {
|
||||
throw new InvalidArgumentException(sprintf('Contact with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
$this->entityManager->remove($contact);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(['success' => true, 'message' => sprintf('Contact #%d deleted.', $id)]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\PrestataireRepositoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'delete-prestataire', description: 'Delete a prestataire (admin). Cascade removes its contacts, addresses and reports.')]
|
||||
class DeletePrestataireTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PrestataireRepositoryInterface $prestataireRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(int $id): string
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$prestataire = $this->prestataireRepository->findById($id);
|
||||
if (null === $prestataire) {
|
||||
throw new InvalidArgumentException(sprintf('Prestataire with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
$name = $prestataire->getName();
|
||||
$this->entityManager->remove($prestataire);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(['success' => true, 'message' => sprintf('Prestataire "%s" deleted.', $name)]);
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,10 @@ class DeleteProspectTool
|
||||
throw new InvalidArgumentException(sprintf('Prospect with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
$name = $prospect->getName();
|
||||
$company = $prospect->getCompany();
|
||||
$this->entityManager->remove($prospect);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(['success' => true, 'message' => sprintf('Prospect "%s" deleted.', $name)]);
|
||||
return json_encode(['success' => true, 'message' => sprintf('Prospect "%s" deleted.', $company)]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\AddressRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'get-address', description: 'Get an address by ID.')]
|
||||
class GetAddressTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AddressRepositoryInterface $addressRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(int $id): string
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$address = $this->addressRepository->findById($id);
|
||||
if (null === $address) {
|
||||
throw new InvalidArgumentException(sprintf('Address with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
return json_encode(Serializer::address($address));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\AddressRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\ClientRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\CommercialReportRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\ContactRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
@@ -13,11 +16,14 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'get-client', description: 'Get a client by ID with full contact details.')]
|
||||
#[McpTool(name: 'get-client', description: 'Get a client by ID, with its linked contacts, addresses, and commercial reports.')]
|
||||
class GetClientTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ClientRepositoryInterface $clientRepository,
|
||||
private readonly ContactRepositoryInterface $contactRepository,
|
||||
private readonly AddressRepositoryInterface $addressRepository,
|
||||
private readonly CommercialReportRepositoryInterface $reportRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
@@ -32,6 +38,20 @@ class GetClientTool
|
||||
throw new InvalidArgumentException(sprintf('Client with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
return json_encode(Serializer::client($client));
|
||||
$payload = Serializer::client($client);
|
||||
$payload['contacts'] = array_map(
|
||||
fn ($c) => Serializer::contact($c),
|
||||
$this->contactRepository->findBy(['client' => $client], ['lastName' => 'ASC'])
|
||||
);
|
||||
$payload['addresses'] = array_map(
|
||||
fn ($a) => Serializer::address($a),
|
||||
$this->addressRepository->findBy(['client' => $client], ['id' => 'ASC'])
|
||||
);
|
||||
$payload['reports'] = array_map(
|
||||
fn ($r) => Serializer::commercialReport($r),
|
||||
$this->reportRepository->findBy(['client' => $client], ['occurredAt' => 'DESC'])
|
||||
);
|
||||
|
||||
return json_encode($payload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\CommercialReportRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'get-commercial-report', description: 'Get a commercial report by ID, including its attached documents.')]
|
||||
class GetCommercialReportTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CommercialReportRepositoryInterface $reportRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(int $id): string
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$report = $this->reportRepository->findById($id);
|
||||
if (null === $report) {
|
||||
throw new InvalidArgumentException(sprintf('CommercialReport with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
return json_encode(Serializer::commercialReport($report));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\ContactRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'get-contact', description: 'Get a contact by ID.')]
|
||||
class GetContactTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ContactRepositoryInterface $contactRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(int $id): string
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$contact = $this->contactRepository->findById($id);
|
||||
if (null === $contact) {
|
||||
throw new InvalidArgumentException(sprintf('Contact with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
return json_encode(Serializer::contact($contact));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\AddressRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\CommercialReportRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\ContactRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\PrestataireRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'get-prestataire', description: 'Get a prestataire by ID, with its linked contacts, addresses, and commercial reports.')]
|
||||
class GetPrestataireTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PrestataireRepositoryInterface $prestataireRepository,
|
||||
private readonly ContactRepositoryInterface $contactRepository,
|
||||
private readonly AddressRepositoryInterface $addressRepository,
|
||||
private readonly CommercialReportRepositoryInterface $reportRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(int $id): string
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$prestataire = $this->prestataireRepository->findById($id);
|
||||
if (null === $prestataire) {
|
||||
throw new InvalidArgumentException(sprintf('Prestataire with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
$payload = Serializer::prestataire($prestataire);
|
||||
$payload['contacts'] = array_map(
|
||||
fn ($c) => Serializer::contact($c),
|
||||
$this->contactRepository->findBy(['prestataire' => $prestataire], ['lastName' => 'ASC'])
|
||||
);
|
||||
$payload['addresses'] = array_map(
|
||||
fn ($a) => Serializer::address($a),
|
||||
$this->addressRepository->findBy(['prestataire' => $prestataire], ['id' => 'ASC'])
|
||||
);
|
||||
$payload['reports'] = array_map(
|
||||
fn ($r) => Serializer::commercialReport($r),
|
||||
$this->reportRepository->findBy(['prestataire' => $prestataire], ['occurredAt' => 'DESC'])
|
||||
);
|
||||
|
||||
return json_encode($payload);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\AddressRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\CommercialReportRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\ContactRepositoryInterface;
|
||||
use App\Module\Directory\Domain\Repository\ProspectRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use InvalidArgumentException;
|
||||
@@ -13,11 +16,14 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'get-prospect', description: 'Get a prospect by ID with full details.')]
|
||||
#[McpTool(name: 'get-prospect', description: 'Get a prospect by ID, with its linked contacts, addresses, and commercial reports.')]
|
||||
class GetProspectTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProspectRepositoryInterface $prospectRepository,
|
||||
private readonly ContactRepositoryInterface $contactRepository,
|
||||
private readonly AddressRepositoryInterface $addressRepository,
|
||||
private readonly CommercialReportRepositoryInterface $reportRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
@@ -32,6 +38,20 @@ class GetProspectTool
|
||||
throw new InvalidArgumentException(sprintf('Prospect with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
return json_encode(Serializer::prospect($prospect));
|
||||
$payload = Serializer::prospect($prospect);
|
||||
$payload['contacts'] = array_map(
|
||||
fn ($c) => Serializer::contact($c),
|
||||
$this->contactRepository->findBy(['prospect' => $prospect], ['lastName' => 'ASC'])
|
||||
);
|
||||
$payload['addresses'] = array_map(
|
||||
fn ($a) => Serializer::address($a),
|
||||
$this->addressRepository->findBy(['prospect' => $prospect], ['id' => 'ASC'])
|
||||
);
|
||||
$payload['reports'] = array_map(
|
||||
fn ($r) => Serializer::commercialReport($r),
|
||||
$this->reportRepository->findBy(['prospect' => $prospect], ['occurredAt' => 'DESC'])
|
||||
);
|
||||
|
||||
return json_encode($payload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\AddressRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
#[McpTool(
|
||||
name: 'list-addresses',
|
||||
description: 'List addresses, optionally filtered by parent (at most one of clientId / prospectId / prestataireId).'
|
||||
)]
|
||||
class ListAddressesTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AddressRepositoryInterface $addressRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
?int $clientId = null,
|
||||
?int $prospectId = null,
|
||||
?int $prestataireId = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$filters = array_filter([$clientId, $prospectId, $prestataireId], static fn ($v) => null !== $v);
|
||||
if (count($filters) > 1) {
|
||||
throw new InvalidArgumentException('At most one of clientId, prospectId or prestataireId can be provided.');
|
||||
}
|
||||
|
||||
$criteria = [];
|
||||
if (null !== $clientId) {
|
||||
$criteria['client'] = $clientId;
|
||||
}
|
||||
if (null !== $prospectId) {
|
||||
$criteria['prospect'] = $prospectId;
|
||||
}
|
||||
if (null !== $prestataireId) {
|
||||
$criteria['prestataire'] = $prestataireId;
|
||||
}
|
||||
|
||||
$addresses = $this->addressRepository->findBy($criteria, ['id' => 'ASC']);
|
||||
|
||||
return json_encode(array_map(fn ($a) => Serializer::address($a), $addresses));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\CommercialReportRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
#[McpTool(
|
||||
name: 'list-commercial-reports',
|
||||
description: 'List commercial reports, optionally filtered by parent (at most one of clientId / prospectId / prestataireId). Returns reports ordered by occurredAt DESC.'
|
||||
)]
|
||||
class ListCommercialReportsTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CommercialReportRepositoryInterface $reportRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
?int $clientId = null,
|
||||
?int $prospectId = null,
|
||||
?int $prestataireId = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$filters = array_filter([$clientId, $prospectId, $prestataireId], static fn ($v) => null !== $v);
|
||||
if (count($filters) > 1) {
|
||||
throw new InvalidArgumentException('At most one of clientId, prospectId or prestataireId can be provided.');
|
||||
}
|
||||
|
||||
$criteria = [];
|
||||
if (null !== $clientId) {
|
||||
$criteria['client'] = $clientId;
|
||||
}
|
||||
if (null !== $prospectId) {
|
||||
$criteria['prospect'] = $prospectId;
|
||||
}
|
||||
if (null !== $prestataireId) {
|
||||
$criteria['prestataire'] = $prestataireId;
|
||||
}
|
||||
|
||||
$reports = $this->reportRepository->findBy($criteria, ['occurredAt' => 'DESC']);
|
||||
|
||||
return json_encode(array_map(fn ($r) => Serializer::commercialReport($r), $reports));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\ContactRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
#[McpTool(
|
||||
name: 'list-contacts',
|
||||
description: 'List contacts, optionally filtered by parent (at most one of clientId / prospectId / prestataireId).'
|
||||
)]
|
||||
class ListContactsTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ContactRepositoryInterface $contactRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
?int $clientId = null,
|
||||
?int $prospectId = null,
|
||||
?int $prestataireId = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$filters = array_filter([$clientId, $prospectId, $prestataireId], static fn ($v) => null !== $v);
|
||||
if (count($filters) > 1) {
|
||||
throw new InvalidArgumentException('At most one of clientId, prospectId or prestataireId can be provided.');
|
||||
}
|
||||
|
||||
$criteria = [];
|
||||
if (null !== $clientId) {
|
||||
$criteria['client'] = $clientId;
|
||||
}
|
||||
if (null !== $prospectId) {
|
||||
$criteria['prospect'] = $prospectId;
|
||||
}
|
||||
if (null !== $prestataireId) {
|
||||
$criteria['prestataire'] = $prestataireId;
|
||||
}
|
||||
|
||||
$contacts = $this->contactRepository->findBy($criteria, ['lastName' => 'ASC']);
|
||||
|
||||
return json_encode(array_map(fn ($c) => Serializer::contact($c), $contacts));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\PrestataireRepositoryInterface;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
#[McpTool(name: 'list-prestataires', description: 'List all prestataires with their IDs, names, and emails. Use this to discover valid prestataire IDs.')]
|
||||
class ListPrestatairesTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PrestataireRepositoryInterface $prestataireRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(): string
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$prestataires = $this->prestataireRepository->findBy([], ['name' => 'ASC']);
|
||||
|
||||
return json_encode(array_map(fn ($p) => [
|
||||
'id' => $p->getId(),
|
||||
'name' => $p->getName(),
|
||||
'email' => $p->getEmail(),
|
||||
], $prestataires));
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class ListProspectsTool
|
||||
$criteria['status'] = $statusEnum;
|
||||
}
|
||||
|
||||
$prospects = $this->prospectRepository->findBy($criteria, ['name' => 'ASC']);
|
||||
$prospects = $this->prospectRepository->findBy($criteria, ['company' => 'ASC']);
|
||||
|
||||
return json_encode(array_map(static fn ($prospect) => Serializer::prospect($prospect), $prospects));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\AddressRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(
|
||||
name: 'update-address',
|
||||
description: 'Update an address (admin). Only provided fields change. Parent (client/prospect/prestataire) is immutable.'
|
||||
)]
|
||||
class UpdateAddressTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AddressRepositoryInterface $addressRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
int $id,
|
||||
?string $label = null,
|
||||
?string $street = null,
|
||||
?string $streetComplement = null,
|
||||
?string $postalCode = null,
|
||||
?string $city = null,
|
||||
?string $country = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$address = $this->addressRepository->findById($id);
|
||||
if (null === $address) {
|
||||
throw new InvalidArgumentException(sprintf('Address with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
if (null !== $label) {
|
||||
$address->setLabel($label);
|
||||
}
|
||||
if (null !== $street) {
|
||||
$address->setStreet($street);
|
||||
}
|
||||
if (null !== $streetComplement) {
|
||||
$address->setStreetComplement($streetComplement);
|
||||
}
|
||||
if (null !== $postalCode) {
|
||||
$address->setPostalCode($postalCode);
|
||||
}
|
||||
if (null !== $city) {
|
||||
$address->setCity($city);
|
||||
}
|
||||
if (null !== $country) {
|
||||
if (2 !== strlen($country)) {
|
||||
throw new InvalidArgumentException('country must be a 2-letter ISO 3166 alpha-2 code (e.g., FR, BE).');
|
||||
}
|
||||
$address->setCountry(strtoupper($country));
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(Serializer::address($address));
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ class UpdateClientTool
|
||||
?string $name = null,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
@@ -47,6 +48,9 @@ class UpdateClientTool
|
||||
if (null !== $phone) {
|
||||
$client->setPhone($phone);
|
||||
}
|
||||
if (null !== $website) {
|
||||
$client->setWebsite($website);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Enum\ReportType;
|
||||
use App\Module\Directory\Domain\Repository\CommercialReportRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(
|
||||
name: 'update-commercial-report',
|
||||
description: 'Update a commercial report (admin). Only provided fields change. Parent (client/prospect/prestataire) is immutable.'
|
||||
)]
|
||||
class UpdateCommercialReportTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CommercialReportRepositoryInterface $reportRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
int $id,
|
||||
?string $subject = null,
|
||||
?string $body = null,
|
||||
?string $occurredAt = null,
|
||||
?string $type = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$report = $this->reportRepository->findById($id);
|
||||
if (null === $report) {
|
||||
throw new InvalidArgumentException(sprintf('CommercialReport with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
if (null !== $subject) {
|
||||
$report->setSubject($subject);
|
||||
}
|
||||
if (null !== $body) {
|
||||
$report->setBody($body);
|
||||
}
|
||||
if (null !== $occurredAt) {
|
||||
try {
|
||||
$report->setOccurredAt(new DateTimeImmutable($occurredAt));
|
||||
} catch (Exception $e) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid occurredAt "%s": %s', $occurredAt, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
if (null !== $type) {
|
||||
$typeEnum = ReportType::tryFrom($type);
|
||||
if (null === $typeEnum) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid type "%s". Allowed: note, call, meeting, email.', $type));
|
||||
}
|
||||
$report->setType($typeEnum);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(Serializer::commercialReport($report));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\ContactRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(
|
||||
name: 'update-contact',
|
||||
description: 'Update a contact (admin). Only provided fields change. The parent (client/prospect/prestataire) is immutable — delete then recreate to re-attach.'
|
||||
)]
|
||||
class UpdateContactTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ContactRepositoryInterface $contactRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
int $id,
|
||||
?string $firstName = null,
|
||||
?string $lastName = null,
|
||||
?string $jobTitle = null,
|
||||
?string $email = null,
|
||||
?string $phonePrimary = null,
|
||||
?string $phoneSecondary = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$contact = $this->contactRepository->findById($id);
|
||||
if (null === $contact) {
|
||||
throw new InvalidArgumentException(sprintf('Contact with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
if (null !== $firstName) {
|
||||
$contact->setFirstName($firstName);
|
||||
}
|
||||
if (null !== $lastName) {
|
||||
$contact->setLastName($lastName);
|
||||
}
|
||||
if (null !== $jobTitle) {
|
||||
$contact->setJobTitle($jobTitle);
|
||||
}
|
||||
if (null !== $email) {
|
||||
$contact->setEmail($email);
|
||||
}
|
||||
if (null !== $phonePrimary) {
|
||||
$contact->setPhonePrimary($phonePrimary);
|
||||
}
|
||||
if (null !== $phoneSecondary) {
|
||||
$contact->setPhoneSecondary($phoneSecondary);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(Serializer::contact($contact));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Module\Directory\Infrastructure\Mcp\Tool;
|
||||
|
||||
use App\Module\Directory\Domain\Repository\PrestataireRepositoryInterface;
|
||||
use App\Shared\Infrastructure\Mcp\Serializer;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Mcp\Capability\Attribute\McpTool;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[McpTool(name: 'update-prestataire', description: 'Update a prestataire (admin). Only provided fields change.')]
|
||||
class UpdatePrestataireTool
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PrestataireRepositoryInterface $prestataireRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function __invoke(
|
||||
int $id,
|
||||
?string $name = null,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
): string {
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
|
||||
}
|
||||
|
||||
$prestataire = $this->prestataireRepository->findById($id);
|
||||
if (null === $prestataire) {
|
||||
throw new InvalidArgumentException(sprintf('Prestataire with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
if (null !== $name) {
|
||||
$prestataire->setName($name);
|
||||
}
|
||||
if (null !== $email) {
|
||||
$prestataire->setEmail($email);
|
||||
}
|
||||
if (null !== $phone) {
|
||||
$prestataire->setPhone($phone);
|
||||
}
|
||||
if (null !== $website) {
|
||||
$prestataire->setWebsite($website);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
return json_encode(Serializer::prestataire($prestataire));
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,10 @@ class UpdateProspectTool
|
||||
|
||||
public function __invoke(
|
||||
int $id,
|
||||
?string $name = null,
|
||||
?string $company = null,
|
||||
?string $email = null,
|
||||
?string $phone = null,
|
||||
?string $website = null,
|
||||
?string $status = null,
|
||||
?string $source = null,
|
||||
?string $notes = null,
|
||||
@@ -43,9 +43,6 @@ class UpdateProspectTool
|
||||
throw new InvalidArgumentException(sprintf('Prospect with ID %d not found.', $id));
|
||||
}
|
||||
|
||||
if (null !== $name) {
|
||||
$prospect->setName($name);
|
||||
}
|
||||
if (null !== $company) {
|
||||
$prospect->setCompany($company);
|
||||
}
|
||||
@@ -55,6 +52,9 @@ class UpdateProspectTool
|
||||
if (null !== $phone) {
|
||||
$prospect->setPhone($phone);
|
||||
}
|
||||
if (null !== $website) {
|
||||
$prospect->setWebsite($website);
|
||||
}
|
||||
if (null !== $status) {
|
||||
$statusEnum = ProspectStatus::tryFrom($status);
|
||||
if (null === $statusEnum) {
|
||||
|
||||
@@ -8,8 +8,13 @@ use App\Module\Absence\Domain\Entity\AbsenceBalance;
|
||||
use App\Module\Absence\Domain\Entity\AbsencePolicy;
|
||||
use App\Module\Absence\Domain\Entity\AbsenceRequest;
|
||||
use App\Module\Core\Domain\Entity\User;
|
||||
use App\Module\Directory\Domain\Entity\Address;
|
||||
use App\Module\Directory\Domain\Entity\Client;
|
||||
use App\Module\Directory\Domain\Entity\CommercialReport;
|
||||
use App\Module\Directory\Domain\Entity\Contact;
|
||||
use App\Module\Directory\Domain\Entity\Prestataire;
|
||||
use App\Module\Directory\Domain\Entity\Prospect;
|
||||
use App\Module\Directory\Domain\Entity\ReportDocument;
|
||||
use App\Module\ProjectManagement\Domain\Entity\Project;
|
||||
use App\Module\ProjectManagement\Domain\Entity\TaskDocument;
|
||||
use App\Module\ProjectManagement\Domain\Entity\TaskEffort;
|
||||
@@ -366,10 +371,103 @@ final class Serializer
|
||||
public static function client(Client $c): array
|
||||
{
|
||||
return [
|
||||
'id' => $c->getId(),
|
||||
'name' => $c->getName(),
|
||||
'email' => $c->getEmail(),
|
||||
'phone' => $c->getPhone(),
|
||||
'id' => $c->getId(),
|
||||
'name' => $c->getName(),
|
||||
'email' => $c->getEmail(),
|
||||
'phone' => $c->getPhone(),
|
||||
'website' => $c->getWebsite(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function prestataire(Prestataire $p): array
|
||||
{
|
||||
return [
|
||||
'id' => $p->getId(),
|
||||
'name' => $p->getName(),
|
||||
'email' => $p->getEmail(),
|
||||
'phone' => $p->getPhone(),
|
||||
'website' => $p->getWebsite(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function contact(Contact $c): array
|
||||
{
|
||||
return [
|
||||
'id' => $c->getId(),
|
||||
'firstName' => $c->getFirstName(),
|
||||
'lastName' => $c->getLastName(),
|
||||
'jobTitle' => $c->getJobTitle(),
|
||||
'email' => $c->getEmail(),
|
||||
'phonePrimary' => $c->getPhonePrimary(),
|
||||
'phoneSecondary' => $c->getPhoneSecondary(),
|
||||
'clientId' => $c->getClient()?->getId(),
|
||||
'prospectId' => $c->getProspect()?->getId(),
|
||||
'prestataireId' => $c->getPrestataire()?->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function address(Address $a): array
|
||||
{
|
||||
return [
|
||||
'id' => $a->getId(),
|
||||
'label' => $a->getLabel(),
|
||||
'street' => $a->getStreet(),
|
||||
'streetComplement' => $a->getStreetComplement(),
|
||||
'postalCode' => $a->getPostalCode(),
|
||||
'city' => $a->getCity(),
|
||||
'country' => $a->getCountry(),
|
||||
'clientId' => $a->getClient()?->getId(),
|
||||
'prospectId' => $a->getProspect()?->getId(),
|
||||
'prestataireId' => $a->getPrestataire()?->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function reportDocument(ReportDocument $d): array
|
||||
{
|
||||
return [
|
||||
'id' => $d->getId(),
|
||||
'originalName' => $d->getOriginalName(),
|
||||
'mimeType' => $d->getMimeType(),
|
||||
'size' => $d->getSize(),
|
||||
'createdAt' => $d->getCreatedAt()?->format('c'),
|
||||
'uploadedBy' => self::user($d->getUploadedBy()),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function commercialReport(CommercialReport $r): array
|
||||
{
|
||||
return [
|
||||
'id' => $r->getId(),
|
||||
'subject' => $r->getSubject(),
|
||||
'body' => $r->getBody(),
|
||||
'occurredAt' => $r->getOccurredAt()?->format('Y-m-d'),
|
||||
'type' => $r->getType()->value,
|
||||
'typeLabel' => $r->getType()->label(),
|
||||
'author' => self::user($r->getAuthor()),
|
||||
'clientId' => $r->getClient()?->getId(),
|
||||
'prospectId' => $r->getProspect()?->getId(),
|
||||
'prestataireId' => $r->getPrestataire()?->getId(),
|
||||
'documents' => array_map(
|
||||
fn (ReportDocument $d) => self::reportDocument($d),
|
||||
$r->getDocuments()->toArray()
|
||||
),
|
||||
'createdAt' => $r->getCreatedAt()?->format('c'),
|
||||
'updatedAt' => $r->getUpdatedAt()?->format('c'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -382,10 +480,10 @@ final class Serializer
|
||||
|
||||
return [
|
||||
'id' => $p->getId(),
|
||||
'name' => $p->getName(),
|
||||
'company' => $p->getCompany(),
|
||||
'email' => $p->getEmail(),
|
||||
'phone' => $p->getPhone(),
|
||||
'website' => $p->getWebsite(),
|
||||
'status' => $p->getStatus()->value,
|
||||
'statusLabel' => $p->getStatus()->label(),
|
||||
'source' => $p->getSource(),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user