@tekkare/romulus 0.1.318 → 0.1.320

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.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "0.1.317",
7
+ "version": "0.1.319",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -10,6 +10,11 @@
10
10
  ne bouge qu'en mode edition : en lecture, un glisser sur un graphe ne doit
11
11
  pas deplacer la carte.
12
12
 
13
+ Le tiroir d'ajout ne propose que les entrees qui auront quelque chose a
14
+ montrer (rmAddableWidgets) ; un widget deja pose d'une entree devenue vide
15
+ reste sur la grille, avec sa note. Le menu « Modeles » remplace le tableau
16
+ par un jeu de widgets (`templates`), apres confirmation s'il y en a deja.
17
+
13
18
  Ce que le paquet ne sait pas :
14
19
  - la source de chaque entree (`sourceOf`), que l'app lit ou elle veut
15
20
  (Directus dans les apps OIP) ;
@@ -24,10 +29,12 @@ import { computed, reactive, ref } from 'vue'
24
29
  import { rmGridBottom } from '../utils/dashboardGrid'
25
30
  import {
26
31
  RM_WIDGET_MIN,
32
+ rmAddableWidgets,
27
33
  rmDashboardExportSheets,
28
34
  rmNewWidgetId,
29
35
  rmWidgetKind,
30
36
  type RmDashboardLang,
37
+ type RmDashboardTemplate,
31
38
  type RmDashboardWidget,
32
39
  type RmWidgetContext,
33
40
  type RmWidgetData,
@@ -58,6 +65,8 @@ const props = withDefaults(defineProps<{
58
65
  scopeLabel?: string
59
66
  /** Ce que disent les widgets et l'editeur quand le contexte n'a aucune marque. */
60
67
  noBrandsText?: string
68
+ /** Les jeux de widgets du menu « Modeles ». Vide : pas de menu. */
69
+ templates?: RmDashboardTemplate[]
61
70
  }>(), {
62
71
  loading: false,
63
72
  failed: false,
@@ -70,6 +79,7 @@ const props = withDefaults(defineProps<{
70
79
  emptyText: undefined,
71
80
  scopeLabel: undefined,
72
81
  noBrandsText: undefined,
82
+ templates: () => [],
73
83
  })
74
84
 
75
85
  const emit = defineEmits<{
@@ -97,6 +107,13 @@ const T = computed(() => props.lang === 'en'
97
107
  loadFailed: 'The dashboard could not be loaded.',
98
108
  emptyTitle: 'An empty dashboard',
99
109
  emptyText: 'Add charts, tables or key figures from the catalogue.',
110
+ templates: 'Templates',
111
+ templatesLabel: 'Dashboard templates',
112
+ replaceTitle: 'Replace the dashboard?',
113
+ replaceText: (n: number) => `The ${n} current widget${n > 1 ? 's' : ''} will be replaced by the template.`,
114
+ replace: 'Replace',
115
+ cancel: 'Cancel',
116
+ templateEmpty: 'This template has nothing to put here.',
100
117
  }
101
118
  : {
102
119
  notSaved: 'Non enregistré.',
@@ -109,6 +126,13 @@ const T = computed(() => props.lang === 'en'
109
126
  loadFailed: 'Le tableau de bord n\'a pas pu être chargé.',
110
127
  emptyTitle: 'Un tableau de bord vide',
111
128
  emptyText: 'Ajoutez des graphiques, des tableaux ou des chiffres clés tirés du catalogue.',
129
+ templates: 'Modèles',
130
+ templatesLabel: 'Modèles de tableau de bord',
131
+ replaceTitle: 'Remplacer le tableau de bord ?',
132
+ replaceText: (n: number) => `${n > 1 ? `Les ${n} widgets en place seront remplacés` : 'Le widget en place sera remplacé'} par le modèle.`,
133
+ replace: 'Remplacer',
134
+ cancel: 'Annuler',
135
+ templateEmpty: 'Ce modèle n\'a rien à poser ici.',
112
136
  })
113
137
 
114
138
  /** Tete (titre, contexte) et pied (source) de la carte, autour du graphe. */
@@ -147,6 +171,67 @@ function move(next: { id: string, x: number, y: number, w: number, h: number }[]
147
171
  const editorOpen = ref(false)
148
172
  const editedId = ref('')
149
173
 
174
+ /**
175
+ * Le catalogue du tiroir : les entrees qui auront quelque chose a montrer,
176
+ * plus celle du widget qu'on regle, meme devenue vide, pour que ses reglages
177
+ * s'ouvrent encore.
178
+ */
179
+ const addable = computed(() => {
180
+ const list = rmAddableWidgets(props.catalog, props.context)
181
+ const edited = editedId.value ? byId.value[editedId.value] : undefined
182
+ const kept = edited ? props.catalog.find(e => e.kind === edited.kind) : undefined
183
+ return kept && !list.includes(kept) ? [...list, kept] : list
184
+ })
185
+
186
+ // --- Modeles ------------------------------------------------------------------
187
+
188
+ const templatesOpen = ref(false)
189
+ const templatesAnchor = ref<HTMLElement | null>(null)
190
+ const templateBusy = ref('')
191
+ const templateNote = ref('')
192
+ /** Le modele choisi, en attente de confirmation parce que la grille n'est pas vide. */
193
+ const pendingTemplate = ref<RmDashboardTemplate | null>(null)
194
+
195
+ const templateGroups = computed(() => {
196
+ const out: { label: string, entries: RmDashboardTemplate[] }[] = []
197
+ for (const entry of props.templates) {
198
+ const label = entry.group ?? T.value.templates
199
+ let group = out.find(g => g.label === label)
200
+ if (!group) out.push((group = { label, entries: [] }))
201
+ group.entries.push(entry)
202
+ }
203
+ return out
204
+ })
205
+
206
+ function pickTemplate(template: RmDashboardTemplate) {
207
+ templateNote.value = ''
208
+ if (props.widgets.length) {
209
+ pendingTemplate.value = template
210
+ templatesOpen.value = false
211
+ return
212
+ }
213
+ applyTemplate(template)
214
+ }
215
+
216
+ async function applyTemplate(template: RmDashboardTemplate) {
217
+ pendingTemplate.value = null
218
+ templateBusy.value = template.id
219
+ try {
220
+ const widgets = await template.widgets()
221
+ if (!widgets?.length) {
222
+ templateNote.value = T.value.templateEmpty
223
+ return
224
+ }
225
+ // Des identifiants neufs : le tableau copie d'un autre projet garde les siens.
226
+ emit('update:widgets', widgets.map(w => ({ ...w, id: rmNewWidgetId() })))
227
+ for (const id of Object.keys(loaded)) delete loaded[id]
228
+ templatesOpen.value = false
229
+ }
230
+ finally {
231
+ templateBusy.value = ''
232
+ }
233
+ }
234
+
150
235
  function openAdd() {
151
236
  editedId.value = ''
152
237
  editorOpen.value = true
@@ -204,6 +289,11 @@ defineExpose({
204
289
  <template v-else-if="editing">{{ T.editingHint }}</template>
205
290
  </p>
206
291
  <div class="rm-dashboard__actions">
292
+ <span v-if="templates.length" ref="templatesAnchor">
293
+ <RmButton variant="tertiary" prefix-icon="Layout" suffix-icon="CaretDown" :disabled="loading || failed" @click="templatesOpen = !templatesOpen">
294
+ {{ T.templates }}
295
+ </RmButton>
296
+ </span>
207
297
  <RmButton variant="tertiary" prefix-icon="Plus" :disabled="loading || failed" @click="openAdd">
208
298
  {{ T.add }}
209
299
  </RmButton>
@@ -267,10 +357,43 @@ defineExpose({
267
357
  </template>
268
358
  </RmDashboardGrid>
269
359
 
360
+ <RmPopover v-if="templates.length" v-model="templatesOpen" :anchor="templatesAnchor" :label="T.templatesLabel" width="320px" align="end">
361
+ <div class="rm-dashboard__templates">
362
+ <section v-for="group in templateGroups" :key="group.label" class="rm-dashboard__template-group">
363
+ <p class="rm-dashboard__template-label">{{ group.label }}</p>
364
+ <button
365
+ v-for="item in group.entries"
366
+ :key="item.id"
367
+ type="button"
368
+ class="rm-dashboard__template"
369
+ :disabled="!!templateBusy"
370
+ @click="pickTemplate(item)"
371
+ >
372
+ <span class="rm-dashboard__template-title">{{ item.title }}</span>
373
+ <span v-if="item.description" class="rm-dashboard__template-desc">{{ item.description }}</span>
374
+ </button>
375
+ </section>
376
+ <p v-if="templateNote" class="rm-dashboard__template-note">{{ templateNote }}</p>
377
+ </div>
378
+ </RmPopover>
379
+
380
+ <RmModal :model-value="!!pendingTemplate" size="sm" mode="free" :label="T.replaceTitle" @update:model-value="pendingTemplate = null">
381
+ <template #header>
382
+ <p class="rm-dashboard__confirm-title">{{ T.replaceTitle }}</p>
383
+ </template>
384
+ <p class="rm-dashboard__confirm-text">{{ T.replaceText(widgets.length) }}</p>
385
+ <template #footer>
386
+ <div class="rm-dashboard__confirm-actions">
387
+ <RmButton variant="tertiary" @click="pendingTemplate = null">{{ T.cancel }}</RmButton>
388
+ <RmButton variant="primary" :loading="!!templateBusy" @click="pendingTemplate && applyTemplate(pendingTemplate)">{{ T.replace }}</RmButton>
389
+ </div>
390
+ </template>
391
+ </RmModal>
392
+
270
393
  <RmDashboardWidgetEditor
271
394
  v-model="editorOpen"
272
395
  :widget="editedId ? byId[editedId] ?? null : null"
273
- :catalog="catalog"
396
+ :catalog="addable"
274
397
  :context="context"
275
398
  :source-of="sourceOf"
276
399
  :lang="lang"
@@ -286,5 +409,5 @@ defineExpose({
286
409
  </template>
287
410
 
288
411
  <style scoped>
289
- .rm-dashboard{display:flex;flex-direction:column;gap:16px}.rm-dashboard__bar{align-items:center;display:flex;flex-wrap:wrap;gap:12px;justify-content:space-between}.rm-dashboard__status{align-items:center;color:var(--text-secondary);display:inline-flex;font-size:.8125rem;gap:4px;margin:0;min-height:1.25rem}.rm-dashboard__actions{display:flex;gap:8px;margin-left:auto}.rm-dashboard__link{background:none;color:var(--color-primary);cursor:pointer;padding:0;text-decoration:underline}
412
+ .rm-dashboard{display:flex;flex-direction:column;gap:16px}.rm-dashboard__bar{align-items:center;display:flex;flex-wrap:wrap;gap:12px;justify-content:space-between}.rm-dashboard__status{align-items:center;color:var(--text-secondary);display:inline-flex;font-size:.8125rem;gap:4px;margin:0;min-height:1.25rem}.rm-dashboard__actions{display:flex;gap:8px;margin-left:auto}.rm-dashboard__link{background:none;color:var(--color-primary);cursor:pointer;padding:0;text-decoration:underline}.rm-dashboard__templates{display:flex;flex-direction:column;gap:12px;padding:4px}.rm-dashboard__template-group{display:flex;flex-direction:column;gap:6px}.rm-dashboard__template-label{color:var(--text-muted);font-size:var(--font-11);font-weight:var(--weight-semibold);letter-spacing:.06em;margin:0 4px;text-transform:uppercase}.rm-dashboard__template{background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-md);color:var(--text-primary);cursor:pointer;display:flex;flex-direction:column;gap:2px;padding:10px 12px;text-align:left;transition:border-color var(--duration-fast) var(--ease-out),box-shadow var(--duration-fast) var(--ease-out);width:100%}.rm-dashboard__template:hover:not(:disabled){border-color:var(--border-default);box-shadow:var(--shadow-xs)}.rm-dashboard__template:focus-visible{box-shadow:var(--shadow-focus);outline:none}.rm-dashboard__template:disabled{cursor:default;opacity:.6}.rm-dashboard__template-title{font-size:var(--font-13);font-weight:var(--weight-semibold);line-height:18px}.rm-dashboard__template-desc{color:var(--text-secondary);font-size:var(--font-12);line-height:16px}.rm-dashboard__template-note{color:var(--text-secondary);font-size:var(--font-12);margin:0 4px}.rm-dashboard__confirm-title{font-size:var(--font-15,15px);font-weight:var(--weight-bold);margin:0}.rm-dashboard__confirm-text{color:var(--text-secondary);font-size:var(--font-13);margin:0}.rm-dashboard__confirm-actions{display:flex;gap:8px;justify-content:flex-end}
290
413
  </style>
@@ -151,8 +151,17 @@ async function run() {
151
151
  }
152
152
  }
153
153
 
154
+ // Une seule chaine : un tableau neuf a chaque lecture relancerait le widget
155
+ // des qu'une dependance bouge sans changer (les lignes du projet recalculees
156
+ // au changement d'onglet, par exemple).
154
157
  watch(
155
- () => [props.widget.kind, JSON.stringify(params.value), brands.value.join('|'), props.lang, JSON.stringify(props.context)],
158
+ () => [
159
+ props.widget.kind,
160
+ JSON.stringify(params.value),
161
+ brands.value.join('|'),
162
+ props.lang,
163
+ JSON.stringify(props.kind.deps ? props.kind.deps(props.context) : props.context),
164
+ ].join('\u0001'),
156
165
  run,
157
166
  { immediate: true },
158
167
  )
@@ -6,7 +6,9 @@
6
6
  ecrivent, et les rangees que l'app deduit de ses ressources : marques,
7
7
  maladies, pays...) avec les informations du projet en pied ; a droite les
8
8
  facons d'avancer (`steps`, un lien par onglet) et la repartition par
9
- famille ; en bas, les derniers ajouts.
9
+ famille, avec un apercu du tableau de bord (`dashboard` : ses chiffres
10
+ cles ou ses premiers widgets, et le lien vers l'onglet) ; en bas, les
11
+ derniers ajouts.
10
12
 
11
13
  La description s'edite sur place : `describe` part avec le texte, l'app
12
14
  l'enregistre et repasse `saving` a faux. Sans `saveError`, l'editeur se
@@ -33,6 +35,12 @@ const props = withDefaults(
33
35
  documentsCount?: number | null
34
36
  scopeRows?: RmProjectScopeRow[]
35
37
  steps?: RmProjectStep[]
38
+ /**
39
+ * L'apercu du tableau de bord : combien de widgets, et un ou deux
40
+ * chiffres cles (ou, a defaut, les titres des premiers widgets).
41
+ * `null` : pas encore lu, la carte attend ; absent : pas de carte.
42
+ */
43
+ dashboard?: { count: number, figures: { label: string, value: string | number }[] } | null
36
44
  /** Le lecteur peut modifier la description. */
37
45
  editable?: boolean
38
46
  loading?: boolean
@@ -47,6 +55,7 @@ const props = withDefaults(
47
55
  documentsCount: null,
48
56
  scopeRows: () => [],
49
57
  steps: () => [],
58
+ dashboard: undefined,
50
59
  editable: true,
51
60
  loading: false,
52
61
  saving: false,
@@ -74,6 +83,8 @@ const WORDS = {
74
83
  breakdown: 'Répartition par famille', nothing: 'Rien n\'est encore rangé.',
75
84
  latest: 'Derniers ajouts', all: 'Toutes les ressources', unknown: 'Élément inconnu',
76
85
  empty: 'Parcourez les pages et utilisez le bouton Projet d\'une carte pour la ranger ici.',
86
+ dashboard: 'Tableau de bord', widgets: (n: number) => `${n} widget${n > 1 ? 's' : ''}`, noWidgets: 'Aucun widget pour l\'instant.',
87
+ openDashboard: 'Ouvrir',
77
88
  },
78
89
  en: {
79
90
  resources: 'Resources', families: 'Families', documents: 'Documents', comments: 'Comments',
@@ -86,6 +97,8 @@ const WORDS = {
86
97
  breakdown: 'Breakdown by family', nothing: 'Nothing filed yet.',
87
98
  latest: 'Latest additions', all: 'All resources', unknown: 'Unknown item',
88
99
  empty: 'Browse the pages and use the Project button on a card to file it here.',
100
+ dashboard: 'Dashboard', widgets: (n: number) => `${n} widget${n > 1 ? 's' : ''}`, noWidgets: 'No widget yet.',
101
+ openDashboard: 'Open',
89
102
  },
90
103
  }
91
104
  const T = computed(() => WORDS[props.lang] ?? WORDS.fr)
@@ -267,6 +280,27 @@ function onLatest(event: MouseEvent, row: RmProjectResource) {
267
280
  </ol>
268
281
  </RmCard>
269
282
 
283
+ <RmSectionCard v-if="dashboard !== undefined" class="rm-project-ov__card">
284
+ <template #header>
285
+ <div class="rm-project-ov__head">
286
+ <span>{{ T.dashboard }}</span>
287
+ <RmButton variant="text" size="sm" suffix-icon="ArrowRight" @click="emit('tab', 'dashboard')">
288
+ {{ T.openDashboard }}
289
+ </RmButton>
290
+ </div>
291
+ </template>
292
+ <RmSkeleton v-if="dashboard === null" width="100%" :height="56" radius="8px" />
293
+ <template v-else>
294
+ <p class="rm-project-ov__context">{{ dashboard.count ? T.widgets(dashboard.count) : T.noWidgets }}</p>
295
+ <dl v-if="dashboard.figures.length" class="rm-project-ov__figures">
296
+ <div v-for="figure in dashboard.figures" :key="figure.label" class="rm-project-ov__figure">
297
+ <dt>{{ figure.label }}</dt>
298
+ <dd>{{ typeof figure.value === 'number' ? figure.value.toLocaleString(lang === 'en' ? 'en-GB' : 'fr-FR') : figure.value }}</dd>
299
+ </div>
300
+ </dl>
301
+ </template>
302
+ </RmSectionCard>
303
+
270
304
  <RmSectionCard class="rm-project-ov__card">
271
305
  <template #header>{{ T.breakdown }}</template>
272
306
  <RmDonutChart v-if="breakdown.length" :data="breakdown" :height="240" hide-legend />
@@ -299,5 +333,5 @@ function onLatest(event: MouseEvent, row: RmProjectResource) {
299
333
  </template>
300
334
 
301
335
  <style scoped>
302
- .rm-project-ov{display:flex;flex-direction:column;gap:16px}.rm-project-ov__top{align-items:stretch;display:grid;gap:16px;grid-template-columns:minmax(0,3fr) minmax(0,2fr)}@media (max-width:1100px){.rm-project-ov__top{grid-template-columns:1fr}}.rm-project-ov__card{min-width:0}.rm-project-ov__card.is-scope,.rm-project-ov__card.is-scope :deep(.r-card__body){display:flex;flex-direction:column}.rm-project-ov__card.is-scope{height:100%}.rm-project-ov__card.is-scope :deep(.r-card__body){flex:1}.rm-project-ov__card-head{align-items:flex-start;display:flex;gap:12px;justify-content:space-between}.rm-project-ov__titles{display:flex;flex-direction:column;gap:4px;margin-bottom:12px}.rm-project-ov__title{color:var(--text-primary);font-size:15px;font-weight:var(--weight-bold);margin:0}.rm-project-ov__context{color:var(--text-muted);font-size:12px;margin:0}.rm-project-ov__scope{display:flex;flex-direction:column;list-style:none;margin:0 0 16px;padding:0}.rm-project-ov__scope-row{align-items:flex-start;border-bottom:1px solid var(--border-soft,var(--border-default));display:flex;gap:12px;padding:8px 0}.rm-project-ov__scope-icon{color:var(--color-secondary);flex:none;margin-top:1px}.rm-project-ov__scope-body{flex:1;min-width:0}.rm-project-ov__scope-key{color:var(--text-muted);font-size:10.5px;font-weight:700;letter-spacing:.08em;margin:0 0 4px;text-transform:uppercase}.rm-project-ov__scope-value{color:var(--text-primary);font-size:13px;font-weight:600;margin:0;white-space:pre-line}.rm-project-ov__tags{display:flex;flex-wrap:wrap;gap:6px}.rm-project-ov__tag{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rm-project-ov__scope-none{color:var(--text-muted);font-size:13px;font-style:italic;margin:0}.rm-project-ov__more{font-size:13px;margin:0;padding-left:16px}.rm-project-ov__placeholder{background:none;border:none;color:var(--text-muted);cursor:pointer;font:inherit;font-size:13px;font-style:italic;margin:0;padding:0}.rm-project-ov__placeholder:hover{text-decoration:underline}.rm-project-ov__edit-actions{display:flex;gap:8px;justify-content:flex-end;margin:8px 0 12px}.rm-project-ov__meta{border-top:1px solid var(--border-default);display:grid;gap:12px;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));margin:auto 0 0;padding-top:16px}.rm-project-ov__meta dt{color:var(--text-secondary);font-size:12px}.rm-project-ov__meta dd{font-size:14px;font-weight:500;margin:2px 0 0}.rm-project-ov__side{display:flex;flex-direction:column;gap:16px;min-width:0}.rm-project-ov__side>:last-child{flex:1}.rm-project-ov__start{display:flex;flex-direction:column;gap:8px;list-style:none;margin:0;padding:0}.rm-project-ov__start-item{align-items:center;background:var(--bg-surface);border:1px solid var(--border-default);border-radius:var(--radius-xl,12px);color:inherit;cursor:pointer;display:flex;font:inherit;gap:12px;padding:10px 12px;text-align:left;transition:border-color .15s,background .15s,box-shadow .15s;width:100%}.rm-project-ov__start-item:hover{background:var(--bg-hover,var(--bg-surface-2));border-color:var(--color-secondary);box-shadow:var(--shadow-sm)}.rm-project-ov__start-item:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.rm-project-ov__start-icon{align-items:center;background:var(--bg-hover,var(--bg-surface-2));border-radius:var(--radius-lg,8px);color:var(--color-secondary);display:flex;flex:none;height:34px;justify-content:center;width:34px}.rm-project-ov__start-text{display:flex;flex:1;flex-direction:column;gap:2px;min-width:0}.rm-project-ov__start-title{color:var(--text-primary);font-size:13px;font-weight:700}.rm-project-ov__start-desc{color:var(--text-muted);font-size:11px;line-height:1.45}.rm-project-ov__start-arrow{color:var(--text-muted);flex:none}.rm-project-ov__start-item.is-disabled{cursor:not-allowed;opacity:.55}.rm-project-ov__start-item.is-disabled:hover{background:var(--bg-surface);border-color:var(--border-default);box-shadow:none}.rm-project-ov__start-tag{border:1px solid;border-radius:var(--radius-pill);color:var(--text-muted);display:inline-block;font-size:10px;font-weight:600;letter-spacing:.02em;margin-left:6px;padding:0 6px;vertical-align:1px}.rm-project-ov__head{align-items:center;display:flex;justify-content:space-between;width:100%}.rm-project-ov__empty{color:var(--text-secondary);font-size:14px;margin:0}.rm-project-ov__list{display:flex;flex-direction:column;list-style:none;margin:0;padding:0}.rm-project-ov__row{align-items:center;border-bottom:1px solid var(--border-default);display:flex;font-size:14px;gap:10px;padding:8px 0}.rm-project-ov__row:last-child{border-bottom:none}.rm-project-ov__row-icon{color:var(--text-secondary);flex:none}.rm-project-ov__row-title{color:var(--text-primary);flex:1;min-width:0;overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:nowrap}a.rm-project-ov__row-title{color:var(--color-primary)}a.rm-project-ov__row-title:hover{text-decoration:underline}.rm-project-ov__row-date,.rm-project-ov__row-family{color:var(--text-muted);flex:none;font-size:12px}
336
+ .rm-project-ov{display:flex;flex-direction:column;gap:16px}.rm-project-ov__top{align-items:stretch;display:grid;gap:16px;grid-template-columns:minmax(0,3fr) minmax(0,2fr)}@media (max-width:1100px){.rm-project-ov__top{grid-template-columns:1fr}}.rm-project-ov__card{min-width:0}.rm-project-ov__card.is-scope,.rm-project-ov__card.is-scope :deep(.r-card__body){display:flex;flex-direction:column}.rm-project-ov__card.is-scope{height:100%}.rm-project-ov__card.is-scope :deep(.r-card__body){flex:1}.rm-project-ov__card-head{align-items:flex-start;display:flex;gap:12px;justify-content:space-between}.rm-project-ov__titles{display:flex;flex-direction:column;gap:4px;margin-bottom:12px}.rm-project-ov__title{color:var(--text-primary);font-size:15px;font-weight:var(--weight-bold);margin:0}.rm-project-ov__context{color:var(--text-muted);font-size:12px;margin:0}.rm-project-ov__scope{display:flex;flex-direction:column;list-style:none;margin:0 0 16px;padding:0}.rm-project-ov__scope-row{align-items:flex-start;border-bottom:1px solid var(--border-soft,var(--border-default));display:flex;gap:12px;padding:8px 0}.rm-project-ov__scope-icon{color:var(--color-secondary);flex:none;margin-top:1px}.rm-project-ov__scope-body{flex:1;min-width:0}.rm-project-ov__scope-key{color:var(--text-muted);font-size:10.5px;font-weight:700;letter-spacing:.08em;margin:0 0 4px;text-transform:uppercase}.rm-project-ov__scope-value{color:var(--text-primary);font-size:13px;font-weight:600;margin:0;white-space:pre-line}.rm-project-ov__tags{display:flex;flex-wrap:wrap;gap:6px}.rm-project-ov__tag{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rm-project-ov__scope-none{color:var(--text-muted);font-size:13px;font-style:italic;margin:0}.rm-project-ov__more{font-size:13px;margin:0;padding-left:16px}.rm-project-ov__placeholder{background:none;border:none;color:var(--text-muted);cursor:pointer;font:inherit;font-size:13px;font-style:italic;margin:0;padding:0}.rm-project-ov__placeholder:hover{text-decoration:underline}.rm-project-ov__edit-actions{display:flex;gap:8px;justify-content:flex-end;margin:8px 0 12px}.rm-project-ov__meta{border-top:1px solid var(--border-default);display:grid;gap:12px;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));margin:auto 0 0;padding-top:16px}.rm-project-ov__meta dt{color:var(--text-secondary);font-size:12px}.rm-project-ov__meta dd{font-size:14px;font-weight:500;margin:2px 0 0}.rm-project-ov__side{display:flex;flex-direction:column;gap:16px;min-width:0}.rm-project-ov__side>:last-child{flex:1}.rm-project-ov__start{display:flex;flex-direction:column;gap:8px;list-style:none;margin:0;padding:0}.rm-project-ov__start-item{align-items:center;background:var(--bg-surface);border:1px solid var(--border-default);border-radius:var(--radius-xl,12px);color:inherit;cursor:pointer;display:flex;font:inherit;gap:12px;padding:10px 12px;text-align:left;transition:border-color .15s,background .15s,box-shadow .15s;width:100%}.rm-project-ov__start-item:hover{background:var(--bg-hover,var(--bg-surface-2));border-color:var(--color-secondary);box-shadow:var(--shadow-sm)}.rm-project-ov__start-item:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}.rm-project-ov__start-icon{align-items:center;background:var(--bg-hover,var(--bg-surface-2));border-radius:var(--radius-lg,8px);color:var(--color-secondary);display:flex;flex:none;height:34px;justify-content:center;width:34px}.rm-project-ov__start-text{display:flex;flex:1;flex-direction:column;gap:2px;min-width:0}.rm-project-ov__start-title{color:var(--text-primary);font-size:13px;font-weight:700}.rm-project-ov__start-desc{color:var(--text-muted);font-size:11px;line-height:1.45}.rm-project-ov__start-arrow{color:var(--text-muted);flex:none}.rm-project-ov__start-item.is-disabled{cursor:not-allowed;opacity:.55}.rm-project-ov__start-item.is-disabled:hover{background:var(--bg-surface);border-color:var(--border-default);box-shadow:none}.rm-project-ov__start-tag{border:1px solid;border-radius:var(--radius-pill);color:var(--text-muted);display:inline-block;font-size:10px;font-weight:600;letter-spacing:.02em;margin-left:6px;padding:0 6px;vertical-align:1px}.rm-project-ov__head{align-items:center;display:flex;justify-content:space-between;width:100%}.rm-project-ov__empty{color:var(--text-secondary);font-size:14px;margin:0}.rm-project-ov__figures{display:grid;gap:12px;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));margin:12px 0 0}.rm-project-ov__figure dt{color:var(--text-muted);font-size:12px}.rm-project-ov__figure dd{color:var(--text-primary);font-size:20px;font-weight:var(--weight-bold);line-height:1.2;margin:2px 0 0}.rm-project-ov__list{display:flex;flex-direction:column;list-style:none;margin:0;padding:0}.rm-project-ov__row{align-items:center;border-bottom:1px solid var(--border-default);display:flex;font-size:14px;gap:10px;padding:8px 0}.rm-project-ov__row:last-child{border-bottom:none}.rm-project-ov__row-icon{color:var(--text-secondary);flex:none}.rm-project-ov__row-title{color:var(--text-primary);flex:1;min-width:0;overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:nowrap}a.rm-project-ov__row-title{color:var(--color-primary)}a.rm-project-ov__row-title:hover{text-decoration:underline}.rm-project-ov__row-date,.rm-project-ov__row-family{color:var(--text-muted);flex:none;font-size:12px}
303
337
  </style>
@@ -1,7 +1,17 @@
1
1
  import { computed, onBeforeUnmount, ref, unref } from "vue";
2
2
  export function useRmDashboard(options) {
3
3
  const stored = ref(null);
4
- const fallback = computed(() => options.defaults());
4
+ let lastFallback = null;
5
+ const fallback = computed(() => {
6
+ const next = options.defaults();
7
+ const previous = lastFallback;
8
+ const widgets2 = next.widgets.map((widget, index) => {
9
+ const before = previous?.widgets[index];
10
+ return before && before.kind === widget.kind ? { ...widget, id: before.id } : widget;
11
+ });
12
+ lastFallback = { ...next, widgets: widgets2 };
13
+ return lastFallback;
14
+ });
5
15
  const loading = ref(true);
6
16
  const failed = ref(false);
7
17
  const saving = ref(false);
@@ -133,6 +133,18 @@ export interface RmWidgetKind<C extends RmWidgetContext = RmWidgetContext> {
133
133
  viz: RmDashboardViz[];
134
134
  /** Le widget lit les marques : il propose le choix des marques. */
135
135
  usesBrands: boolean;
136
+ /**
137
+ * Le widget aura-t-il quelque chose a montrer pour ce contexte ? Faux :
138
+ * l'entree est cachee du catalogue (un projet sans cancer, sans pays...).
139
+ * Un widget `usesBrands` sans marque l'est deja, sans rien declarer.
140
+ */
141
+ available?: (context: C) => boolean;
142
+ /**
143
+ * La part du contexte que le widget lit (ses lignes, son Inbox...) : il ne
144
+ * se recharge que quand elle change. Absent : tout le contexte, et un
145
+ * widget se recharge des qu'une autre part bouge.
146
+ */
147
+ deps?: (context: C) => unknown;
136
148
  params: RmWidgetParam[];
137
149
  /** Taille de depart dans la grille de 12 colonnes. */
138
150
  size: {
@@ -152,6 +164,27 @@ export interface RmWidgetSource {
152
164
  verified: string | Date | number;
153
165
  export?: RmExportSource[];
154
166
  }
167
+ /**
168
+ * Un modele de tableau : un jeu de widgets a poser d'un coup, propose dans
169
+ * le menu « Modeles » de RmDashboard a la place du tableau en place. Les
170
+ * widgets se calculent a l'appel (le contexte a pu changer), et peuvent
171
+ * venir de loin (le tableau d'un autre projet) : `null` quand il n'y a rien.
172
+ */
173
+ export interface RmDashboardTemplate {
174
+ id: string;
175
+ title: string;
176
+ description?: string;
177
+ /** Groupe du menu (« Modeles », « Copier depuis un projet »). */
178
+ group?: string;
179
+ widgets: () => RmDashboardWidget[] | null | Promise<RmDashboardWidget[] | null>;
180
+ }
181
+ /**
182
+ * Les entrees du catalogue qu'on peut ajouter dans ce contexte : celles qui
183
+ * auront quelque chose a montrer. Un widget `usesBrands` sans marque et une
184
+ * entree dont `available` dit non sont cachees, pas grisees : une entree
185
+ * qui ne rend rien n'a rien a faire dans le tiroir.
186
+ */
187
+ export declare function rmAddableWidgets<C extends RmWidgetContext>(catalog: RmWidgetKind<C>[], context: C): RmWidgetKind<C>[];
155
188
  export declare const RM_VIZ_LABELS: Record<RmDashboardViz, Record<RmDashboardLang, string>>;
156
189
  /** L'icone d'une visualisation, pour le catalogue. */
157
190
  export declare const RM_VIZ_ICONS: Record<RmDashboardViz, string>;
@@ -1,3 +1,9 @@
1
+ export function rmAddableWidgets(catalog, context) {
2
+ return catalog.filter((entry) => {
3
+ if (entry.usesBrands && !context.brands.length) return false;
4
+ return entry.available ? entry.available(context) : true;
5
+ });
6
+ }
1
7
  export const RM_VIZ_LABELS = {
2
8
  line: { fr: "Courbe", en: "Line" },
3
9
  bar: { fr: "Barres", en: "Bars" },
@@ -0,0 +1,98 @@
1
+ <!--
2
+ Carte d'une autorisation oncologique rangee depuis Global Oncology
3
+ (EmaApproval, FdaApproval, PmdaApproval, MpdsApproval, MhraApproval), par
4
+ son `_id` : agence, produit, molecule, laboratoire, date, cancers tagues.
5
+ Global Oncology n'a pas de fiche a onglets pour ces familles : la carte
6
+ reprend les champs de ses cartes de resultat.
7
+
8
+ Montee par le tiroir des projets ; le lien vers l'app passe par le slot
9
+ `title-link`.
10
+ -->
11
+ <template>
12
+ <div class="oip-onco">
13
+ <RmPageHeader :eyebrow="agency">
14
+ <template #title>
15
+ <span class="oip-onco__title">{{ title }}</span>
16
+ <slot name="title-link" />
17
+ </template>
18
+ </RmPageHeader>
19
+
20
+ <div class="oip-onco__body">
21
+ <RmLoadingState v-if="loading" spinner />
22
+ <RmEmptyState v-else-if="!doc" icon="Prohibit" :title="en ? 'Approval not found' : 'Autorisation introuvable'" />
23
+ <RmCard v-else padding="md">
24
+ <dl class="oip-onco__rows">
25
+ <template v-for="row in rows" :key="row.label">
26
+ <dt>{{ row.label }}</dt>
27
+ <dd>{{ row.value }}</dd>
28
+ </template>
29
+ </dl>
30
+ </RmCard>
31
+ </div>
32
+ </div>
33
+ </template>
34
+
35
+ <script setup lang="ts">
36
+ import { oipEsGet } from "../../composables/useOipResources";
37
+ import { ONCOLOGY_AGENCY, ONCOLOGY_PROJECT_KINDS, oncologyRows } from "../../oip-oncology/kinds";
38
+
39
+ const props = withDefaults(
40
+ defineProps<{
41
+ /** Le `resourceId` : `_id` du document dans l'index de la famille. */
42
+ id: string;
43
+ /** La famille (cle du registre de l'API). */
44
+ type: string;
45
+ lang?: "fr" | "en";
46
+ highlight?: string[];
47
+ }>(),
48
+ { lang: "fr", highlight: () => [] },
49
+ );
50
+
51
+ const en = computed(() => props.lang === "en");
52
+ const kind = computed(() => ONCOLOGY_PROJECT_KINDS.find((entry) => entry.type === props.type));
53
+ const agency = computed(() => ONCOLOGY_AGENCY[props.type]?.[props.lang] ?? "");
54
+ const loading = ref(true);
55
+ const doc = ref<Record<string, any> | null>(null);
56
+
57
+ const title = computed(() => (doc.value && kind.value ? kind.value.title(doc.value, props.lang) : "") || props.id);
58
+ const rows = computed(() => (doc.value ? oncologyRows(props.type, doc.value, props.lang) : []));
59
+
60
+ async function read() {
61
+ loading.value = true;
62
+ const hit = kind.value ? await oipEsGet<any>("drugs", kind.value.index, props.id, kind.value.source).catch(() => null) : null;
63
+ doc.value = hit?._source ?? null;
64
+ loading.value = false;
65
+ }
66
+
67
+ watch(() => [props.type, props.id], read, { immediate: true });
68
+ </script>
69
+
70
+ <style scoped>
71
+ .oip-onco__title {
72
+ margin-right: var(--space-8);
73
+ }
74
+ .oip-onco__body {
75
+ display: flex;
76
+ flex-direction: column;
77
+ gap: var(--space-16);
78
+ padding: var(--space-16) 0;
79
+ }
80
+ .oip-onco__rows {
81
+ display: grid;
82
+ grid-template-columns: 180px minmax(0, 1fr);
83
+ gap: var(--space-6) var(--space-12);
84
+ margin: 0;
85
+ }
86
+ .oip-onco__rows dt {
87
+ color: var(--text-muted);
88
+ font-size: var(--font-12);
89
+ font-weight: var(--weight-semibold);
90
+ text-transform: uppercase;
91
+ letter-spacing: 0.04em;
92
+ }
93
+ .oip-onco__rows dd {
94
+ margin: 0;
95
+ color: var(--text-primary);
96
+ font-size: var(--font-14);
97
+ }
98
+ </style>