@atlashub/smartstack-cli 2.9.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/.documentation/business-analyse.html +81 -17
  2. package/dist/mcp-entry.mjs +1302 -223
  3. package/dist/mcp-entry.mjs.map +1 -1
  4. package/package.json +1 -1
  5. package/templates/agents/efcore/db-deploy.md +1 -1
  6. package/templates/agents/efcore/migration.md +26 -10
  7. package/templates/agents/efcore/rebase-snapshot.md +24 -7
  8. package/templates/agents/efcore/squash.md +73 -57
  9. package/templates/agents/gitflow/commit.md +138 -18
  10. package/templates/agents/gitflow/exec.md +1 -1
  11. package/templates/agents/gitflow/finish.md +79 -62
  12. package/templates/agents/gitflow/init-clone.md +186 -0
  13. package/templates/agents/gitflow/init-detect.md +137 -0
  14. package/templates/agents/gitflow/init-validate.md +210 -0
  15. package/templates/agents/gitflow/init.md +231 -74
  16. package/templates/agents/gitflow/merge.md +65 -33
  17. package/templates/agents/gitflow/pr.md +93 -49
  18. package/templates/agents/gitflow/start.md +76 -33
  19. package/templates/agents/gitflow/status.md +41 -71
  20. package/templates/hooks/appsettings-guard.sh +76 -0
  21. package/templates/hooks/ef-migration-check.md +1 -1
  22. package/templates/hooks/hooks.json +9 -0
  23. package/templates/project/test-frontend/msw/handlers.ts +58 -0
  24. package/templates/project/test-frontend/msw/server.ts +25 -0
  25. package/templates/project/test-frontend/setup.ts +16 -0
  26. package/templates/project/test-frontend/test-utils.tsx +59 -0
  27. package/templates/project/test-frontend/vitest.config.ts +31 -0
  28. package/templates/skills/_resources/config-safety.md +61 -0
  29. package/templates/skills/_resources/formatting-guide.md +2 -2
  30. package/templates/skills/application/SKILL.md +12 -3
  31. package/templates/skills/application/steps/step-04-backend.md +21 -0
  32. package/templates/skills/application/steps/step-07-tests.md +259 -120
  33. package/templates/skills/business-analyse/SKILL.md +57 -28
  34. package/templates/skills/business-analyse/_shared.md +70 -39
  35. package/templates/skills/business-analyse/html/ba-interactive.html +2622 -0
  36. package/templates/skills/business-analyse/questionnaire/00-application.md +123 -131
  37. package/templates/skills/business-analyse/questionnaire/01-context.md +173 -24
  38. package/templates/skills/business-analyse/questionnaire/02-stakeholders.md +170 -50
  39. package/templates/skills/business-analyse/questionnaire/03-scope.md +154 -48
  40. package/templates/skills/business-analyse/questionnaire/10-documentation.md +1 -1
  41. package/templates/skills/business-analyse/questionnaire/14-risk-assumptions.md +135 -0
  42. package/templates/skills/business-analyse/questionnaire/15-success-metrics.md +136 -0
  43. package/templates/skills/business-analyse/questionnaire.md +55 -46
  44. package/templates/skills/business-analyse/steps/step-00-init.md +24 -2
  45. package/templates/skills/business-analyse/steps/step-01-cadrage.md +31 -20
  46. package/templates/skills/business-analyse/steps/step-03-specify.md +1 -0
  47. package/templates/skills/business-analyse/steps/step-05-handoff.md +103 -1
  48. package/templates/skills/business-analyse/steps/step-06-extract.md +518 -0
  49. package/templates/skills/check-version/SKILL.md +1 -1
  50. package/templates/skills/efcore/steps/db/step-deploy.md +22 -3
  51. package/templates/skills/efcore/steps/db/step-reset.md +27 -4
  52. package/templates/skills/efcore/steps/db/step-seed.md +46 -2
  53. package/templates/skills/efcore/steps/db/step-status.md +14 -0
  54. package/templates/skills/efcore/steps/migration/step-01-check.md +31 -5
  55. package/templates/skills/efcore/steps/migration/step-02-create.md +20 -4
  56. package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +60 -0
  57. package/templates/skills/efcore/steps/shared/step-00-init.md +47 -8
  58. package/templates/skills/efcore/steps/squash/step-03-create.md +27 -5
  59. package/templates/skills/gitflow/SKILL.md +91 -29
  60. package/templates/skills/gitflow/_shared.md +144 -2
  61. package/templates/skills/gitflow/phases/status.md +11 -1
  62. package/templates/skills/gitflow/steps/step-commit.md +1 -1
  63. package/templates/skills/gitflow/steps/step-init.md +202 -39
  64. package/templates/skills/gitflow/templates/config.json +10 -1
  65. package/templates/skills/ralph-loop/steps/step-03-commit.md +2 -2
  66. package/templates/skills/validate-feature/SKILL.md +83 -0
  67. package/templates/skills/validate-feature/steps/step-01-compile.md +38 -0
  68. package/templates/skills/validate-feature/steps/step-02-unit-tests.md +45 -0
  69. package/templates/skills/validate-feature/steps/step-03-integration-tests.md +53 -0
  70. package/templates/skills/validate-feature/steps/step-04-api-smoke.md +157 -0
@@ -0,0 +1,2622 @@
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>{{APPLICATION_NAME}} - Analyse metier</title>
7
+ <style>
8
+ /* ============================================
9
+ DESIGN SYSTEM - SmartStack Business Analysis
10
+ ============================================ */
11
+ :root {
12
+ --primary: #6366f1;
13
+ --primary-dark: #4f46e5;
14
+ --primary-light: #818cf8;
15
+ --secondary: #f97316;
16
+ --accent: #06b6d4;
17
+ --bg-dark: #0f172a;
18
+ --bg-card: #1e293b;
19
+ --bg-hover: #334155;
20
+ --bg-input: #151d2e;
21
+ --text: #b8c4d1;
22
+ --text-muted: #8a9bb0;
23
+ --text-bright: #e2e8f0;
24
+ --border: #334155;
25
+ --border-light: #475569;
26
+ --success: #22c55e;
27
+ --warning: #eab308;
28
+ --error: #ef4444;
29
+ --info: #3b82f6;
30
+ --sidebar-width: 280px;
31
+ --header-height: 52px;
32
+ --transition-fast: 0.15s ease;
33
+ --transition-normal: 0.3s ease;
34
+ }
35
+
36
+ * { margin: 0; padding: 0; box-sizing: border-box; }
37
+ html { scroll-behavior: smooth; }
38
+
39
+ body {
40
+ font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
41
+ background: var(--bg-dark);
42
+ color: var(--text);
43
+ line-height: 1.7;
44
+ min-height: 100vh;
45
+ }
46
+
47
+ /* ============================================
48
+ LAYOUT
49
+ ============================================ */
50
+ .app { display: flex; flex-direction: column; min-height: 100vh; }
51
+
52
+ .header {
53
+ background: var(--bg-card);
54
+ border-bottom: 1px solid var(--border);
55
+ height: var(--header-height);
56
+ display: flex;
57
+ align-items: center;
58
+ padding: 0 1.5rem;
59
+ gap: 1rem;
60
+ position: sticky;
61
+ top: 0;
62
+ z-index: 100;
63
+ }
64
+
65
+ .header-logo {
66
+ width: 32px; height: 32px;
67
+ background: linear-gradient(135deg, var(--primary), var(--secondary));
68
+ border-radius: 6px;
69
+ display: flex; align-items: center; justify-content: center;
70
+ font-weight: 700; font-size: 0.85rem; color: #fff;
71
+ flex-shrink: 0;
72
+ }
73
+
74
+ .header-title { font-size: 1rem; font-weight: 600; color: var(--text-bright); }
75
+ .header-sep { width: 1px; height: 24px; background: var(--border); }
76
+ .header-app-name { font-size: 0.9rem; color: var(--primary-light); font-weight: 500; }
77
+ .header-spacer { flex: 1; }
78
+
79
+ .header-actions { display: flex; gap: 0.5rem; }
80
+
81
+ .btn {
82
+ padding: 0.4rem 0.9rem;
83
+ border-radius: 6px;
84
+ border: 1px solid var(--border);
85
+ background: var(--bg-hover);
86
+ color: var(--text);
87
+ font-size: 0.8rem;
88
+ cursor: pointer;
89
+ transition: all var(--transition-fast);
90
+ font-family: inherit;
91
+ }
92
+ .btn:hover { border-color: var(--primary); color: var(--text-bright); }
93
+ .btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
94
+ .btn-primary:hover { background: var(--primary-dark); }
95
+ .btn-success { background: var(--success); border-color: var(--success); color: #fff; }
96
+ .btn-sm { padding: 0.25rem 0.6rem; font-size: 0.75rem; }
97
+
98
+ .body { display: flex; flex: 1; }
99
+
100
+ /* ============================================
101
+ SIDEBAR - Navigation 5 niveaux
102
+ ============================================ */
103
+ .sidebar {
104
+ width: var(--sidebar-width);
105
+ background: var(--bg-card);
106
+ border-right: 1px solid var(--border);
107
+ overflow-y: auto;
108
+ height: calc(100vh - var(--header-height));
109
+ position: sticky;
110
+ top: var(--header-height);
111
+ flex-shrink: 0;
112
+ }
113
+
114
+ .sidebar::-webkit-scrollbar { width: 4px; }
115
+ .sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
116
+
117
+ .nav-group { padding: 1rem 0; }
118
+ .nav-group + .nav-group { border-top: 1px solid var(--border); }
119
+
120
+ .nav-group-title {
121
+ font-size: 0.65rem;
122
+ text-transform: uppercase;
123
+ letter-spacing: 0.1em;
124
+ color: var(--text-muted);
125
+ padding: 0 1rem;
126
+ margin-bottom: 0.5rem;
127
+ font-weight: 600;
128
+ }
129
+
130
+ .nav-item {
131
+ display: flex;
132
+ align-items: center;
133
+ gap: 0.5rem;
134
+ padding: 0.45rem 1rem;
135
+ color: var(--text);
136
+ text-decoration: none;
137
+ font-size: 0.85rem;
138
+ cursor: pointer;
139
+ transition: all var(--transition-fast);
140
+ border-left: 3px solid transparent;
141
+ }
142
+ .nav-item:hover { background: var(--bg-hover); color: var(--text-bright); }
143
+ .nav-item.active { background: rgba(99,102,241,0.1); border-left-color: var(--primary); color: var(--primary-light); font-weight: 500; }
144
+
145
+ .nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }
146
+ .nav-item .nav-badge {
147
+ margin-left: auto;
148
+ font-size: 0.65rem;
149
+ background: var(--bg-hover);
150
+ padding: 0.1rem 0.4rem;
151
+ border-radius: 10px;
152
+ color: var(--text-muted);
153
+ }
154
+
155
+ .nav-children { margin-left: 1.2rem; }
156
+ .nav-children .nav-item { font-size: 0.8rem; padding: 0.3rem 1rem; }
157
+
158
+ /* ============================================
159
+ MAIN CONTENT
160
+ ============================================ */
161
+ .main {
162
+ flex: 1;
163
+ padding: 2rem 2.5rem;
164
+ max-width: 960px;
165
+ overflow-y: auto;
166
+ height: calc(100vh - var(--header-height));
167
+ }
168
+
169
+ .section { margin-bottom: 3rem; }
170
+ .section-title {
171
+ font-size: 1.4rem;
172
+ color: var(--text-bright);
173
+ font-weight: 600;
174
+ margin-bottom: 0.5rem;
175
+ padding-bottom: 0.5rem;
176
+ border-bottom: 2px solid var(--primary);
177
+ }
178
+ .section-subtitle {
179
+ font-size: 0.9rem;
180
+ color: var(--text-muted);
181
+ margin-bottom: 1.5rem;
182
+ }
183
+
184
+ /* ============================================
185
+ EDITABLE CARDS
186
+ ============================================ */
187
+ .card {
188
+ background: var(--bg-card);
189
+ border: 1px solid var(--border);
190
+ border-radius: 10px;
191
+ padding: 1.25rem;
192
+ margin-bottom: 1rem;
193
+ transition: border-color var(--transition-fast);
194
+ }
195
+ .card:hover { border-color: var(--border-light); }
196
+
197
+ .card-header {
198
+ display: flex;
199
+ align-items: center;
200
+ gap: 0.75rem;
201
+ margin-bottom: 0.75rem;
202
+ }
203
+ .card-label {
204
+ font-size: 0.7rem;
205
+ text-transform: uppercase;
206
+ letter-spacing: 0.08em;
207
+ color: var(--text-muted);
208
+ font-weight: 600;
209
+ }
210
+ .card-title {
211
+ font-size: 1.05rem;
212
+ color: var(--text-bright);
213
+ font-weight: 600;
214
+ }
215
+
216
+ .editable {
217
+ border: 1px dashed transparent;
218
+ border-radius: 6px;
219
+ padding: 0.4rem 0.6rem;
220
+ transition: all var(--transition-fast);
221
+ min-height: 1.5em;
222
+ outline: none;
223
+ }
224
+ .editable:hover { border-color: var(--border-light); background: var(--bg-input); }
225
+ .editable:focus { border-color: var(--primary); background: var(--bg-input); box-shadow: 0 0 0 2px rgba(99,102,241,0.2); }
226
+ .editable[data-placeholder]:empty::before {
227
+ content: attr(data-placeholder);
228
+ color: var(--text-muted);
229
+ font-style: italic;
230
+ }
231
+
232
+ /* ============================================
233
+ PRIORITY BADGES
234
+ ============================================ */
235
+ .priority {
236
+ display: inline-flex;
237
+ align-items: center;
238
+ gap: 0.3rem;
239
+ padding: 0.2rem 0.6rem;
240
+ border-radius: 12px;
241
+ font-size: 0.7rem;
242
+ font-weight: 600;
243
+ text-transform: uppercase;
244
+ letter-spacing: 0.05em;
245
+ }
246
+ .priority-vital { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
247
+ .priority-important { background: rgba(234,179,8,0.15); color: #facc15; border: 1px solid rgba(234,179,8,0.3); }
248
+ .priority-optional { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
249
+ .priority-excluded { background: rgba(100,116,139,0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }
250
+
251
+ /* ============================================
252
+ STATUS BADGES
253
+ ============================================ */
254
+ .status {
255
+ display: inline-flex; align-items: center; gap: 0.3rem;
256
+ padding: 0.15rem 0.5rem; border-radius: 10px;
257
+ font-size: 0.7rem; font-weight: 500;
258
+ }
259
+ .status-dot { width: 6px; height: 6px; border-radius: 50%; }
260
+ .status-draft .status-dot { background: var(--text-muted); }
261
+ .status-draft { color: var(--text-muted); }
262
+ .status-progress .status-dot { background: var(--info); }
263
+ .status-progress { color: var(--info); }
264
+ .status-done .status-dot { background: var(--success); }
265
+ .status-done { color: var(--success); }
266
+
267
+ /* ============================================
268
+ USE CASE LIST
269
+ ============================================ */
270
+ .uc-list { list-style: none; }
271
+
272
+ .uc-item {
273
+ background: var(--bg-card);
274
+ border: 1px solid var(--border);
275
+ border-radius: 8px;
276
+ padding: 1rem 1.25rem;
277
+ margin-bottom: 0.75rem;
278
+ transition: border-color var(--transition-fast);
279
+ }
280
+ .uc-item:hover { border-color: var(--border-light); }
281
+
282
+ .uc-header {
283
+ display: flex;
284
+ align-items: center;
285
+ gap: 0.75rem;
286
+ margin-bottom: 0.5rem;
287
+ }
288
+ .uc-id {
289
+ font-size: 0.7rem;
290
+ font-weight: 700;
291
+ color: var(--primary-light);
292
+ background: rgba(99,102,241,0.1);
293
+ padding: 0.15rem 0.5rem;
294
+ border-radius: 4px;
295
+ }
296
+ .uc-title { font-weight: 600; color: var(--text-bright); flex: 1; }
297
+ .uc-actions { display: flex; gap: 0.3rem; opacity: 0; transition: opacity var(--transition-fast); }
298
+ .uc-item:hover .uc-actions { opacity: 1; }
299
+
300
+ .uc-detail { font-size: 0.875rem; color: var(--text); }
301
+ .uc-detail-label { color: var(--text-muted); font-size: 0.75rem; font-weight: 600; margin-top: 0.5rem; }
302
+
303
+ .uc-actors {
304
+ display: flex; gap: 0.4rem; margin-top: 0.3rem; flex-wrap: wrap;
305
+ }
306
+ .uc-actor {
307
+ font-size: 0.7rem;
308
+ padding: 0.1rem 0.4rem;
309
+ background: rgba(6,182,212,0.1);
310
+ color: var(--accent);
311
+ border-radius: 4px;
312
+ border: 1px solid rgba(6,182,212,0.2);
313
+ }
314
+
315
+ /* ============================================
316
+ BUSINESS RULE LIST
317
+ ============================================ */
318
+ .br-item {
319
+ display: flex;
320
+ align-items: flex-start;
321
+ gap: 0.75rem;
322
+ padding: 0.75rem 1rem;
323
+ background: var(--bg-card);
324
+ border: 1px solid var(--border);
325
+ border-radius: 8px;
326
+ margin-bottom: 0.5rem;
327
+ }
328
+ .br-category {
329
+ font-size: 0.65rem;
330
+ font-weight: 700;
331
+ text-transform: uppercase;
332
+ padding: 0.15rem 0.4rem;
333
+ border-radius: 4px;
334
+ flex-shrink: 0;
335
+ min-width: 70px;
336
+ text-align: center;
337
+ }
338
+ .br-cat-validation { background: rgba(99,102,241,0.15); color: var(--primary-light); }
339
+ .br-cat-calculation { background: rgba(234,179,8,0.15); color: #facc15; }
340
+ .br-cat-workflow { background: rgba(249,115,22,0.15); color: var(--secondary); }
341
+ .br-cat-security { background: rgba(239,68,68,0.15); color: #f87171; }
342
+ .br-cat-data { background: rgba(6,182,212,0.15); color: var(--accent); }
343
+ .br-text { flex: 1; font-size: 0.875rem; }
344
+
345
+ /* ============================================
346
+ MOCKUP FRAME
347
+ ============================================ */
348
+ .mockup-frame {
349
+ background: var(--bg-card);
350
+ border: 1px solid var(--border);
351
+ border-radius: 12px;
352
+ overflow: hidden;
353
+ margin: 1rem 0;
354
+ }
355
+ .mockup-toolbar {
356
+ background: var(--bg-hover);
357
+ padding: 0.5rem 1rem;
358
+ display: flex;
359
+ align-items: center;
360
+ gap: 0.5rem;
361
+ border-bottom: 1px solid var(--border);
362
+ }
363
+ .mockup-dot { width: 8px; height: 8px; border-radius: 50%; }
364
+ .mockup-dot-red { background: #ef4444; }
365
+ .mockup-dot-yellow { background: #eab308; }
366
+ .mockup-dot-green { background: #22c55e; }
367
+ .mockup-title {
368
+ font-size: 0.75rem; color: var(--text-muted);
369
+ margin-left: 0.5rem;
370
+ }
371
+
372
+ .mockup-content {
373
+ padding: 1.5rem;
374
+ min-height: 200px;
375
+ }
376
+
377
+ /* Mockup components */
378
+ .mock-header {
379
+ display: flex;
380
+ align-items: center;
381
+ justify-content: space-between;
382
+ margin-bottom: 1rem;
383
+ padding-bottom: 0.75rem;
384
+ border-bottom: 1px solid var(--border);
385
+ }
386
+ .mock-title { font-size: 1.1rem; font-weight: 600; color: var(--text-bright); }
387
+ .mock-btn {
388
+ padding: 0.35rem 0.8rem;
389
+ background: var(--primary);
390
+ color: #fff;
391
+ border-radius: 6px;
392
+ font-size: 0.8rem;
393
+ font-weight: 500;
394
+ }
395
+ .mock-search {
396
+ display: flex; align-items: center; gap: 0.5rem;
397
+ padding: 0.4rem 0.8rem;
398
+ background: var(--bg-input);
399
+ border: 1px solid var(--border);
400
+ border-radius: 6px;
401
+ margin-bottom: 1rem;
402
+ color: var(--text-muted);
403
+ font-size: 0.8rem;
404
+ }
405
+ .mock-table {
406
+ width: 100%;
407
+ border-collapse: collapse;
408
+ }
409
+ .mock-table th {
410
+ text-align: left;
411
+ font-size: 0.7rem;
412
+ text-transform: uppercase;
413
+ letter-spacing: 0.05em;
414
+ color: var(--text-muted);
415
+ padding: 0.5rem 0.75rem;
416
+ border-bottom: 1px solid var(--border);
417
+ font-weight: 600;
418
+ }
419
+ .mock-table td {
420
+ padding: 0.6rem 0.75rem;
421
+ font-size: 0.85rem;
422
+ border-bottom: 1px solid rgba(51,65,85,0.5);
423
+ }
424
+ .mock-table tr:hover td { background: rgba(99,102,241,0.05); }
425
+
426
+ .mock-status {
427
+ display: inline-flex; align-items: center; gap: 0.3rem;
428
+ padding: 0.15rem 0.5rem; border-radius: 10px; font-size: 0.75rem;
429
+ }
430
+ .mock-status-active { background: rgba(34,197,94,0.15); color: #4ade80; }
431
+ .mock-status-pending { background: rgba(234,179,8,0.15); color: #facc15; }
432
+ .mock-status-draft { background: rgba(100,116,139,0.15); color: #94a3b8; }
433
+
434
+ .mock-form-group { margin-bottom: 1rem; }
435
+ .mock-label {
436
+ display: block;
437
+ font-size: 0.75rem;
438
+ color: var(--text-muted);
439
+ margin-bottom: 0.3rem;
440
+ font-weight: 500;
441
+ }
442
+ .mock-input {
443
+ width: 100%;
444
+ padding: 0.5rem 0.75rem;
445
+ background: var(--bg-input);
446
+ border: 1px solid var(--border);
447
+ border-radius: 6px;
448
+ color: var(--text);
449
+ font-size: 0.85rem;
450
+ }
451
+ .mock-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
452
+ .mock-form-actions {
453
+ display: flex; gap: 0.5rem; justify-content: flex-end;
454
+ padding-top: 1rem; border-top: 1px solid var(--border);
455
+ }
456
+
457
+ /* Dashboard mockup */
458
+ .mock-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
459
+ .mock-kpi {
460
+ background: var(--bg-hover);
461
+ border-radius: 8px;
462
+ padding: 0.75rem;
463
+ text-align: center;
464
+ }
465
+ .mock-kpi-value { font-size: 1.3rem; font-weight: 700; color: var(--text-bright); }
466
+ .mock-kpi-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.2rem; }
467
+ .mock-chart-placeholder {
468
+ height: 150px;
469
+ background: linear-gradient(135deg, rgba(99,102,241,0.05), rgba(6,182,212,0.05));
470
+ border: 1px dashed var(--border);
471
+ border-radius: 8px;
472
+ display: flex; align-items: center; justify-content: center;
473
+ color: var(--text-muted); font-size: 0.85rem;
474
+ }
475
+
476
+ /* ============================================
477
+ ADD BUTTON
478
+ ============================================ */
479
+ .add-btn {
480
+ display: flex;
481
+ align-items: center;
482
+ justify-content: center;
483
+ gap: 0.5rem;
484
+ width: 100%;
485
+ padding: 0.75rem;
486
+ border: 2px dashed var(--border);
487
+ border-radius: 8px;
488
+ background: transparent;
489
+ color: var(--text-muted);
490
+ font-size: 0.85rem;
491
+ cursor: pointer;
492
+ transition: all var(--transition-fast);
493
+ font-family: inherit;
494
+ }
495
+ .add-btn:hover {
496
+ border-color: var(--primary);
497
+ color: var(--primary-light);
498
+ background: rgba(99,102,241,0.05);
499
+ }
500
+
501
+ /* ============================================
502
+ INLINE FORM (for adding items)
503
+ ============================================ */
504
+ .inline-form {
505
+ background: var(--bg-card);
506
+ border: 2px solid var(--primary);
507
+ border-radius: 10px;
508
+ padding: 1.25rem;
509
+ margin-bottom: 1rem;
510
+ display: none;
511
+ }
512
+ .inline-form.visible { display: block; }
513
+ .inline-form-title {
514
+ font-size: 0.9rem;
515
+ font-weight: 600;
516
+ color: var(--primary-light);
517
+ margin-bottom: 1rem;
518
+ }
519
+ .form-group { margin-bottom: 0.75rem; }
520
+ .form-label {
521
+ display: block;
522
+ font-size: 0.75rem;
523
+ color: var(--text-muted);
524
+ margin-bottom: 0.3rem;
525
+ font-weight: 500;
526
+ }
527
+ .form-input, .form-textarea, .form-select {
528
+ width: 100%;
529
+ padding: 0.5rem 0.75rem;
530
+ background: var(--bg-input);
531
+ border: 1px solid var(--border);
532
+ border-radius: 6px;
533
+ color: var(--text);
534
+ font-size: 0.85rem;
535
+ font-family: inherit;
536
+ transition: border-color var(--transition-fast);
537
+ }
538
+ .form-input:focus, .form-textarea:focus, .form-select:focus {
539
+ outline: none;
540
+ border-color: var(--primary);
541
+ box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
542
+ }
543
+ .form-textarea { min-height: 80px; resize: vertical; }
544
+ .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
545
+ .form-actions {
546
+ display: flex; gap: 0.5rem; justify-content: flex-end;
547
+ margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border);
548
+ }
549
+
550
+ /* ============================================
551
+ STAKEHOLDER TABLE
552
+ ============================================ */
553
+ .stakeholder-grid {
554
+ display: grid;
555
+ grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
556
+ gap: 1rem;
557
+ }
558
+ .stakeholder-card {
559
+ background: var(--bg-card);
560
+ border: 1px solid var(--border);
561
+ border-radius: 10px;
562
+ padding: 1rem;
563
+ }
564
+ .stakeholder-card:hover { border-color: var(--border-light); }
565
+ .stakeholder-role { font-weight: 600; color: var(--text-bright); margin-bottom: 0.25rem; }
566
+ .stakeholder-function { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
567
+ .stakeholder-tasks { list-style: none; }
568
+ .stakeholder-tasks li {
569
+ font-size: 0.8rem;
570
+ padding: 0.15rem 0;
571
+ color: var(--text);
572
+ }
573
+ .stakeholder-tasks li::before { content: "- "; color: var(--primary-light); }
574
+ .stakeholder-meta {
575
+ display: flex; gap: 0.75rem; margin-top: 0.5rem; padding-top: 0.5rem;
576
+ border-top: 1px solid var(--border);
577
+ }
578
+ .stakeholder-meta span { font-size: 0.7rem; color: var(--text-muted); }
579
+
580
+ /* ============================================
581
+ PROCESS FLOW
582
+ ============================================ */
583
+ .process-flow {
584
+ display: flex;
585
+ align-items: center;
586
+ gap: 0.25rem;
587
+ overflow-x: auto;
588
+ padding: 1rem 0;
589
+ }
590
+ .process-step {
591
+ background: var(--bg-card);
592
+ border: 1px solid var(--border);
593
+ border-radius: 8px;
594
+ padding: 0.75rem 1rem;
595
+ min-width: 140px;
596
+ text-align: center;
597
+ flex-shrink: 0;
598
+ }
599
+ .process-step:hover { border-color: var(--primary); }
600
+ .process-step-number {
601
+ font-size: 0.65rem;
602
+ color: var(--primary-light);
603
+ font-weight: 700;
604
+ }
605
+ .process-step-label { font-size: 0.8rem; color: var(--text-bright); font-weight: 500; }
606
+ .process-arrow { color: var(--text-muted); font-size: 1.2rem; flex-shrink: 0; }
607
+
608
+ /* ============================================
609
+ RISK TABLE
610
+ ============================================ */
611
+ .risk-item {
612
+ display: grid;
613
+ grid-template-columns: auto 1fr auto auto;
614
+ gap: 1rem;
615
+ align-items: center;
616
+ padding: 0.75rem 1rem;
617
+ background: var(--bg-card);
618
+ border: 1px solid var(--border);
619
+ border-radius: 8px;
620
+ margin-bottom: 0.5rem;
621
+ }
622
+ .risk-level {
623
+ width: 10px; height: 10px;
624
+ border-radius: 50%;
625
+ }
626
+ .risk-critical { background: var(--error); }
627
+ .risk-medium { background: var(--warning); }
628
+ .risk-low { background: var(--success); }
629
+ .risk-text { font-size: 0.875rem; }
630
+ .risk-probability, .risk-impact {
631
+ font-size: 0.7rem;
632
+ color: var(--text-muted);
633
+ text-align: center;
634
+ }
635
+
636
+ /* ============================================
637
+ NOTIFICATION BAR
638
+ ============================================ */
639
+ .notification {
640
+ position: fixed;
641
+ bottom: 1.5rem;
642
+ right: 1.5rem;
643
+ padding: 0.75rem 1.25rem;
644
+ border-radius: 8px;
645
+ font-size: 0.85rem;
646
+ font-weight: 500;
647
+ z-index: 200;
648
+ transform: translateY(100px);
649
+ opacity: 0;
650
+ transition: all 0.3s ease;
651
+ }
652
+ .notification.visible { transform: translateY(0); opacity: 1; }
653
+ .notification-success { background: var(--success); color: #fff; }
654
+ .notification-info { background: var(--info); color: #fff; }
655
+
656
+ /* ============================================
657
+ MODULE CARDS (Decomposition)
658
+ ============================================ */
659
+ .module-grid {
660
+ display: grid;
661
+ grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
662
+ gap: 1rem;
663
+ }
664
+ .module-card {
665
+ background: var(--bg-card);
666
+ border: 1px solid var(--border);
667
+ border-radius: 10px;
668
+ padding: 1rem;
669
+ cursor: pointer;
670
+ transition: all var(--transition-fast);
671
+ position: relative;
672
+ }
673
+ .module-card:hover { border-color: var(--primary); }
674
+ .module-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(99,102,241,0.2); }
675
+ .module-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 0.5rem; }
676
+ .module-card-code { font-weight: 700; color: var(--text-bright); font-size: 1rem; }
677
+ .module-card-type {
678
+ font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em;
679
+ padding: 0.15rem 0.5rem; border-radius: 4px;
680
+ background: rgba(99,102,241,0.1); color: var(--primary-light);
681
+ }
682
+ .module-card-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
683
+ .module-card-meta { display: flex; gap: 0.75rem; font-size: 0.7rem; color: var(--text-muted); }
684
+ .module-card-meta span { display: flex; align-items: center; gap: 0.2rem; }
685
+ .module-card-remove {
686
+ position: absolute; top: 0.5rem; right: 0.5rem;
687
+ background: none; border: none; color: var(--text-muted);
688
+ cursor: pointer; font-size: 0.8rem; opacity: 0;
689
+ transition: opacity var(--transition-fast);
690
+ }
691
+ .module-card:hover .module-card-remove { opacity: 1; }
692
+ .module-card-remove:hover { color: var(--error); }
693
+
694
+ /* ============================================
695
+ TABS (Module Specification)
696
+ ============================================ */
697
+ .tab-bar {
698
+ display: flex;
699
+ gap: 0;
700
+ border-bottom: 1px solid var(--border);
701
+ margin-bottom: 1.5rem;
702
+ overflow-x: auto;
703
+ }
704
+ .tab-btn {
705
+ padding: 0.6rem 1rem;
706
+ background: none;
707
+ border: none;
708
+ border-bottom: 2px solid transparent;
709
+ color: var(--text-muted);
710
+ font-size: 0.8rem;
711
+ font-family: inherit;
712
+ cursor: pointer;
713
+ white-space: nowrap;
714
+ transition: all var(--transition-fast);
715
+ }
716
+ .tab-btn:hover { color: var(--text-bright); background: var(--bg-hover); }
717
+ .tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary); font-weight: 500; }
718
+ .tab-panel { display: none; }
719
+ .tab-panel.active { display: block; }
720
+
721
+ /* ============================================
722
+ ENTITY TABLE
723
+ ============================================ */
724
+ .entity-block {
725
+ background: var(--bg-card);
726
+ border: 1px solid var(--border);
727
+ border-radius: 10px;
728
+ margin-bottom: 1rem;
729
+ overflow: hidden;
730
+ }
731
+ .entity-header {
732
+ display: flex; align-items: center; justify-content: space-between;
733
+ padding: 0.75rem 1rem;
734
+ background: var(--bg-hover);
735
+ border-bottom: 1px solid var(--border);
736
+ }
737
+ .entity-name { font-weight: 600; color: var(--text-bright); }
738
+ .entity-desc { font-size: 0.8rem; color: var(--text-muted); }
739
+ .attr-table { width: 100%; border-collapse: collapse; }
740
+ .attr-table th {
741
+ text-align: left; font-size: 0.7rem; text-transform: uppercase;
742
+ letter-spacing: 0.05em; color: var(--text-muted); padding: 0.5rem 0.75rem;
743
+ border-bottom: 1px solid var(--border); font-weight: 600;
744
+ }
745
+ .attr-table td {
746
+ padding: 0.5rem 0.75rem; font-size: 0.85rem;
747
+ border-bottom: 1px solid rgba(51,65,85,0.3);
748
+ }
749
+ .attr-required { color: var(--error); font-weight: 700; }
750
+
751
+ /* ============================================
752
+ DEPENDENCY VISUALIZATION
753
+ ============================================ */
754
+ .dep-graph {
755
+ display: flex; flex-direction: column; gap: 1.5rem;
756
+ padding: 1.5rem; background: var(--bg-card); border: 1px solid var(--border);
757
+ border-radius: 10px;
758
+ }
759
+ .dep-layer {
760
+ display: flex; align-items: center; gap: 1rem;
761
+ }
762
+ .dep-layer-label {
763
+ font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase;
764
+ letter-spacing: 0.05em; min-width: 80px; font-weight: 600;
765
+ }
766
+ .dep-layer-modules { display: flex; gap: 0.75rem; flex-wrap: wrap; }
767
+ .dep-module {
768
+ padding: 0.4rem 0.8rem; border-radius: 6px;
769
+ background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.3);
770
+ color: var(--primary-light); font-size: 0.8rem; font-weight: 500;
771
+ }
772
+ .dep-arrow {
773
+ text-align: center; color: var(--text-muted); font-size: 1.2rem;
774
+ padding-left: 80px;
775
+ }
776
+
777
+ /* ============================================
778
+ PHASE PROGRESS
779
+ ============================================ */
780
+ .phase-progress {
781
+ display: flex; align-items: center; gap: 0.3rem;
782
+ padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
783
+ }
784
+ .phase-dot {
785
+ width: 24px; height: 24px; border-radius: 50%;
786
+ display: flex; align-items: center; justify-content: center;
787
+ font-size: 0.6rem; font-weight: 700; color: var(--text-muted);
788
+ background: var(--bg-hover); border: 2px solid var(--border);
789
+ transition: all var(--transition-fast);
790
+ }
791
+ .phase-dot.completed { background: var(--success); border-color: var(--success); color: #fff; }
792
+ .phase-dot.current { background: var(--primary); border-color: var(--primary); color: #fff; }
793
+ .phase-line { flex: 1; height: 2px; background: var(--border); }
794
+ .phase-line.completed { background: var(--success); }
795
+
796
+ /* ============================================
797
+ STAT CARDS (Handoff)
798
+ ============================================ */
799
+ .stat-grid {
800
+ display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
801
+ gap: 1rem; margin-bottom: 1.5rem;
802
+ }
803
+ .stat-card {
804
+ background: var(--bg-card); border: 1px solid var(--border);
805
+ border-radius: 10px; padding: 1rem; text-align: center;
806
+ }
807
+ .stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text-bright); }
808
+ .stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
809
+
810
+ /* ============================================
811
+ CONSOLIDATION
812
+ ============================================ */
813
+ .interaction-item {
814
+ display: flex; align-items: center; gap: 0.75rem;
815
+ padding: 0.75rem 1rem; background: var(--bg-card);
816
+ border: 1px solid var(--border); border-radius: 8px;
817
+ margin-bottom: 0.5rem; font-size: 0.85rem;
818
+ }
819
+ .interaction-arrow { color: var(--primary-light); font-weight: 700; font-size: 1.1rem; }
820
+ .interaction-type {
821
+ font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em;
822
+ padding: 0.15rem 0.4rem; border-radius: 4px;
823
+ background: rgba(6,182,212,0.1); color: var(--accent);
824
+ }
825
+ .e2e-flow {
826
+ display: flex; align-items: center; gap: 0.3rem;
827
+ overflow-x: auto; padding: 1rem 0;
828
+ }
829
+ .e2e-step {
830
+ padding: 0.5rem 0.75rem; border-radius: 6px; text-align: center;
831
+ font-size: 0.75rem; flex-shrink: 0;
832
+ background: var(--bg-card); border: 1px solid var(--border);
833
+ }
834
+ .e2e-step-module { font-weight: 600; color: var(--primary-light); font-size: 0.65rem; }
835
+ .e2e-step-action { color: var(--text-bright); }
836
+
837
+ /* ============================================
838
+ RESPONSIVE
839
+ ============================================ */
840
+ @media (max-width: 768px) {
841
+ .sidebar { display: none; }
842
+ .main { padding: 1rem; }
843
+ .mock-kpi-grid { grid-template-columns: repeat(2, 1fr); }
844
+ .form-row { grid-template-columns: 1fr; }
845
+ .stakeholder-grid { grid-template-columns: 1fr; }
846
+ }
847
+
848
+ /* ============================================
849
+ PRINT
850
+ ============================================ */
851
+ @media print {
852
+ .sidebar, .header-actions, .add-btn, .uc-actions, .inline-form, .module-card-remove, .phase-progress { display: none !important; }
853
+ .main { max-width: 100%; padding: 0; }
854
+ .section { display: block !important; page-break-inside: avoid; }
855
+ body { background: #fff; color: #1a1a1a; }
856
+ .card, .uc-item, .br-item, .module-card, .entity-block, .interaction-item { border-color: #ddd; }
857
+ .tab-panel { display: block !important; }
858
+ .tab-bar { display: none; }
859
+ }
860
+ </style>
861
+ </head>
862
+ <body>
863
+ <div class="app">
864
+ <!-- ============================================
865
+ HEADER
866
+ ============================================ -->
867
+ <header class="header">
868
+ <div class="header-logo">BA</div>
869
+ <span class="header-title">Analyse metier</span>
870
+ <div class="header-sep"></div>
871
+ <span class="header-app-name" id="appName">{{APPLICATION_NAME}}</span>
872
+ <div class="header-spacer"></div>
873
+ <div class="header-actions">
874
+ <button class="btn btn-sm" onclick="saveToLocalStorage()" title="Sauvegarder les modifications dans le navigateur">Sauvegarder</button>
875
+ <button class="btn btn-sm btn-primary" onclick="exportJSON()" title="Exporter les donnees au format JSON pour l'extraction">Exporter JSON</button>
876
+ </div>
877
+ </header>
878
+
879
+ <div class="body">
880
+ <!-- ============================================
881
+ SIDEBAR - Navigation 5 niveaux
882
+ ============================================ -->
883
+ <aside class="sidebar">
884
+ <!-- Phase Progress -->
885
+ <div class="phase-progress">
886
+ <div class="phase-dot current" id="phase-1" title="Cadrage">1</div>
887
+ <div class="phase-line" id="pline-1"></div>
888
+ <div class="phase-dot" id="phase-2" title="Decomposition">2</div>
889
+ <div class="phase-line" id="pline-2"></div>
890
+ <div class="phase-dot" id="phase-3" title="Specification">3</div>
891
+ <div class="phase-line" id="pline-3"></div>
892
+ <div class="phase-dot" id="phase-4" title="Consolidation">4</div>
893
+ <div class="phase-line" id="pline-4"></div>
894
+ <div class="phase-dot" id="phase-5" title="Synthese">5</div>
895
+ </div>
896
+
897
+ <!-- Phase 1 : Cadrage -->
898
+ <div class="nav-group">
899
+ <div class="nav-group-title">1. Cadrage</div>
900
+ <a class="nav-item active" onclick="showSection('cadrage-problem')" data-section="cadrage-problem">
901
+ <span class="nav-icon">&#9679;</span> Probleme a resoudre
902
+ </a>
903
+ <a class="nav-item" onclick="showSection('cadrage-current')" data-section="cadrage-current">
904
+ <span class="nav-icon">&#9679;</span> Situation actuelle
905
+ </a>
906
+ <a class="nav-item" onclick="showSection('cadrage-vision')" data-section="cadrage-vision">
907
+ <span class="nav-icon">&#9679;</span> Situation souhaitee
908
+ </a>
909
+ <a class="nav-item" onclick="showSection('cadrage-stakeholders')" data-section="cadrage-stakeholders">
910
+ <span class="nav-icon">&#9679;</span> Parties prenantes
911
+ <span class="nav-badge" id="stakeholderCount">0</span>
912
+ </a>
913
+ <a class="nav-item" onclick="showSection('cadrage-scope')" data-section="cadrage-scope">
914
+ <span class="nav-icon">&#9679;</span> Perimetre fonctionnel
915
+ </a>
916
+ <a class="nav-item" onclick="showSection('cadrage-risks')" data-section="cadrage-risks">
917
+ <span class="nav-icon">&#9679;</span> Risques et hypotheses
918
+ </a>
919
+ <a class="nav-item" onclick="showSection('cadrage-success')" data-section="cadrage-success">
920
+ <span class="nav-icon">&#9679;</span> Criteres de reussite
921
+ </a>
922
+ </div>
923
+
924
+ <!-- Phase 2 : Decomposition -->
925
+ <div class="nav-group">
926
+ <div class="nav-group-title">2. Decomposition</div>
927
+ <a class="nav-item" onclick="showSection('decomp-modules')" data-section="decomp-modules">
928
+ <span class="nav-icon">&#9679;</span> Domaines fonctionnels
929
+ <span class="nav-badge" id="moduleCount">0</span>
930
+ </a>
931
+ <a class="nav-item" onclick="showSection('decomp-dependencies')" data-section="decomp-dependencies">
932
+ <span class="nav-icon">&#9679;</span> Dependances
933
+ </a>
934
+ </div>
935
+
936
+ <!-- Phase 3 : Specification par module -->
937
+ <div class="nav-group" id="modulesNav">
938
+ <div class="nav-group-title">3. Specification</div>
939
+ <!-- Populated dynamically per module -->
940
+ </div>
941
+
942
+ <!-- Phase 4 : Consolidation -->
943
+ <div class="nav-group">
944
+ <div class="nav-group-title">4. Consolidation</div>
945
+ <a class="nav-item" onclick="showSection('consol-interactions')" data-section="consol-interactions">
946
+ <span class="nav-icon">&#9679;</span> Interactions
947
+ </a>
948
+ <a class="nav-item" onclick="showSection('consol-permissions')" data-section="consol-permissions">
949
+ <span class="nav-icon">&#9679;</span> Coherence des acces
950
+ </a>
951
+ <a class="nav-item" onclick="showSection('consol-flows')" data-section="consol-flows">
952
+ <span class="nav-icon">&#9679;</span> Parcours bout en bout
953
+ </a>
954
+ </div>
955
+
956
+ <!-- Phase 5 : Synthese -->
957
+ <div class="nav-group">
958
+ <div class="nav-group-title">5. Synthese</div>
959
+ <a class="nav-item" onclick="showSection('handoff-summary')" data-section="handoff-summary">
960
+ <span class="nav-icon">&#9679;</span> Vue d'ensemble
961
+ </a>
962
+ </div>
963
+ </aside>
964
+
965
+ <!-- ============================================
966
+ MAIN CONTENT
967
+ ============================================ -->
968
+ <main class="main" id="mainContent">
969
+
970
+ <!-- SECTION: Probleme a resoudre -->
971
+ <div class="section" id="cadrage-problem">
972
+ <h2 class="section-title">Probleme a resoudre</h2>
973
+ <p class="section-subtitle">Decrivez le probleme principal que ce projet doit resoudre. Soyez le plus concret possible.</p>
974
+
975
+ <div class="card">
976
+ <div class="card-label">Description du probleme</div>
977
+ <div class="editable" contenteditable="true" data-field="problem.description" data-placeholder="Decrivez le probleme que vous rencontrez aujourd'hui. Qu'est-ce qui ne fonctionne pas, ou pas assez bien ?"></div>
978
+ </div>
979
+
980
+ <div class="card">
981
+ <div class="card-label">Qui est le plus impacte ?</div>
982
+ <div class="editable" contenteditable="true" data-field="problem.impactedPeople" data-placeholder="Quelles personnes souffrent le plus de ce probleme au quotidien ? Quel impact sur leur travail ?"></div>
983
+ </div>
984
+
985
+ <div class="card">
986
+ <div class="card-label">Depuis quand ce probleme existe-t-il ?</div>
987
+ <div class="editable" contenteditable="true" data-field="problem.history" data-placeholder="Depuis combien de temps ce probleme existe-t-il ? A-t-il empire recemment ?"></div>
988
+ </div>
989
+
990
+ <div class="card">
991
+ <div class="card-label">Evenement declencheur</div>
992
+ <div class="editable" contenteditable="true" data-field="problem.trigger" data-placeholder="Qu'est-ce qui a declenche cette demande maintenant ? Pourquoi pas il y a 6 mois ?"></div>
993
+ </div>
994
+
995
+ <div class="card">
996
+ <div class="card-label">Consequences si le projet n'est pas realise</div>
997
+ <div class="editable" contenteditable="true" data-field="problem.consequences" data-placeholder="Que se passerait-il si ce projet n'etait PAS realise ? Quelles consequences a court et moyen terme ?"></div>
998
+ </div>
999
+ </div>
1000
+
1001
+ <!-- SECTION: Situation actuelle -->
1002
+ <div class="section" id="cadrage-current" style="display:none;">
1003
+ <h2 class="section-title">Situation actuelle</h2>
1004
+ <p class="section-subtitle">Comment les choses se passent aujourd'hui, concretement.</p>
1005
+
1006
+ <div class="card">
1007
+ <div class="card-label">Outils et methodes utilises aujourd'hui</div>
1008
+ <div class="editable" contenteditable="true" data-field="current.tools" data-placeholder="Comment gerez-vous ce sujet aujourd'hui ? Avec quels outils (tableur, email, papier, logiciel) ?"></div>
1009
+ </div>
1010
+
1011
+ <div class="card">
1012
+ <div class="card-label">Processus actuel, etape par etape</div>
1013
+ <div id="processFlow" class="process-flow">
1014
+ <!-- Populated dynamically -->
1015
+ </div>
1016
+ <button class="add-btn" onclick="addProcessStep()">+ Ajouter une etape au processus</button>
1017
+ </div>
1018
+
1019
+ <div class="card">
1020
+ <div class="card-label">Etapes les plus penibles ou les plus longues</div>
1021
+ <div class="editable" contenteditable="true" data-field="current.painPoints" data-placeholder="Quelles sont les etapes les plus penibles ou les plus longues dans ce processus ?"></div>
1022
+ </div>
1023
+
1024
+ <div class="card">
1025
+ <div class="card-label">Erreurs ou problemes recurrents</div>
1026
+ <div class="editable" contenteditable="true" data-field="current.errors" data-placeholder="Quelles erreurs ou problemes reviennent regulierement ? Donnez 2 a 3 exemples concrets."></div>
1027
+ </div>
1028
+ </div>
1029
+
1030
+ <!-- SECTION: Situation souhaitee -->
1031
+ <div class="section" id="cadrage-vision" style="display:none;">
1032
+ <h2 class="section-title">Situation souhaitee</h2>
1033
+ <p class="section-subtitle">Ce que le client veut obtenir, pas ce qu'il veut construire.</p>
1034
+
1035
+ <div class="card">
1036
+ <div class="card-label">Ce qui changerait concretement</div>
1037
+ <div class="editable" contenteditable="true" data-field="vision.changes" data-placeholder="Si le probleme etait resolu demain, que feriez-vous differemment dans votre journee de travail ?"></div>
1038
+ </div>
1039
+
1040
+ <div class="card">
1041
+ <div class="card-label">Resultats attendus (mesurables)</div>
1042
+ <div class="editable" contenteditable="true" data-field="vision.results" data-placeholder="Quels resultats concrets attendez-vous ? Citez 2 a 3 ameliorations mesurables."></div>
1043
+ </div>
1044
+
1045
+ <div class="card">
1046
+ <div class="card-label">Signe visible de succes</div>
1047
+ <div class="editable" contenteditable="true" data-field="vision.successSign" data-placeholder="Comment saurez-vous que le projet est un succes ? Quel est le signe visible ?"></div>
1048
+ </div>
1049
+ </div>
1050
+
1051
+ <!-- SECTION: Parties prenantes -->
1052
+ <div class="section" id="cadrage-stakeholders" style="display:none;">
1053
+ <h2 class="section-title">Parties prenantes</h2>
1054
+ <p class="section-subtitle">Toutes les personnes concernees par ce projet et leurs besoins.</p>
1055
+
1056
+ <div class="stakeholder-grid" id="stakeholderGrid">
1057
+ <!-- Populated dynamically -->
1058
+ </div>
1059
+
1060
+ <button class="add-btn" onclick="toggleForm('addStakeholderForm')">+ Ajouter un profil utilisateur</button>
1061
+
1062
+ <div class="inline-form" id="addStakeholderForm">
1063
+ <div class="inline-form-title">Nouveau profil utilisateur</div>
1064
+ <div class="form-group">
1065
+ <label class="form-label">Titre du profil (exemple : Responsable de production)</label>
1066
+ <input type="text" class="form-input" id="sh-role" placeholder="Titre ou description du profil">
1067
+ </div>
1068
+ <div class="form-group">
1069
+ <label class="form-label">Fonction dans l'entreprise</label>
1070
+ <input type="text" class="form-input" id="sh-function" placeholder="Ce qu'il fait dans l'organisation">
1071
+ </div>
1072
+ <div class="form-group">
1073
+ <label class="form-label">Taches principales (une par ligne)</label>
1074
+ <textarea class="form-textarea" id="sh-tasks" placeholder="Tache 1&#10;Tache 2&#10;Tache 3"></textarea>
1075
+ </div>
1076
+ <div class="form-row">
1077
+ <div class="form-group">
1078
+ <label class="form-label">Frequence d'utilisation</label>
1079
+ <select class="form-select" id="sh-frequency">
1080
+ <option value="daily">Quotidienne</option>
1081
+ <option value="weekly">Hebdomadaire</option>
1082
+ <option value="monthly">Mensuelle</option>
1083
+ <option value="occasional">Occasionnelle</option>
1084
+ </select>
1085
+ </div>
1086
+ <div class="form-group">
1087
+ <label class="form-label">Niveau d'acces</label>
1088
+ <select class="form-select" id="sh-access">
1089
+ <option value="admin">Administration complete</option>
1090
+ <option value="manager">Supervision et validation</option>
1091
+ <option value="contributor">Saisie et modification</option>
1092
+ <option value="viewer">Consultation seule</option>
1093
+ </select>
1094
+ </div>
1095
+ </div>
1096
+ <div class="form-group">
1097
+ <label class="form-label">Frustrations actuelles</label>
1098
+ <textarea class="form-textarea" id="sh-frustrations" placeholder="Quelles sont les 2-3 plus grandes frustrations de ce profil avec la facon de travailler actuelle ?"></textarea>
1099
+ </div>
1100
+ <div class="form-actions">
1101
+ <button class="btn" onclick="toggleForm('addStakeholderForm')">Annuler</button>
1102
+ <button class="btn btn-primary" onclick="addStakeholder()">Ajouter ce profil</button>
1103
+ </div>
1104
+ </div>
1105
+ </div>
1106
+
1107
+ <!-- SECTION: Perimetre fonctionnel -->
1108
+ <div class="section" id="cadrage-scope" style="display:none;">
1109
+ <h2 class="section-title">Perimetre fonctionnel</h2>
1110
+ <p class="section-subtitle">Ce que le systeme doit faire et ne pas faire, par ordre de priorite.</p>
1111
+
1112
+ <h3 style="color: var(--text-bright); font-size: 1rem; margin-bottom: 0.75rem;">
1113
+ <span style="color: #f87171;">&#9632;</span> Fonctionnalites indispensables
1114
+ </h3>
1115
+ <div id="scopeVital" class="uc-list"></div>
1116
+ <button class="add-btn" onclick="addScopeItem('vital')">+ Ajouter une fonctionnalite indispensable</button>
1117
+
1118
+ <h3 style="color: var(--text-bright); font-size: 1rem; margin: 1.5rem 0 0.75rem;">
1119
+ <span style="color: #facc15;">&#9632;</span> Fonctionnalites importantes
1120
+ </h3>
1121
+ <div id="scopeImportant" class="uc-list"></div>
1122
+ <button class="add-btn" onclick="addScopeItem('important')">+ Ajouter une fonctionnalite importante</button>
1123
+
1124
+ <h3 style="color: var(--text-bright); font-size: 1rem; margin: 1.5rem 0 0.75rem;">
1125
+ <span style="color: #4ade80;">&#9632;</span> Fonctionnalites optionnelles
1126
+ </h3>
1127
+ <div id="scopeOptional" class="uc-list"></div>
1128
+ <button class="add-btn" onclick="addScopeItem('optional')">+ Ajouter une fonctionnalite optionnelle</button>
1129
+
1130
+ <h3 style="color: var(--text-bright); font-size: 1rem; margin: 1.5rem 0 0.75rem;">
1131
+ <span style="color: #94a3b8;">&#9632;</span> Hors perimetre
1132
+ </h3>
1133
+ <div id="scopeExcluded" class="uc-list"></div>
1134
+ <button class="add-btn" onclick="addScopeItem('excluded')">+ Ajouter une exclusion</button>
1135
+ </div>
1136
+
1137
+ <!-- SECTION: Risques et hypotheses -->
1138
+ <div class="section" id="cadrage-risks" style="display:none;">
1139
+ <h2 class="section-title">Risques et hypotheses</h2>
1140
+ <p class="section-subtitle">Ce qui pourrait mal tourner et les certitudes non verifiees.</p>
1141
+
1142
+ <h3 style="color: var(--text-bright); font-size: 1rem; margin-bottom: 0.75rem;">Risques identifies</h3>
1143
+ <div id="risksList"></div>
1144
+ <button class="add-btn" onclick="toggleForm('addRiskForm')">+ Ajouter un risque</button>
1145
+
1146
+ <div class="inline-form" id="addRiskForm">
1147
+ <div class="inline-form-title">Nouveau risque</div>
1148
+ <div class="form-group">
1149
+ <label class="form-label">Description du risque</label>
1150
+ <input type="text" class="form-input" id="risk-desc" placeholder="Qu'est-ce qui pourrait mal tourner ?">
1151
+ </div>
1152
+ <div class="form-row">
1153
+ <div class="form-group">
1154
+ <label class="form-label">Probabilite</label>
1155
+ <select class="form-select" id="risk-probability">
1156
+ <option value="high">Forte</option>
1157
+ <option value="medium">Moyenne</option>
1158
+ <option value="low">Faible</option>
1159
+ </select>
1160
+ </div>
1161
+ <div class="form-group">
1162
+ <label class="form-label">Impact</label>
1163
+ <select class="form-select" id="risk-impact">
1164
+ <option value="high">Grave</option>
1165
+ <option value="medium">Moyen</option>
1166
+ <option value="low">Faible</option>
1167
+ </select>
1168
+ </div>
1169
+ </div>
1170
+ <div class="form-group">
1171
+ <label class="form-label">Mesure de prevention ou de reduction</label>
1172
+ <textarea class="form-textarea" id="risk-mitigation" placeholder="Comment prevenir ou reduire ce risque ?"></textarea>
1173
+ </div>
1174
+ <div class="form-actions">
1175
+ <button class="btn" onclick="toggleForm('addRiskForm')">Annuler</button>
1176
+ <button class="btn btn-primary" onclick="addRisk()">Ajouter ce risque</button>
1177
+ </div>
1178
+ </div>
1179
+
1180
+ <h3 style="color: var(--text-bright); font-size: 1rem; margin: 2rem 0 0.75rem;">Hypotheses a verifier</h3>
1181
+ <div class="card">
1182
+ <div class="editable" contenteditable="true" data-field="risks.assumptions" data-placeholder="Quelles hypotheses faites-vous sur ce projet sans les avoir verifiees ? (une par ligne)"></div>
1183
+ </div>
1184
+ </div>
1185
+
1186
+ <!-- SECTION: Criteres de reussite -->
1187
+ <div class="section" id="cadrage-success" style="display:none;">
1188
+ <h2 class="section-title">Criteres de reussite</h2>
1189
+ <p class="section-subtitle">Comment mesurer objectivement que le projet est un succes.</p>
1190
+
1191
+ <div class="card">
1192
+ <div class="card-label">Definition du succes</div>
1193
+ <div class="editable" contenteditable="true" data-field="success.definition" data-placeholder="Comment saurez-vous que le projet est un succes ? Quel changement concret observerez-vous ?"></div>
1194
+ </div>
1195
+
1196
+ <div class="card">
1197
+ <div class="card-label">Objectifs mesurables</div>
1198
+ <div class="editable" contenteditable="true" data-field="success.metrics" data-placeholder="Quels chiffres presenteriez-vous a votre direction pour prouver le succes ? (temps, erreurs, satisfaction...)"></div>
1199
+ </div>
1200
+
1201
+ <div class="card">
1202
+ <div class="card-label">Delai d'evaluation</div>
1203
+ <div class="editable" contenteditable="true" data-field="success.timeline" data-placeholder="Au bout de combien de temps pourrez-vous juger si ca fonctionne ? 1 semaine ? 1 mois ? 3 mois ?"></div>
1204
+ </div>
1205
+
1206
+ <div class="card">
1207
+ <div class="card-label">Conditions minimales de mise en service</div>
1208
+ <div class="editable" contenteditable="true" data-field="success.minimumConditions" data-placeholder="Quelles conditions minimales pour mettre le systeme en service ? (fonctionnalites presentes, donnees migrees, formation faite...)"></div>
1209
+ </div>
1210
+ </div>
1211
+
1212
+ <!-- ================================================================
1213
+ PHASE 2 : DECOMPOSITION
1214
+ ================================================================ -->
1215
+
1216
+ <!-- SECTION: Domaines fonctionnels -->
1217
+ <div class="section" id="decomp-modules" style="display:none;">
1218
+ <h2 class="section-title">Domaines fonctionnels</h2>
1219
+ <p class="section-subtitle">Identifiez les grands domaines de votre application. Chaque domaine regroupe des fonctionnalites coherentes et independantes.</p>
1220
+
1221
+ <div class="module-grid" id="moduleGrid">
1222
+ <!-- Populated dynamically -->
1223
+ </div>
1224
+
1225
+ <button class="add-btn" onclick="toggleForm('addModuleForm')" style="margin-top:1rem;">+ Ajouter un domaine fonctionnel</button>
1226
+
1227
+ <div class="inline-form" id="addModuleForm">
1228
+ <div class="inline-form-title">Nouveau domaine fonctionnel</div>
1229
+ <div class="form-group">
1230
+ <label class="form-label">Nom du domaine (exemple : Gestion des commandes)</label>
1231
+ <input type="text" class="form-input" id="mod-name" placeholder="Nom clair et explicite">
1232
+ </div>
1233
+ <div class="form-group">
1234
+ <label class="form-label">Description en une ou deux phrases</label>
1235
+ <textarea class="form-textarea" id="mod-desc" placeholder="A quoi sert ce domaine ? Quel probleme resout-il ?"></textarea>
1236
+ </div>
1237
+ <div class="form-row">
1238
+ <div class="form-group">
1239
+ <label class="form-label">Type de domaine</label>
1240
+ <select class="form-select" id="mod-type">
1241
+ <option value="data-centric">Gestion de donnees (listes, fiches, formulaires)</option>
1242
+ <option value="workflow">Processus metier (etapes, validations, approbations)</option>
1243
+ <option value="reporting">Tableaux de bord et rapports</option>
1244
+ <option value="integration">Integration avec des systemes externes</option>
1245
+ <option value="full-module">Domaine complet (donnees + processus + rapports)</option>
1246
+ </select>
1247
+ </div>
1248
+ <div class="form-group">
1249
+ <label class="form-label">Priorite</label>
1250
+ <select class="form-select" id="mod-priority">
1251
+ <option value="must">Indispensable</option>
1252
+ <option value="should">Important</option>
1253
+ <option value="could">Optionnel</option>
1254
+ </select>
1255
+ </div>
1256
+ </div>
1257
+ <div class="form-group">
1258
+ <label class="form-label">Principales donnees gerees (une par ligne)</label>
1259
+ <textarea class="form-textarea" id="mod-entities" placeholder="Commande&#10;Ligne de commande&#10;Facture"></textarea>
1260
+ </div>
1261
+ <div class="form-actions">
1262
+ <button class="btn" onclick="toggleForm('addModuleForm')">Annuler</button>
1263
+ <button class="btn btn-primary" onclick="addModule()">Ajouter ce domaine</button>
1264
+ </div>
1265
+ </div>
1266
+ </div>
1267
+
1268
+ <!-- SECTION: Dependances -->
1269
+ <div class="section" id="decomp-dependencies" style="display:none;">
1270
+ <h2 class="section-title">Dependances entre domaines</h2>
1271
+ <p class="section-subtitle">Indiquez quels domaines dependent d'autres domaines. Par exemple, les Commandes dependent des Clients et des Produits.</p>
1272
+
1273
+ <div id="depGraphContainer">
1274
+ <div class="dep-graph" id="depGraph">
1275
+ <p style="color:var(--text-muted);text-align:center;padding:2rem;">Ajoutez des domaines fonctionnels pour visualiser les dependances.</p>
1276
+ </div>
1277
+ </div>
1278
+
1279
+ <div style="margin-top:1.5rem;">
1280
+ <h3 style="color:var(--text-bright);font-size:1rem;margin-bottom:0.75rem;">Ajouter une dependance</h3>
1281
+ <div class="form-row">
1282
+ <div class="form-group">
1283
+ <label class="form-label">Ce domaine...</label>
1284
+ <select class="form-select" id="dep-from"></select>
1285
+ </div>
1286
+ <div class="form-group">
1287
+ <label class="form-label">...depend de</label>
1288
+ <select class="form-select" id="dep-to"></select>
1289
+ </div>
1290
+ </div>
1291
+ <div class="form-group">
1292
+ <label class="form-label">Nature de la dependance</label>
1293
+ <input type="text" class="form-input" id="dep-desc" placeholder="Exemple : La commande reference un client existant">
1294
+ </div>
1295
+ <button class="btn btn-primary" onclick="addDependency()" style="margin-top:0.5rem;">Ajouter cette dependance</button>
1296
+ </div>
1297
+
1298
+ <div id="depList" style="margin-top:1.5rem;"></div>
1299
+
1300
+ <div style="margin-top:2rem;">
1301
+ <h3 style="color:var(--text-bright);font-size:1rem;margin-bottom:0.75rem;">Ordre de traitement propose</h3>
1302
+ <p class="section-subtitle">Les domaines sont traites dans l'ordre de leurs dependances : les fondations d'abord, puis les domaines qui en dependent.</p>
1303
+ <div id="processingOrder" class="process-flow"></div>
1304
+ </div>
1305
+ </div>
1306
+
1307
+ <!-- ================================================================
1308
+ PHASE 3 : SPECIFICATION PAR MODULE
1309
+ ================================================================ -->
1310
+
1311
+ <!-- Container dynamique pour les specs de chaque module -->
1312
+ <div id="moduleSpecContainer">
1313
+ <!-- Generated dynamically by renderModuleSpec() -->
1314
+ </div>
1315
+
1316
+ <!-- ================================================================
1317
+ PHASE 4 : CONSOLIDATION
1318
+ ================================================================ -->
1319
+
1320
+ <!-- SECTION: Interactions cross-module -->
1321
+ <div class="section" id="consol-interactions" style="display:none;">
1322
+ <h2 class="section-title">Interactions entre domaines</h2>
1323
+ <p class="section-subtitle">Vue d'ensemble de la facon dont les domaines communiquent et partagent des donnees.</p>
1324
+ <div id="consolInteractions">
1325
+ <p style="color:var(--text-muted);text-align:center;padding:2rem;">Les interactions seront calculees automatiquement a partir des dependances et des donnees partagees entre domaines.</p>
1326
+ </div>
1327
+ </div>
1328
+
1329
+ <!-- SECTION: Coherence des acces -->
1330
+ <div class="section" id="consol-permissions" style="display:none;">
1331
+ <h2 class="section-title">Coherence des droits d'acces</h2>
1332
+ <p class="section-subtitle">Verification que les profils utilisateurs ont des droits coherents dans tous les domaines.</p>
1333
+ <div id="consolPermissions">
1334
+ <p style="color:var(--text-muted);text-align:center;padding:2rem;">La coherence sera verifiee quand les permissions de chaque domaine seront definies.</p>
1335
+ </div>
1336
+ </div>
1337
+
1338
+ <!-- SECTION: Parcours bout en bout -->
1339
+ <div class="section" id="consol-flows" style="display:none;">
1340
+ <h2 class="section-title">Parcours bout en bout</h2>
1341
+ <p class="section-subtitle">Les processus metier qui traversent plusieurs domaines, de bout en bout.</p>
1342
+
1343
+ <div id="e2eFlowsList"></div>
1344
+
1345
+ <button class="add-btn" onclick="toggleForm('addFlowForm')">+ Ajouter un parcours</button>
1346
+
1347
+ <div class="inline-form" id="addFlowForm">
1348
+ <div class="inline-form-title">Nouveau parcours bout en bout</div>
1349
+ <div class="form-group">
1350
+ <label class="form-label">Nom du parcours (exemple : De la commande a la facture)</label>
1351
+ <input type="text" class="form-input" id="flow-name" placeholder="Nom descriptif du parcours">
1352
+ </div>
1353
+ <div class="form-group">
1354
+ <label class="form-label">Etapes du parcours (une par ligne : Domaine - Action)</label>
1355
+ <textarea class="form-textarea" id="flow-steps" placeholder="Clients - Le client existe dans le systeme&#10;Commandes - Creer la commande&#10;Commandes - Valider la commande&#10;Factures - Generer la facture"></textarea>
1356
+ </div>
1357
+ <div class="form-group">
1358
+ <label class="form-label">Qui intervient dans ce parcours ?</label>
1359
+ <input type="text" class="form-input" id="flow-actors" placeholder="Exemple : Contributeur (creation), Responsable (validation)">
1360
+ </div>
1361
+ <div class="form-actions">
1362
+ <button class="btn" onclick="toggleForm('addFlowForm')">Annuler</button>
1363
+ <button class="btn btn-primary" onclick="addE2EFlow()">Ajouter ce parcours</button>
1364
+ </div>
1365
+ </div>
1366
+ </div>
1367
+
1368
+ <!-- ================================================================
1369
+ PHASE 5 : SYNTHESE
1370
+ ================================================================ -->
1371
+
1372
+ <div class="section" id="handoff-summary" style="display:none;">
1373
+ <h2 class="section-title">Synthese de l'analyse</h2>
1374
+ <p class="section-subtitle">Vue d'ensemble de toute l'analyse metier, prete pour le developpement.</p>
1375
+
1376
+ <div class="stat-grid" id="handoffStats">
1377
+ <!-- Populated dynamically -->
1378
+ </div>
1379
+
1380
+ <h3 style="color:var(--text-bright);font-size:1rem;margin-bottom:0.75rem;">Domaines par ordre de traitement</h3>
1381
+ <div id="handoffModuleList"></div>
1382
+
1383
+ <h3 style="color:var(--text-bright);font-size:1rem;margin:1.5rem 0 0.75rem;">Couverture du besoin initial</h3>
1384
+ <div class="card">
1385
+ <div class="card-label">Matrice de couverture</div>
1386
+ <p style="font-size:0.85rem;color:var(--text-muted);margin-bottom:0.75rem;">Chaque besoin du cadrage est couvert par au moins un domaine et un cas d'utilisation.</p>
1387
+ <div id="coverageMatrix"></div>
1388
+ </div>
1389
+
1390
+ <div style="margin-top:2rem;padding:1.5rem;background:var(--bg-card);border:1px solid var(--border);border-radius:10px;text-align:center;">
1391
+ <p style="color:var(--text-bright);font-size:1.1rem;font-weight:600;margin-bottom:0.5rem;">Analyse prete pour l'extraction</p>
1392
+ <p style="color:var(--text-muted);font-size:0.85rem;margin-bottom:1rem;">Exportez le fichier JSON pour lancer la generation automatique du systeme.</p>
1393
+ <button class="btn btn-primary" onclick="exportJSON()" style="font-size:0.9rem;padding:0.6rem 1.5rem;">Exporter l'analyse complete en JSON</button>
1394
+ </div>
1395
+ </div>
1396
+
1397
+ </main>
1398
+ </div>
1399
+ </div>
1400
+
1401
+ <!-- Notification -->
1402
+ <div class="notification notification-success" id="notification"></div>
1403
+
1404
+ <script>
1405
+ /* ============================================
1406
+ DATA STORE
1407
+ ============================================ */
1408
+ const APP_KEY = 'ba-{{APPLICATION_ID}}';
1409
+ let data = {
1410
+ metadata: {
1411
+ applicationName: '{{APPLICATION_NAME}}',
1412
+ applicationId: '{{APPLICATION_ID}}',
1413
+ version: '{{VERSION}}',
1414
+ createdAt: '{{CREATED_AT}}',
1415
+ lastModified: new Date().toISOString()
1416
+ },
1417
+ cadrage: {
1418
+ problem: {},
1419
+ current: {},
1420
+ vision: {},
1421
+ stakeholders: [],
1422
+ scope: { vital: [], important: [], optional: [], excluded: [] },
1423
+ risks: [],
1424
+ assumptions: '',
1425
+ success: {}
1426
+ },
1427
+ modules: [],
1428
+ dependencies: [],
1429
+ moduleSpecs: {},
1430
+ consolidation: {
1431
+ interactions: [],
1432
+ e2eFlows: []
1433
+ },
1434
+ handoff: {}
1435
+ };
1436
+
1437
+ /* ============================================
1438
+ INITIALIZATION
1439
+ ============================================ */
1440
+ document.addEventListener('DOMContentLoaded', function() {
1441
+ loadFromLocalStorage();
1442
+ initEditableFields();
1443
+ renderStakeholders();
1444
+ renderScope();
1445
+ renderRisks();
1446
+ renderModules();
1447
+ renderDependencies();
1448
+ renderAllModuleSpecs();
1449
+ renderConsolidation();
1450
+ renderHandoff();
1451
+ renderE2EFlows();
1452
+ updateCounts();
1453
+ });
1454
+
1455
+ /* ============================================
1456
+ NAVIGATION
1457
+ ============================================ */
1458
+ let currentSectionId = 'cadrage-problem';
1459
+
1460
+ function showSection(sectionId) {
1461
+ currentSectionId = sectionId;
1462
+ document.querySelectorAll('.section').forEach(s => s.style.display = 'none');
1463
+ const section = document.getElementById(sectionId);
1464
+ if (section) section.style.display = 'block';
1465
+
1466
+ document.querySelectorAll('.nav-item').forEach(n => n.classList.remove('active'));
1467
+ const navItem = document.querySelector('[data-section="' + sectionId + '"]');
1468
+ if (navItem) navItem.classList.add('active');
1469
+ }
1470
+
1471
+ function restoreCurrentSection() {
1472
+ if (currentSectionId) {
1473
+ const section = document.getElementById(currentSectionId);
1474
+ if (section) section.style.display = 'block';
1475
+ }
1476
+ }
1477
+
1478
+ /* ============================================
1479
+ EDITABLE FIELDS
1480
+ ============================================ */
1481
+ function initEditableFields() {
1482
+ document.querySelectorAll('.editable[data-field]').forEach(el => {
1483
+ const field = el.dataset.field;
1484
+ const value = getNestedValue(data, 'cadrage.' + field);
1485
+ if (value) el.textContent = value;
1486
+
1487
+ el.addEventListener('blur', function() {
1488
+ setNestedValue(data, 'cadrage.' + field, this.textContent.trim());
1489
+ autoSave();
1490
+ });
1491
+ });
1492
+ }
1493
+
1494
+ /* ============================================
1495
+ STAKEHOLDERS
1496
+ ============================================ */
1497
+ function addStakeholder() {
1498
+ const role = document.getElementById('sh-role').value.trim();
1499
+ if (!role) return;
1500
+
1501
+ data.cadrage.stakeholders.push({
1502
+ role: role,
1503
+ function: document.getElementById('sh-function').value.trim(),
1504
+ tasks: document.getElementById('sh-tasks').value.split('\n').filter(t => t.trim()),
1505
+ frequency: document.getElementById('sh-frequency').value,
1506
+ access: document.getElementById('sh-access').value,
1507
+ frustrations: document.getElementById('sh-frustrations').value.trim()
1508
+ });
1509
+
1510
+ renderStakeholders();
1511
+ toggleForm('addStakeholderForm');
1512
+ clearForm('addStakeholderForm');
1513
+ updateCounts();
1514
+ autoSave();
1515
+ }
1516
+
1517
+ function renderStakeholders() {
1518
+ const grid = document.getElementById('stakeholderGrid');
1519
+ grid.innerHTML = data.cadrage.stakeholders.map((s, i) => `
1520
+ <div class="stakeholder-card">
1521
+ <div style="display:flex;justify-content:space-between;align-items:start;">
1522
+ <div class="stakeholder-role">${s.role}</div>
1523
+ <button class="btn btn-sm" onclick="removeStakeholder(${i})" style="opacity:0.5;font-size:0.7rem;">Supprimer</button>
1524
+ </div>
1525
+ <div class="stakeholder-function">${s.function || ''}</div>
1526
+ <ul class="stakeholder-tasks">
1527
+ ${(s.tasks || []).map(t => '<li>' + t + '</li>').join('')}
1528
+ </ul>
1529
+ <div class="stakeholder-meta">
1530
+ <span>${formatFrequency(s.frequency)}</span>
1531
+ <span>${formatAccess(s.access)}</span>
1532
+ </div>
1533
+ ${s.frustrations ? '<div style="font-size:0.8rem;color:var(--warning);margin-top:0.5rem;font-style:italic;">' + s.frustrations + '</div>' : ''}
1534
+ </div>
1535
+ `).join('');
1536
+ }
1537
+
1538
+ function removeStakeholder(index) {
1539
+ data.cadrage.stakeholders.splice(index, 1);
1540
+ renderStakeholders();
1541
+ updateCounts();
1542
+ autoSave();
1543
+ }
1544
+
1545
+ /* ============================================
1546
+ SCOPE ITEMS
1547
+ ============================================ */
1548
+ function addScopeItem(priority) {
1549
+ const name = prompt('Nom de la fonctionnalite :');
1550
+ if (!name) return;
1551
+ const description = prompt('Description courte (optionnel) :') || '';
1552
+
1553
+ data.cadrage.scope[priority].push({ name, description });
1554
+ renderScope();
1555
+ autoSave();
1556
+ }
1557
+
1558
+ function renderScope() {
1559
+ ['vital', 'important', 'optional', 'excluded'].forEach(p => {
1560
+ const container = document.getElementById('scope' + p.charAt(0).toUpperCase() + p.slice(1));
1561
+ container.innerHTML = data.cadrage.scope[p].map((item, i) => `
1562
+ <div class="uc-item">
1563
+ <div class="uc-header">
1564
+ <span class="priority priority-${p}">${formatPriority(p)}</span>
1565
+ <span class="uc-title">${item.name}</span>
1566
+ <div class="uc-actions">
1567
+ <button class="btn btn-sm" onclick="removeScopeItem('${p}',${i})">Supprimer</button>
1568
+ </div>
1569
+ </div>
1570
+ ${item.description ? '<div class="uc-detail">' + item.description + '</div>' : ''}
1571
+ </div>
1572
+ `).join('');
1573
+ });
1574
+ }
1575
+
1576
+ function removeScopeItem(priority, index) {
1577
+ data.cadrage.scope[priority].splice(index, 1);
1578
+ renderScope();
1579
+ autoSave();
1580
+ }
1581
+
1582
+ /* ============================================
1583
+ RISKS
1584
+ ============================================ */
1585
+ function addRisk() {
1586
+ const desc = document.getElementById('risk-desc').value.trim();
1587
+ if (!desc) return;
1588
+
1589
+ data.cadrage.risks.push({
1590
+ description: desc,
1591
+ probability: document.getElementById('risk-probability').value,
1592
+ impact: document.getElementById('risk-impact').value,
1593
+ mitigation: document.getElementById('risk-mitigation').value.trim()
1594
+ });
1595
+
1596
+ renderRisks();
1597
+ toggleForm('addRiskForm');
1598
+ clearForm('addRiskForm');
1599
+ autoSave();
1600
+ }
1601
+
1602
+ function renderRisks() {
1603
+ const list = document.getElementById('risksList');
1604
+ list.innerHTML = data.cadrage.risks.map((r, i) => {
1605
+ const level = (r.probability === 'high' && r.impact === 'high') ? 'critical'
1606
+ : (r.probability === 'low' && r.impact === 'low') ? 'low' : 'medium';
1607
+ return `
1608
+ <div class="risk-item">
1609
+ <div class="risk-level risk-${level}"></div>
1610
+ <div>
1611
+ <div class="risk-text">${r.description}</div>
1612
+ ${r.mitigation ? '<div style="font-size:0.75rem;color:var(--text-muted);margin-top:0.25rem;">Prevention : ' + r.mitigation + '</div>' : ''}
1613
+ </div>
1614
+ <div class="risk-probability">${formatLevel(r.probability)}</div>
1615
+ <div class="risk-impact">${formatLevel(r.impact)}</div>
1616
+ </div>
1617
+ `;
1618
+ }).join('');
1619
+ }
1620
+
1621
+ /* ============================================
1622
+ PROCESS STEPS
1623
+ ============================================ */
1624
+ function addProcessStep() {
1625
+ const label = prompt('Nom de l\'etape :');
1626
+ if (!label) return;
1627
+ if (!data.cadrage.current.steps) data.cadrage.current.steps = [];
1628
+ data.cadrage.current.steps.push(label);
1629
+ renderProcessFlow();
1630
+ autoSave();
1631
+ }
1632
+
1633
+ function renderProcessFlow() {
1634
+ const container = document.getElementById('processFlow');
1635
+ const steps = data.cadrage.current.steps || [];
1636
+ container.innerHTML = steps.map((step, i) => `
1637
+ <div class="process-step">
1638
+ <div class="process-step-number">Etape ${i + 1}</div>
1639
+ <div class="process-step-label">${step}</div>
1640
+ </div>
1641
+ ${i < steps.length - 1 ? '<div class="process-arrow">&#8594;</div>' : ''}
1642
+ `).join('');
1643
+ }
1644
+
1645
+ /* ============================================
1646
+ PERSISTENCE
1647
+ ============================================ */
1648
+ function autoSave() {
1649
+ data.metadata.lastModified = new Date().toISOString();
1650
+ localStorage.setItem(APP_KEY, JSON.stringify(data));
1651
+ }
1652
+
1653
+ function saveToLocalStorage() {
1654
+ autoSave();
1655
+ showNotification('Modifications sauvegardees');
1656
+ }
1657
+
1658
+ function loadFromLocalStorage() {
1659
+ const saved = localStorage.getItem(APP_KEY);
1660
+ if (saved) {
1661
+ try {
1662
+ const parsed = JSON.parse(saved);
1663
+ // Deep merge with defaults
1664
+ data.metadata = { ...data.metadata, ...parsed.metadata };
1665
+ data.cadrage = {
1666
+ ...data.cadrage,
1667
+ ...parsed.cadrage,
1668
+ scope: { ...data.cadrage.scope, ...(parsed.cadrage?.scope || {}) }
1669
+ };
1670
+ data.modules = parsed.modules || [];
1671
+ data.dependencies = parsed.dependencies || [];
1672
+ data.moduleSpecs = parsed.moduleSpecs || {};
1673
+ data.consolidation = { ...data.consolidation, ...(parsed.consolidation || {}) };
1674
+ data.handoff = parsed.handoff || {};
1675
+
1676
+ // Restore editable fields
1677
+ document.querySelectorAll('.editable[data-field]').forEach(el => {
1678
+ const value = getNestedValue(data, 'cadrage.' + el.dataset.field);
1679
+ if (value) el.textContent = value;
1680
+ });
1681
+ renderProcessFlow();
1682
+ } catch (e) { console.error('Error loading saved data:', e); }
1683
+ }
1684
+ }
1685
+
1686
+ function exportJSON() {
1687
+ // Collect all editable fields (cadrage)
1688
+ document.querySelectorAll('.editable[data-field]').forEach(el => {
1689
+ setNestedValue(data, 'cadrage.' + el.dataset.field, el.textContent.trim());
1690
+ });
1691
+
1692
+ // Collect module editable fields
1693
+ document.querySelectorAll('.editable[data-module-field]').forEach(el => {
1694
+ const code = el.dataset.moduleCode;
1695
+ const field = el.dataset.moduleField;
1696
+ if (data.moduleSpecs[code]) {
1697
+ data.moduleSpecs[code][field] = el.textContent.trim();
1698
+ }
1699
+ });
1700
+
1701
+ data.metadata.lastModified = new Date().toISOString();
1702
+ data.metadata.exportedAt = new Date().toISOString();
1703
+
1704
+ // Build complete export with structured data
1705
+ const exportData = {
1706
+ metadata: data.metadata,
1707
+ cadrage: data.cadrage,
1708
+ modules: data.modules,
1709
+ dependencies: data.dependencies,
1710
+ moduleSpecifications: {},
1711
+ consolidation: data.consolidation
1712
+ };
1713
+
1714
+ // Structure module specs for export
1715
+ data.modules.forEach(m => {
1716
+ const spec = data.moduleSpecs[m.code] || {};
1717
+ exportData.moduleSpecifications[m.code] = {
1718
+ module: m,
1719
+ useCases: (spec.useCases || []).map((uc, i) => ({
1720
+ id: 'UC-' + String(i + 1).padStart(3, '0'),
1721
+ ...uc
1722
+ })),
1723
+ businessRules: (spec.businessRules || []).map((br, i) => ({
1724
+ id: 'BR-' + br.category.toUpperCase().substring(0, 4) + '-' + String(i + 1).padStart(3, '0'),
1725
+ ...br
1726
+ })),
1727
+ entities: spec.entities || [],
1728
+ permissions: spec.permissions || [],
1729
+ notes: spec.notes || '',
1730
+ mockupNotes: spec.mockupNotes || ''
1731
+ };
1732
+ });
1733
+
1734
+ const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' });
1735
+ const url = URL.createObjectURL(blob);
1736
+ const a = document.createElement('a');
1737
+ a.href = url;
1738
+ a.download = (data.metadata.applicationId || 'analyse') + '-export.json';
1739
+ a.click();
1740
+ URL.revokeObjectURL(url);
1741
+ showNotification('Export JSON telecharge');
1742
+ }
1743
+
1744
+ /* ============================================
1745
+ UTILITIES
1746
+ ============================================ */
1747
+ function showNotification(message) {
1748
+ const el = document.getElementById('notification');
1749
+ el.textContent = message;
1750
+ el.classList.add('visible');
1751
+ setTimeout(() => el.classList.remove('visible'), 2500);
1752
+ }
1753
+
1754
+ function toggleForm(formId) {
1755
+ document.getElementById(formId).classList.toggle('visible');
1756
+ }
1757
+
1758
+ function clearForm(formId) {
1759
+ document.querySelectorAll('#' + formId + ' input, #' + formId + ' textarea').forEach(el => el.value = '');
1760
+ }
1761
+
1762
+ function getNestedValue(obj, path) {
1763
+ return path.split('.').reduce((o, k) => (o || {})[k], obj);
1764
+ }
1765
+
1766
+ function setNestedValue(obj, path, value) {
1767
+ const keys = path.split('.');
1768
+ let current = obj;
1769
+ for (let i = 0; i < keys.length - 1; i++) {
1770
+ if (!current[keys[i]]) current[keys[i]] = {};
1771
+ current = current[keys[i]];
1772
+ }
1773
+ current[keys[keys.length - 1]] = value;
1774
+ }
1775
+
1776
+ function updateCounts() {
1777
+ document.getElementById('stakeholderCount').textContent = data.cadrage.stakeholders.length;
1778
+ document.getElementById('moduleCount').textContent = data.modules.length;
1779
+ updateModulesNav();
1780
+ updateDepSelects();
1781
+ }
1782
+
1783
+ function formatFrequency(f) {
1784
+ return { daily: 'Quotidien', weekly: 'Hebdomadaire', monthly: 'Mensuel', occasional: 'Occasionnel' }[f] || f;
1785
+ }
1786
+
1787
+ function formatAccess(a) {
1788
+ return { admin: 'Administration', manager: 'Supervision', contributor: 'Contribution', viewer: 'Consultation' }[a] || a;
1789
+ }
1790
+
1791
+ function formatPriority(p) {
1792
+ return { vital: 'Indispensable', important: 'Important', optional: 'Optionnel', excluded: 'Hors perimetre' }[p] || p;
1793
+ }
1794
+
1795
+ function formatLevel(l) {
1796
+ return { high: 'Fort', medium: 'Moyen', low: 'Faible' }[l] || l;
1797
+ }
1798
+ /* ============================================
1799
+ MODULE MANAGEMENT
1800
+ ============================================ */
1801
+ function addModule() {
1802
+ const name = document.getElementById('mod-name').value.trim();
1803
+ if (!name) return;
1804
+ const code = name.replace(/[^a-zA-Z0-9]/g, '');
1805
+
1806
+ data.modules.push({
1807
+ code: code,
1808
+ name: name,
1809
+ description: document.getElementById('mod-desc').value.trim(),
1810
+ featureType: document.getElementById('mod-type').value,
1811
+ priority: document.getElementById('mod-priority').value,
1812
+ entities: document.getElementById('mod-entities').value.split('\n').filter(e => e.trim()),
1813
+ status: 'pending'
1814
+ });
1815
+
1816
+ // Initialize module spec
1817
+ if (!data.moduleSpecs[code]) {
1818
+ data.moduleSpecs[code] = {
1819
+ useCases: [],
1820
+ businessRules: [],
1821
+ entities: [],
1822
+ permissions: [],
1823
+ notes: ''
1824
+ };
1825
+ }
1826
+
1827
+ renderModules();
1828
+ renderDependencies();
1829
+ renderAllModuleSpecs();
1830
+ toggleForm('addModuleForm');
1831
+ clearForm('addModuleForm');
1832
+ updateCounts();
1833
+ autoSave();
1834
+ }
1835
+
1836
+ function removeModule(index) {
1837
+ if (!confirm('Supprimer ce domaine fonctionnel ?')) return;
1838
+ const code = data.modules[index].code;
1839
+ data.modules.splice(index, 1);
1840
+ delete data.moduleSpecs[code];
1841
+ data.dependencies = data.dependencies.filter(d => d.from !== code && d.to !== code);
1842
+ renderModules();
1843
+ renderDependencies();
1844
+ renderAllModuleSpecs();
1845
+ updateCounts();
1846
+ autoSave();
1847
+ }
1848
+
1849
+ function renderModules() {
1850
+ const grid = document.getElementById('moduleGrid');
1851
+ grid.innerHTML = data.modules.map((m, i) => `
1852
+ <div class="module-card" onclick="showSection('module-spec-${m.code}')">
1853
+ <button class="module-card-remove" onclick="event.stopPropagation();removeModule(${i})">&#10005;</button>
1854
+ <div class="module-card-header">
1855
+ <span class="module-card-code">${m.name}</span>
1856
+ <span class="module-card-type">${formatModuleType(m.featureType)}</span>
1857
+ </div>
1858
+ <div class="module-card-desc">${m.description || ''}</div>
1859
+ <div class="module-card-meta">
1860
+ <span class="priority priority-${m.priority === 'must' ? 'vital' : m.priority === 'should' ? 'important' : 'optional'}">${formatModulePriority(m.priority)}</span>
1861
+ <span>${(m.entities || []).length} donnees</span>
1862
+ <span>${(data.moduleSpecs[m.code]?.useCases || []).length} cas d'utilisation</span>
1863
+ </div>
1864
+ </div>
1865
+ `).join('') || '<p style="color:var(--text-muted);text-align:center;padding:2rem;grid-column:1/-1;">Aucun domaine fonctionnel defini. Cliquez sur le bouton ci-dessous pour commencer.</p>';
1866
+ }
1867
+
1868
+ function updateModulesNav() {
1869
+ const nav = document.getElementById('modulesNav');
1870
+ const navItems = data.modules.map(m => `
1871
+ <a class="nav-item" onclick="showSection('module-spec-${m.code}')" data-section="module-spec-${m.code}">
1872
+ <span class="nav-icon">&#9679;</span> ${m.name}
1873
+ <span class="nav-badge">${(data.moduleSpecs[m.code]?.useCases || []).length}</span>
1874
+ </a>
1875
+ `).join('');
1876
+ nav.innerHTML = '<div class="nav-group-title">3. Specification</div>' + (navItems || '<div style="padding:0.3rem 1rem;font-size:0.8rem;color:var(--text-muted);font-style:italic;">Aucun domaine</div>');
1877
+ }
1878
+
1879
+ /* ============================================
1880
+ DEPENDENCY MANAGEMENT
1881
+ ============================================ */
1882
+ function updateDepSelects() {
1883
+ const fromSel = document.getElementById('dep-from');
1884
+ const toSel = document.getElementById('dep-to');
1885
+ if (!fromSel || !toSel) return;
1886
+ const opts = data.modules.map(m => `<option value="${m.code}">${m.name}</option>`).join('');
1887
+ fromSel.innerHTML = opts;
1888
+ toSel.innerHTML = opts;
1889
+ }
1890
+
1891
+ function addDependency() {
1892
+ const from = document.getElementById('dep-from').value;
1893
+ const to = document.getElementById('dep-to').value;
1894
+ if (!from || !to || from === to) return;
1895
+ if (data.dependencies.some(d => d.from === from && d.to === to)) return;
1896
+
1897
+ data.dependencies.push({
1898
+ from: from,
1899
+ to: to,
1900
+ description: document.getElementById('dep-desc').value.trim()
1901
+ });
1902
+ document.getElementById('dep-desc').value = '';
1903
+
1904
+ renderDependencies();
1905
+ autoSave();
1906
+ }
1907
+
1908
+ function removeDependency(index) {
1909
+ data.dependencies.splice(index, 1);
1910
+ renderDependencies();
1911
+ autoSave();
1912
+ }
1913
+
1914
+ function renderDependencies() {
1915
+ // Render dependency list
1916
+ const depList = document.getElementById('depList');
1917
+ if (depList) {
1918
+ depList.innerHTML = data.dependencies.map((d, i) => {
1919
+ const fromName = data.modules.find(m => m.code === d.from)?.name || d.from;
1920
+ const toName = data.modules.find(m => m.code === d.to)?.name || d.to;
1921
+ return `
1922
+ <div class="interaction-item">
1923
+ <span style="font-weight:600;color:var(--text-bright);">${fromName}</span>
1924
+ <span class="interaction-arrow">&#8594;</span>
1925
+ <span style="font-weight:600;color:var(--text-bright);">${toName}</span>
1926
+ <span style="flex:1;font-size:0.8rem;color:var(--text-muted);">${d.description || ''}</span>
1927
+ <button class="btn btn-sm" onclick="removeDependency(${i})" style="opacity:0.5;">Supprimer</button>
1928
+ </div>
1929
+ `;
1930
+ }).join('');
1931
+ }
1932
+
1933
+ // Render graph
1934
+ renderDepGraph();
1935
+ // Render processing order
1936
+ renderProcessingOrder();
1937
+ }
1938
+
1939
+ function renderDepGraph() {
1940
+ const graph = document.getElementById('depGraph');
1941
+ if (!graph || data.modules.length === 0) return;
1942
+
1943
+ const layers = computeTopologicalLayers();
1944
+ if (!layers) {
1945
+ graph.innerHTML = '<p style="color:var(--error);text-align:center;padding:1rem;">Dependance circulaire detectee ! Corrigez les dependances.</p>';
1946
+ return;
1947
+ }
1948
+
1949
+ graph.innerHTML = layers.map((layer, i) => `
1950
+ <div class="dep-layer">
1951
+ <div class="dep-layer-label">Couche ${i + 1}</div>
1952
+ <div class="dep-layer-modules">
1953
+ ${layer.map(code => {
1954
+ const m = data.modules.find(mod => mod.code === code);
1955
+ return `<div class="dep-module">${m ? m.name : code}</div>`;
1956
+ }).join('')}
1957
+ </div>
1958
+ </div>
1959
+ ${i < layers.length - 1 ? '<div class="dep-arrow">&#8595;</div>' : ''}
1960
+ `).join('');
1961
+ }
1962
+
1963
+ function computeTopologicalLayers() {
1964
+ const codes = data.modules.map(m => m.code);
1965
+ const inDeg = {};
1966
+ const adj = {};
1967
+ codes.forEach(c => { inDeg[c] = 0; adj[c] = []; });
1968
+ data.dependencies.forEach(d => {
1969
+ if (inDeg[d.from] !== undefined && adj[d.to] !== undefined) {
1970
+ adj[d.to].push(d.from);
1971
+ inDeg[d.from]++;
1972
+ }
1973
+ });
1974
+
1975
+ const layers = [];
1976
+ let remaining = new Set(codes);
1977
+ while (remaining.size > 0) {
1978
+ const layer = [];
1979
+ remaining.forEach(c => {
1980
+ if (inDeg[c] === 0) layer.push(c);
1981
+ });
1982
+ if (layer.length === 0) return null; // cycle
1983
+ layers.push(layer);
1984
+ layer.forEach(c => {
1985
+ remaining.delete(c);
1986
+ (adj[c] || []).forEach(dep => { inDeg[dep]--; });
1987
+ });
1988
+ }
1989
+ return layers;
1990
+ }
1991
+
1992
+ function renderProcessingOrder() {
1993
+ const container = document.getElementById('processingOrder');
1994
+ if (!container) return;
1995
+ const layers = computeTopologicalLayers();
1996
+ if (!layers) { container.innerHTML = ''; return; }
1997
+ const order = layers.flat();
1998
+ container.innerHTML = order.map((code, i) => {
1999
+ const m = data.modules.find(mod => mod.code === code);
2000
+ return `
2001
+ <div class="process-step">
2002
+ <div class="process-step-number">Etape ${i + 1}</div>
2003
+ <div class="process-step-label">${m ? m.name : code}</div>
2004
+ </div>
2005
+ ${i < order.length - 1 ? '<div class="process-arrow">&#8594;</div>' : ''}
2006
+ `;
2007
+ }).join('');
2008
+ }
2009
+
2010
+ /* ============================================
2011
+ MODULE SPECIFICATION (per module)
2012
+ ============================================ */
2013
+ function renderAllModuleSpecs() {
2014
+ const container = document.getElementById('moduleSpecContainer');
2015
+ container.innerHTML = data.modules.map(m => renderModuleSpecSection(m)).join('');
2016
+ // Bind editable fields in module specs
2017
+ container.querySelectorAll('.editable[data-module-field]').forEach(el => {
2018
+ el.addEventListener('blur', function() {
2019
+ const code = this.dataset.moduleCode;
2020
+ const field = this.dataset.moduleField;
2021
+ if (data.moduleSpecs[code]) {
2022
+ data.moduleSpecs[code][field] = this.textContent.trim();
2023
+ autoSave();
2024
+ }
2025
+ });
2026
+ });
2027
+ // Restore currently visible section after re-render
2028
+ restoreCurrentSection();
2029
+ }
2030
+
2031
+ function renderModuleSpecSection(mod) {
2032
+ const code = mod.code;
2033
+ const spec = data.moduleSpecs[code] || { useCases: [], businessRules: [], entities: [], permissions: [], notes: '' };
2034
+
2035
+ return `
2036
+ <div class="section" id="module-spec-${code}" style="display:none;">
2037
+ <h2 class="section-title">${mod.name}</h2>
2038
+ <p class="section-subtitle">${mod.description || 'Specification detaillee de ce domaine fonctionnel.'}</p>
2039
+
2040
+ <div class="tab-bar">
2041
+ <button class="tab-btn active" onclick="switchTab('${code}', 'uc')">Cas d'utilisation</button>
2042
+ <button class="tab-btn" onclick="switchTab('${code}', 'br')">Regles metier</button>
2043
+ <button class="tab-btn" onclick="switchTab('${code}', 'ent')">Donnees</button>
2044
+ <button class="tab-btn" onclick="switchTab('${code}', 'perm')">Droits d'acces</button>
2045
+ <button class="tab-btn" onclick="switchTab('${code}', 'mock')">Maquettes</button>
2046
+ <button class="tab-btn" onclick="switchTab('${code}', 'notes')">Notes</button>
2047
+ </div>
2048
+
2049
+ <!-- TAB: Cas d'utilisation -->
2050
+ <div class="tab-panel active" id="tab-${code}-uc">
2051
+ <p style="font-size:0.85rem;color:var(--text-muted);margin-bottom:1rem;">Decrivez ce que chaque type d'utilisateur peut faire dans ce domaine. Un cas d'utilisation = une action concrete.</p>
2052
+ <div id="ucList-${code}" class="uc-list">
2053
+ ${spec.useCases.map((uc, i) => renderUseCase(code, uc, i)).join('')}
2054
+ </div>
2055
+ <button class="add-btn" onclick="toggleForm('addUcForm-${code}')">+ Ajouter un cas d'utilisation</button>
2056
+ <div class="inline-form" id="addUcForm-${code}">
2057
+ <div class="inline-form-title">Nouveau cas d'utilisation</div>
2058
+ <div class="form-group">
2059
+ <label class="form-label">Que fait l'utilisateur ? (exemple : Creer une commande)</label>
2060
+ <input type="text" class="form-input" id="uc-name-${code}" placeholder="Action concrete de l'utilisateur">
2061
+ </div>
2062
+ <div class="form-group">
2063
+ <label class="form-label">Qui realise cette action ? (profil utilisateur)</label>
2064
+ <input type="text" class="form-input" id="uc-actor-${code}" placeholder="Exemple : Responsable de production">
2065
+ </div>
2066
+ <div class="form-group">
2067
+ <label class="form-label">Deroulement normal, etape par etape (une par ligne)</label>
2068
+ <textarea class="form-textarea" id="uc-steps-${code}" placeholder="1. L'utilisateur ouvre la page de creation&#10;2. Il remplit les champs obligatoires&#10;3. Il valide le formulaire&#10;4. Le systeme enregistre et confirme"></textarea>
2069
+ </div>
2070
+ <div class="form-group">
2071
+ <label class="form-label">Que se passe-t-il si quelque chose ne va pas ? (optionnel)</label>
2072
+ <textarea class="form-textarea" id="uc-alt-${code}" placeholder="Exemple : Si les donnees sont incorrectes, le systeme affiche un message d'erreur" style="min-height:50px;"></textarea>
2073
+ </div>
2074
+ <div class="form-actions">
2075
+ <button class="btn" onclick="toggleForm('addUcForm-${code}')">Annuler</button>
2076
+ <button class="btn btn-primary" onclick="addUseCase('${code}')">Ajouter</button>
2077
+ </div>
2078
+ </div>
2079
+ </div>
2080
+
2081
+ <!-- TAB: Regles metier -->
2082
+ <div class="tab-panel" id="tab-${code}-br">
2083
+ <p style="font-size:0.85rem;color:var(--text-muted);margin-bottom:1rem;">Les regles que le systeme doit respecter. Formulez-les sous forme de conditions : "Si... alors... sinon..."</p>
2084
+ <div id="brList-${code}">
2085
+ ${spec.businessRules.map((br, i) => renderBusinessRule(code, br, i)).join('')}
2086
+ </div>
2087
+ <button class="add-btn" onclick="toggleForm('addBrForm-${code}')">+ Ajouter une regle metier</button>
2088
+ <div class="inline-form" id="addBrForm-${code}">
2089
+ <div class="inline-form-title">Nouvelle regle metier</div>
2090
+ <div class="form-group">
2091
+ <label class="form-label">Nom court de la regle</label>
2092
+ <input type="text" class="form-input" id="br-name-${code}" placeholder="Exemple : Verification du budget disponible">
2093
+ </div>
2094
+ <div class="form-group">
2095
+ <label class="form-label">Categorie</label>
2096
+ <select class="form-select" id="br-cat-${code}">
2097
+ <option value="validation">Verification (le systeme verifie que...)</option>
2098
+ <option value="calculation">Calcul (le systeme calcule...)</option>
2099
+ <option value="workflow">Processus (quand X se produit, alors...)</option>
2100
+ <option value="security">Securite (seul... peut...)</option>
2101
+ <option value="data">Donnees (les donnees doivent...)</option>
2102
+ </select>
2103
+ </div>
2104
+ <div class="form-group">
2105
+ <label class="form-label">Formulation de la regle (Si... alors... sinon...)</label>
2106
+ <textarea class="form-textarea" id="br-statement-${code}" placeholder="Si le montant de la commande depasse le budget du client, alors la commande est refusee et un message d'erreur s'affiche"></textarea>
2107
+ </div>
2108
+ <div class="form-group">
2109
+ <label class="form-label">Exemple concret (optionnel)</label>
2110
+ <input type="text" class="form-input" id="br-example-${code}" placeholder="Exemple : Commande de 5000 CHF, budget de 2000 CHF → refusee">
2111
+ </div>
2112
+ <div class="form-actions">
2113
+ <button class="btn" onclick="toggleForm('addBrForm-${code}')">Annuler</button>
2114
+ <button class="btn btn-primary" onclick="addBusinessRule('${code}')">Ajouter</button>
2115
+ </div>
2116
+ </div>
2117
+ </div>
2118
+
2119
+ <!-- TAB: Donnees (Entites) -->
2120
+ <div class="tab-panel" id="tab-${code}-ent">
2121
+ <p style="font-size:0.85rem;color:var(--text-muted);margin-bottom:1rem;">Les types de donnees que ce domaine gere. Decrivez les informations importantes a enregistrer pour chaque type.</p>
2122
+ <div id="entList-${code}">
2123
+ ${spec.entities.map((ent, i) => renderEntity(code, ent, i)).join('')}
2124
+ </div>
2125
+ <button class="add-btn" onclick="toggleForm('addEntForm-${code}')">+ Ajouter un type de donnees</button>
2126
+ <div class="inline-form" id="addEntForm-${code}">
2127
+ <div class="inline-form-title">Nouveau type de donnees</div>
2128
+ <div class="form-group">
2129
+ <label class="form-label">Nom (exemple : Commande, Client, Facture)</label>
2130
+ <input type="text" class="form-input" id="ent-name-${code}" placeholder="Nom du type de donnees">
2131
+ </div>
2132
+ <div class="form-group">
2133
+ <label class="form-label">Description : a quoi sert cette donnee ?</label>
2134
+ <textarea class="form-textarea" id="ent-desc-${code}" placeholder="En une ou deux phrases, decrivez ce que represente cette donnee dans votre activite" style="min-height:50px;"></textarea>
2135
+ </div>
2136
+ <div class="form-group">
2137
+ <label class="form-label">Informations a enregistrer (une par ligne : Nom - Description)</label>
2138
+ <textarea class="form-textarea" id="ent-attrs-${code}" placeholder="Numero - Identifiant unique de la commande&#10;Date - Date de creation de la commande&#10;Montant total - Somme des lignes&#10;Statut - Brouillon, Envoyee, Validee, Refusee"></textarea>
2139
+ </div>
2140
+ <div class="form-group">
2141
+ <label class="form-label">Relations avec d'autres donnees (optionnel, une par ligne)</label>
2142
+ <textarea class="form-textarea" id="ent-rels-${code}" placeholder="Client - Chaque commande appartient a un client&#10;Ligne de commande - Une commande contient plusieurs lignes" style="min-height:50px;"></textarea>
2143
+ </div>
2144
+ <div class="form-actions">
2145
+ <button class="btn" onclick="toggleForm('addEntForm-${code}')">Annuler</button>
2146
+ <button class="btn btn-primary" onclick="addEntity('${code}')">Ajouter</button>
2147
+ </div>
2148
+ </div>
2149
+ </div>
2150
+
2151
+ <!-- TAB: Droits d'acces -->
2152
+ <div class="tab-panel" id="tab-${code}-perm">
2153
+ <p style="font-size:0.85rem;color:var(--text-muted);margin-bottom:1rem;">Definissez qui peut faire quoi dans ce domaine. Cochez les actions autorisees pour chaque profil.</p>
2154
+ <div id="permGrid-${code}">
2155
+ ${renderPermissionGrid(code)}
2156
+ </div>
2157
+ </div>
2158
+
2159
+ <!-- TAB: Maquettes -->
2160
+ <div class="tab-panel" id="tab-${code}-mock">
2161
+ <p style="font-size:0.85rem;color:var(--text-muted);margin-bottom:1rem;">Exemples visuels des ecrans principaux de ce domaine. Ces maquettes montrent la disposition generale, pas le design final.</p>
2162
+
2163
+ <div class="mockup-frame">
2164
+ <div class="mockup-toolbar">
2165
+ <div class="mockup-dot mockup-dot-red"></div>
2166
+ <div class="mockup-dot mockup-dot-yellow"></div>
2167
+ <div class="mockup-dot mockup-dot-green"></div>
2168
+ <span class="mockup-title">${mod.name} - Liste</span>
2169
+ </div>
2170
+ <div class="mockup-content">
2171
+ <div class="mock-header">
2172
+ <div class="mock-title">${mod.name}</div>
2173
+ <div class="mock-btn">+ Nouveau</div>
2174
+ </div>
2175
+ <div class="mock-search">Rechercher...</div>
2176
+ <table class="mock-table">
2177
+ <thead><tr>
2178
+ ${(mod.entities || []).slice(0, 1).length > 0 ? '<th>Identifiant</th><th>Nom</th><th>Statut</th><th>Date</th><th>Actions</th>' : '<th>Colonne 1</th><th>Colonne 2</th><th>Statut</th><th>Actions</th>'}
2179
+ </tr></thead>
2180
+ <tbody>
2181
+ <tr><td style="color:var(--primary-light);">001</td><td>Exemple 1</td><td><span class="mock-status mock-status-active">Actif</span></td><td>Aujourd'hui</td><td style="color:var(--text-muted);">Voir | Modifier</td></tr>
2182
+ <tr><td style="color:var(--primary-light);">002</td><td>Exemple 2</td><td><span class="mock-status mock-status-pending">En attente</span></td><td>Hier</td><td style="color:var(--text-muted);">Voir | Modifier</td></tr>
2183
+ <tr><td style="color:var(--primary-light);">003</td><td>Exemple 3</td><td><span class="mock-status mock-status-draft">Brouillon</span></td><td>Il y a 3 jours</td><td style="color:var(--text-muted);">Voir | Modifier</td></tr>
2184
+ </tbody>
2185
+ </table>
2186
+ </div>
2187
+ </div>
2188
+
2189
+ <div class="mockup-frame" style="margin-top:1rem;">
2190
+ <div class="mockup-toolbar">
2191
+ <div class="mockup-dot mockup-dot-red"></div>
2192
+ <div class="mockup-dot mockup-dot-yellow"></div>
2193
+ <div class="mockup-dot mockup-dot-green"></div>
2194
+ <span class="mockup-title">${mod.name} - Formulaire de creation</span>
2195
+ </div>
2196
+ <div class="mockup-content">
2197
+ <div class="mock-header">
2198
+ <div class="mock-title">Nouveau ${(mod.entities || [])[0] || 'enregistrement'}</div>
2199
+ </div>
2200
+ <div class="mock-form-row">
2201
+ <div class="mock-form-group"><div class="mock-label">Identifiant</div><div class="mock-input" style="color:var(--text-muted);">Genere automatiquement</div></div>
2202
+ <div class="mock-form-group"><div class="mock-label">Nom</div><div class="mock-input"></div></div>
2203
+ </div>
2204
+ <div class="mock-form-group"><div class="mock-label">Description</div><div class="mock-input" style="height:60px;"></div></div>
2205
+ <div class="mock-form-actions">
2206
+ <div class="mock-btn" style="background:var(--bg-hover);color:var(--text);">Annuler</div>
2207
+ <div class="mock-btn">Enregistrer</div>
2208
+ </div>
2209
+ </div>
2210
+ </div>
2211
+
2212
+ <div class="card" style="margin-top:1rem;">
2213
+ <div class="card-label">Notes sur les maquettes</div>
2214
+ <div class="editable" contenteditable="true" data-module-code="${code}" data-module-field="mockupNotes" data-placeholder="Ajoutez vos remarques sur les maquettes : elements manquants, disposition souhaitee, comportements particuliers...">${spec.mockupNotes || ''}</div>
2215
+ </div>
2216
+ </div>
2217
+
2218
+ <!-- TAB: Notes -->
2219
+ <div class="tab-panel" id="tab-${code}-notes">
2220
+ <p style="font-size:0.85rem;color:var(--text-muted);margin-bottom:1rem;">Notes libres, questions en suspens, elements a clarifier pour ce domaine.</p>
2221
+ <div class="card">
2222
+ <div class="editable" contenteditable="true" data-module-code="${code}" data-module-field="notes" data-placeholder="Notez ici tout ce qui concerne ce domaine : questions, precisions, contraintes particulieres...">${spec.notes || ''}</div>
2223
+ </div>
2224
+ </div>
2225
+ </div>`;
2226
+ }
2227
+
2228
+ function renderUseCase(code, uc, index) {
2229
+ return `
2230
+ <div class="uc-item">
2231
+ <div class="uc-header">
2232
+ <span class="uc-id">UC-${String(index + 1).padStart(3, '0')}</span>
2233
+ <span class="uc-title">${uc.name}</span>
2234
+ <div class="uc-actions">
2235
+ <button class="btn btn-sm" onclick="removeUseCase('${code}',${index})">Supprimer</button>
2236
+ </div>
2237
+ </div>
2238
+ <div class="uc-actors"><div class="uc-actor">${uc.actor}</div></div>
2239
+ ${uc.steps ? `<div class="uc-detail-label">Deroulement</div><div class="uc-detail">${uc.steps.replace(/\n/g, '<br>')}</div>` : ''}
2240
+ ${uc.alternative ? `<div class="uc-detail-label">En cas de probleme</div><div class="uc-detail" style="color:var(--warning);">${uc.alternative}</div>` : ''}
2241
+ </div>`;
2242
+ }
2243
+
2244
+ function addUseCase(code) {
2245
+ const name = document.getElementById('uc-name-' + code).value.trim();
2246
+ if (!name) return;
2247
+ if (!data.moduleSpecs[code]) data.moduleSpecs[code] = { useCases: [], businessRules: [], entities: [], permissions: [], notes: '' };
2248
+
2249
+ data.moduleSpecs[code].useCases.push({
2250
+ name: name,
2251
+ actor: document.getElementById('uc-actor-' + code).value.trim(),
2252
+ steps: document.getElementById('uc-steps-' + code).value.trim(),
2253
+ alternative: document.getElementById('uc-alt-' + code).value.trim()
2254
+ });
2255
+
2256
+ renderAllModuleSpecs();
2257
+ updateCounts();
2258
+ autoSave();
2259
+ }
2260
+
2261
+ function removeUseCase(code, index) {
2262
+ data.moduleSpecs[code].useCases.splice(index, 1);
2263
+ renderAllModuleSpecs();
2264
+ updateCounts();
2265
+ autoSave();
2266
+ }
2267
+
2268
+ function renderBusinessRule(code, br, index) {
2269
+ const catColors = { validation: 'br-cat-validation', calculation: 'br-cat-calculation', workflow: 'br-cat-workflow', security: 'br-cat-security', data: 'br-cat-data' };
2270
+ const catLabels = { validation: 'Verification', calculation: 'Calcul', workflow: 'Processus', security: 'Securite', data: 'Donnees' };
2271
+ return `
2272
+ <div class="br-item">
2273
+ <span class="br-category ${catColors[br.category] || 'br-cat-validation'}">${catLabels[br.category] || br.category}</span>
2274
+ <div class="br-text">
2275
+ <div style="font-weight:600;color:var(--text-bright);margin-bottom:0.2rem;">${br.name}</div>
2276
+ <div>${br.statement}</div>
2277
+ ${br.example ? `<div style="font-size:0.8rem;color:var(--text-muted);margin-top:0.25rem;font-style:italic;">Exemple : ${br.example}</div>` : ''}
2278
+ </div>
2279
+ <button class="btn btn-sm" onclick="removeBusinessRule('${code}',${index})" style="opacity:0.5;flex-shrink:0;">&#10005;</button>
2280
+ </div>`;
2281
+ }
2282
+
2283
+ function addBusinessRule(code) {
2284
+ const name = document.getElementById('br-name-' + code).value.trim();
2285
+ if (!name) return;
2286
+ if (!data.moduleSpecs[code]) data.moduleSpecs[code] = { useCases: [], businessRules: [], entities: [], permissions: [], notes: '' };
2287
+
2288
+ data.moduleSpecs[code].businessRules.push({
2289
+ name: name,
2290
+ category: document.getElementById('br-cat-' + code).value,
2291
+ statement: document.getElementById('br-statement-' + code).value.trim(),
2292
+ example: document.getElementById('br-example-' + code).value.trim()
2293
+ });
2294
+
2295
+ renderAllModuleSpecs();
2296
+ autoSave();
2297
+ }
2298
+
2299
+ function removeBusinessRule(code, index) {
2300
+ data.moduleSpecs[code].businessRules.splice(index, 1);
2301
+ renderAllModuleSpecs();
2302
+ autoSave();
2303
+ }
2304
+
2305
+ function renderEntity(code, ent, index) {
2306
+ return `
2307
+ <div class="entity-block">
2308
+ <div class="entity-header">
2309
+ <div>
2310
+ <div class="entity-name">${ent.name}</div>
2311
+ <div class="entity-desc">${ent.description || ''}</div>
2312
+ </div>
2313
+ <button class="btn btn-sm" onclick="removeEntity('${code}',${index})" style="opacity:0.5;">Supprimer</button>
2314
+ </div>
2315
+ ${(ent.attributes || []).length > 0 ? `
2316
+ <table class="attr-table">
2317
+ <thead><tr><th>Information</th><th>Description</th></tr></thead>
2318
+ <tbody>
2319
+ ${ent.attributes.map(a => `<tr><td style="font-weight:500;color:var(--text-bright);">${a.name}</td><td>${a.description || ''}</td></tr>`).join('')}
2320
+ </tbody>
2321
+ </table>` : ''}
2322
+ ${(ent.relationships || []).length > 0 ? `
2323
+ <div style="padding:0.5rem 0.75rem;font-size:0.8rem;color:var(--text-muted);border-top:1px solid var(--border);">
2324
+ Relations : ${ent.relationships.map(r => `<span style="color:var(--accent);">${r}</span>`).join(', ')}
2325
+ </div>` : ''}
2326
+ </div>`;
2327
+ }
2328
+
2329
+ function addEntity(code) {
2330
+ const name = document.getElementById('ent-name-' + code).value.trim();
2331
+ if (!name) return;
2332
+ if (!data.moduleSpecs[code]) data.moduleSpecs[code] = { useCases: [], businessRules: [], entities: [], permissions: [], notes: '' };
2333
+
2334
+ const attrs = document.getElementById('ent-attrs-' + code).value.split('\n').filter(l => l.trim()).map(l => {
2335
+ const parts = l.split(' - ');
2336
+ return { name: parts[0]?.trim() || l.trim(), description: parts.slice(1).join(' - ').trim() };
2337
+ });
2338
+ const rels = document.getElementById('ent-rels-' + code).value.split('\n').filter(l => l.trim());
2339
+
2340
+ data.moduleSpecs[code].entities.push({
2341
+ name: name,
2342
+ description: document.getElementById('ent-desc-' + code).value.trim(),
2343
+ attributes: attrs,
2344
+ relationships: rels
2345
+ });
2346
+
2347
+ renderAllModuleSpecs();
2348
+ autoSave();
2349
+ }
2350
+
2351
+ function removeEntity(code, index) {
2352
+ data.moduleSpecs[code].entities.splice(index, 1);
2353
+ renderAllModuleSpecs();
2354
+ autoSave();
2355
+ }
2356
+
2357
+ function renderPermissionGrid(code) {
2358
+ const roles = data.cadrage.stakeholders.length > 0
2359
+ ? data.cadrage.stakeholders.map(s => s.role)
2360
+ : ['Administrateur', 'Responsable', 'Contributeur', 'Lecteur'];
2361
+ const actions = ['Consulter', 'Creer', 'Modifier', 'Supprimer', 'Valider', 'Exporter'];
2362
+
2363
+ const perms = data.moduleSpecs[code]?.permissions || [];
2364
+
2365
+ return `
2366
+ <table class="mock-table" style="background:var(--bg-card);border-radius:8px;overflow:hidden;">
2367
+ <thead><tr>
2368
+ <th>Profil</th>
2369
+ ${actions.map(a => `<th style="text-align:center;">${a}</th>`).join('')}
2370
+ </tr></thead>
2371
+ <tbody>
2372
+ ${roles.map(role => `
2373
+ <tr>
2374
+ <td style="font-weight:500;color:var(--text-bright);">${role}</td>
2375
+ ${actions.map(action => {
2376
+ const key = role + '|' + action;
2377
+ const checked = perms.includes(key);
2378
+ return `<td style="text-align:center;"><input type="checkbox" ${checked ? 'checked' : ''} onchange="togglePermission('${code}','${key}',this.checked)" style="cursor:pointer;width:16px;height:16px;"></td>`;
2379
+ }).join('')}
2380
+ </tr>
2381
+ `).join('')}
2382
+ </tbody>
2383
+ </table>`;
2384
+ }
2385
+
2386
+ function togglePermission(code, key, checked) {
2387
+ if (!data.moduleSpecs[code]) data.moduleSpecs[code] = { useCases: [], businessRules: [], entities: [], permissions: [], notes: '' };
2388
+ if (!data.moduleSpecs[code].permissions) data.moduleSpecs[code].permissions = [];
2389
+ if (checked) {
2390
+ if (!data.moduleSpecs[code].permissions.includes(key)) data.moduleSpecs[code].permissions.push(key);
2391
+ } else {
2392
+ data.moduleSpecs[code].permissions = data.moduleSpecs[code].permissions.filter(p => p !== key);
2393
+ }
2394
+ autoSave();
2395
+ }
2396
+
2397
+ function switchTab(code, tabId) {
2398
+ const section = document.getElementById('module-spec-' + code);
2399
+ if (!section) return;
2400
+ section.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
2401
+ section.querySelectorAll('.tab-panel').forEach(panel => panel.classList.remove('active'));
2402
+ const targetPanel = document.getElementById('tab-' + code + '-' + tabId);
2403
+ if (targetPanel) targetPanel.classList.add('active');
2404
+ // Activate the clicked button
2405
+ const buttons = section.querySelectorAll('.tab-btn');
2406
+ const tabIndex = { uc: 0, br: 1, ent: 2, perm: 3, mock: 4, notes: 5 }[tabId];
2407
+ if (buttons[tabIndex]) buttons[tabIndex].classList.add('active');
2408
+ }
2409
+
2410
+ /* ============================================
2411
+ CONSOLIDATION
2412
+ ============================================ */
2413
+ function renderConsolidation() {
2414
+ renderConsolInteractions();
2415
+ renderConsolPermissions();
2416
+ }
2417
+
2418
+ function renderConsolInteractions() {
2419
+ const container = document.getElementById('consolInteractions');
2420
+ if (!container || data.dependencies.length === 0) return;
2421
+
2422
+ container.innerHTML = data.dependencies.map(d => {
2423
+ const fromName = data.modules.find(m => m.code === d.from)?.name || d.from;
2424
+ const toName = data.modules.find(m => m.code === d.to)?.name || d.to;
2425
+ return `
2426
+ <div class="interaction-item">
2427
+ <span style="font-weight:600;color:var(--text-bright);">${fromName}</span>
2428
+ <span class="interaction-arrow">&#8594;</span>
2429
+ <span style="font-weight:600;color:var(--text-bright);">${toName}</span>
2430
+ <span class="interaction-type">Dependance</span>
2431
+ <span style="flex:1;font-size:0.8rem;color:var(--text-muted);">${d.description || ''}</span>
2432
+ </div>`;
2433
+ }).join('');
2434
+ }
2435
+
2436
+ function renderConsolPermissions() {
2437
+ const container = document.getElementById('consolPermissions');
2438
+ if (!container || data.modules.length === 0) return;
2439
+
2440
+ const roles = data.cadrage.stakeholders.length > 0
2441
+ ? data.cadrage.stakeholders.map(s => s.role)
2442
+ : ['Administrateur', 'Responsable', 'Contributeur', 'Lecteur'];
2443
+
2444
+ let html = '<table class="mock-table" style="background:var(--bg-card);border-radius:8px;overflow:hidden;">';
2445
+ html += '<thead><tr><th>Profil</th>';
2446
+ data.modules.forEach(m => { html += `<th style="text-align:center;">${m.name}</th>`; });
2447
+ html += '</tr></thead><tbody>';
2448
+
2449
+ roles.forEach(role => {
2450
+ html += `<tr><td style="font-weight:500;color:var(--text-bright);">${role}</td>`;
2451
+ data.modules.forEach(m => {
2452
+ const perms = (data.moduleSpecs[m.code]?.permissions || []).filter(p => p.startsWith(role + '|'));
2453
+ const count = perms.length;
2454
+ const color = count > 4 ? 'var(--success)' : count > 2 ? 'var(--warning)' : count > 0 ? 'var(--text-muted)' : 'var(--border)';
2455
+ html += `<td style="text-align:center;color:${color};font-weight:600;">${count > 0 ? count + ' droits' : 'Aucun'}</td>`;
2456
+ });
2457
+ html += '</tr>';
2458
+ });
2459
+
2460
+ html += '</tbody></table>';
2461
+ container.innerHTML = html;
2462
+ }
2463
+
2464
+ /* ============================================
2465
+ E2E FLOWS
2466
+ ============================================ */
2467
+ function addE2EFlow() {
2468
+ const name = document.getElementById('flow-name').value.trim();
2469
+ if (!name) return;
2470
+
2471
+ const steps = document.getElementById('flow-steps').value.split('\n').filter(l => l.trim()).map(l => {
2472
+ const parts = l.split(' - ');
2473
+ return { module: parts[0]?.trim() || '', action: parts.slice(1).join(' - ').trim() || l.trim() };
2474
+ });
2475
+
2476
+ data.consolidation.e2eFlows.push({
2477
+ name: name,
2478
+ steps: steps,
2479
+ actors: document.getElementById('flow-actors').value.trim()
2480
+ });
2481
+
2482
+ renderE2EFlows();
2483
+ toggleForm('addFlowForm');
2484
+ clearForm('addFlowForm');
2485
+ autoSave();
2486
+ }
2487
+
2488
+ function removeE2EFlow(index) {
2489
+ data.consolidation.e2eFlows.splice(index, 1);
2490
+ renderE2EFlows();
2491
+ autoSave();
2492
+ }
2493
+
2494
+ function renderE2EFlows() {
2495
+ const container = document.getElementById('e2eFlowsList');
2496
+ if (!container) return;
2497
+
2498
+ container.innerHTML = data.consolidation.e2eFlows.map((flow, fi) => `
2499
+ <div class="card" style="margin-bottom:1rem;">
2500
+ <div class="card-header">
2501
+ <span class="card-title">${flow.name}</span>
2502
+ <button class="btn btn-sm" onclick="removeE2EFlow(${fi})" style="opacity:0.5;">Supprimer</button>
2503
+ </div>
2504
+ ${flow.actors ? `<div style="font-size:0.8rem;color:var(--text-muted);margin-bottom:0.5rem;">Intervenants : ${flow.actors}</div>` : ''}
2505
+ <div class="e2e-flow">
2506
+ ${flow.steps.map((s, i) => `
2507
+ <div class="e2e-step">
2508
+ <div class="e2e-step-module">${s.module}</div>
2509
+ <div class="e2e-step-action">${s.action}</div>
2510
+ </div>
2511
+ ${i < flow.steps.length - 1 ? '<div class="process-arrow">&#8594;</div>' : ''}
2512
+ `).join('')}
2513
+ </div>
2514
+ </div>
2515
+ `).join('');
2516
+ }
2517
+
2518
+ /* ============================================
2519
+ HANDOFF / SYNTHESE
2520
+ ============================================ */
2521
+ function renderHandoff() {
2522
+ renderHandoffStats();
2523
+ renderHandoffModules();
2524
+ renderCoverageMatrix();
2525
+ }
2526
+
2527
+ function renderHandoffStats() {
2528
+ const container = document.getElementById('handoffStats');
2529
+ if (!container) return;
2530
+
2531
+ const totalUCs = data.modules.reduce((sum, m) => sum + (data.moduleSpecs[m.code]?.useCases || []).length, 0);
2532
+ const totalBRs = data.modules.reduce((sum, m) => sum + (data.moduleSpecs[m.code]?.businessRules || []).length, 0);
2533
+ const totalEnts = data.modules.reduce((sum, m) => sum + (data.moduleSpecs[m.code]?.entities || []).length, 0);
2534
+ const totalStakeholders = data.cadrage.stakeholders.length;
2535
+
2536
+ container.innerHTML = `
2537
+ <div class="stat-card"><div class="stat-value">${data.modules.length}</div><div class="stat-label">Domaines fonctionnels</div></div>
2538
+ <div class="stat-card"><div class="stat-value">${totalUCs}</div><div class="stat-label">Cas d'utilisation</div></div>
2539
+ <div class="stat-card"><div class="stat-value">${totalBRs}</div><div class="stat-label">Regles metier</div></div>
2540
+ <div class="stat-card"><div class="stat-value">${totalEnts}</div><div class="stat-label">Types de donnees</div></div>
2541
+ <div class="stat-card"><div class="stat-value">${totalStakeholders}</div><div class="stat-label">Profils utilisateurs</div></div>
2542
+ <div class="stat-card"><div class="stat-value">${data.dependencies.length}</div><div class="stat-label">Dependances</div></div>
2543
+ <div class="stat-card"><div class="stat-value">${data.consolidation.e2eFlows.length}</div><div class="stat-label">Parcours bout en bout</div></div>
2544
+ <div class="stat-card"><div class="stat-value">${data.cadrage.risks.length}</div><div class="stat-label">Risques identifies</div></div>
2545
+ `;
2546
+ }
2547
+
2548
+ function renderHandoffModules() {
2549
+ const container = document.getElementById('handoffModuleList');
2550
+ if (!container) return;
2551
+
2552
+ const layers = computeTopologicalLayers();
2553
+ const order = layers ? layers.flat() : data.modules.map(m => m.code);
2554
+
2555
+ container.innerHTML = order.map((code, i) => {
2556
+ const m = data.modules.find(mod => mod.code === code);
2557
+ if (!m) return '';
2558
+ const spec = data.moduleSpecs[code] || {};
2559
+ return `
2560
+ <div class="card" style="margin-bottom:0.75rem;">
2561
+ <div style="display:flex;align-items:center;gap:0.75rem;">
2562
+ <div style="width:28px;height:28px;border-radius:50%;background:var(--primary);display:flex;align-items:center;justify-content:center;color:#fff;font-size:0.75rem;font-weight:700;flex-shrink:0;">${i + 1}</div>
2563
+ <div style="flex:1;">
2564
+ <div style="font-weight:600;color:var(--text-bright);">${m.name}</div>
2565
+ <div style="font-size:0.8rem;color:var(--text-muted);">${m.description || ''}</div>
2566
+ </div>
2567
+ <div style="display:flex;gap:1rem;font-size:0.75rem;color:var(--text-muted);">
2568
+ <span>${(spec.useCases || []).length} cas d'utilisation</span>
2569
+ <span>${(spec.businessRules || []).length} regles</span>
2570
+ <span>${(spec.entities || []).length} donnees</span>
2571
+ </div>
2572
+ <span class="priority priority-${m.priority === 'must' ? 'vital' : m.priority === 'should' ? 'important' : 'optional'}">${formatModulePriority(m.priority)}</span>
2573
+ </div>
2574
+ </div>`;
2575
+ }).join('');
2576
+ }
2577
+
2578
+ function renderCoverageMatrix() {
2579
+ const container = document.getElementById('coverageMatrix');
2580
+ if (!container) return;
2581
+
2582
+ const allScope = ['vital', 'important', 'optional'].flatMap(p =>
2583
+ (data.cadrage.scope[p] || []).map(item => ({ ...item, priority: p }))
2584
+ );
2585
+
2586
+ if (allScope.length === 0) {
2587
+ container.innerHTML = '<p style="color:var(--text-muted);font-style:italic;">Aucun element de perimetre defini dans le cadrage.</p>';
2588
+ return;
2589
+ }
2590
+
2591
+ container.innerHTML = `
2592
+ <table class="mock-table" style="background:var(--bg-card);border-radius:8px;overflow:hidden;">
2593
+ <thead><tr><th>Besoin</th><th>Priorite</th><th>Domaine</th><th>Couvert</th></tr></thead>
2594
+ <tbody>
2595
+ ${allScope.map(item => {
2596
+ const moduleName = data.modules.length > 0 ? data.modules[0].name : 'A definir';
2597
+ return `
2598
+ <tr>
2599
+ <td>${item.name}</td>
2600
+ <td><span class="priority priority-${item.priority}">${formatPriority(item.priority)}</span></td>
2601
+ <td style="color:var(--text-muted);">${moduleName}</td>
2602
+ <td style="text-align:center;color:var(--success);">&#10003;</td>
2603
+ </tr>`;
2604
+ }).join('')}
2605
+ </tbody>
2606
+ </table>`;
2607
+ }
2608
+
2609
+ /* ============================================
2610
+ ADDITIONAL UTILITIES
2611
+ ============================================ */
2612
+ function formatModuleType(t) {
2613
+ return { 'data-centric': 'Donnees', 'workflow': 'Processus', 'reporting': 'Rapports', 'integration': 'Integration', 'full-module': 'Complet' }[t] || t;
2614
+ }
2615
+
2616
+ function formatModulePriority(p) {
2617
+ return { must: 'Indispensable', should: 'Important', could: 'Optionnel' }[p] || p;
2618
+ }
2619
+
2620
+ </script>
2621
+ </body>
2622
+ </html>