@tekkare/romulus 0.1.348 → 0.1.349

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.346",
7
+ "version": "0.1.348",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -34,6 +34,12 @@ export interface RmDrawerProps {
34
34
  * decide (90 et 91).
35
35
  */
36
36
  zIndex?: number | string
37
+ /**
38
+ * Marge en haut et en bas, coins arrondis : le tiroir se pose comme un
39
+ * panneau, aligne sur un cadre qui ne touche pas les bords (le rail d'un
40
+ * shell OIP). Absent : le tiroir colle aux bords de la fenetre.
41
+ */
42
+ inset?: string
37
43
  }
38
44
 
39
45
  const props = withDefaults(defineProps<RmDrawerProps>(), {
@@ -45,6 +51,7 @@ const props = withDefaults(defineProps<RmDrawerProps>(), {
45
51
  labelledBy: undefined,
46
52
  closeLabel: 'Fermer',
47
53
  zIndex: undefined,
54
+ inset: undefined,
48
55
  })
49
56
 
50
57
  const emit = defineEmits<{
@@ -87,8 +94,8 @@ const layer = computed(() => (props.zIndex === undefined ? undefined : { zIndex:
87
94
  v-if="modelValue"
88
95
  ref="surface"
89
96
  class="rm-drawer"
90
- :class="[`rm-drawer--${side}`]"
91
- :style="[{ width: drawerWidth, [side]: offset }, layer]"
97
+ :class="[`rm-drawer--${side}`, { 'rm-drawer--inset': inset, 'rm-drawer--attached': inset && offset !== '0px' }]"
98
+ :style="[{ width: drawerWidth, [side]: offset }, inset ? { top: inset, bottom: inset } : {}, layer]"
92
99
  role="dialog"
93
100
  aria-modal="true"
94
101
  :aria-label="labelledBy ? undefined : label"
@@ -115,5 +122,5 @@ const layer = computed(() => (props.zIndex === undefined ? undefined : { zIndex:
115
122
  </template>
116
123
 
117
124
  <style scoped>
118
- .rm-drawer-overlay{backdrop-filter:blur(2px);background-color:rgba(0,0,0,.2);inset:0;position:fixed;z-index:90}.rm-drawer{background-color:var(--bg-surface);bottom:0;box-shadow:var(--shadow-lg);color:var(--text-primary);display:flex;flex-direction:column;font-family:var(--font-sans);max-width:100%;position:fixed;top:0;z-index:91}.rm-drawer--right{border-left:1px solid var(--border-default)}.rm-drawer--left{border-right:1px solid var(--border-default)}.rm-drawer__header{align-items:center;border-bottom:1px solid var(--border-default);display:flex;justify-content:space-between;min-height:64px;padding:var(--space-16) var(--space-24)}.rm-drawer__close{align-items:center;background:none;border:none;border-radius:var(--radius-md);color:var(--text-secondary);cursor:pointer;display:flex;flex-shrink:0;height:32px;justify-content:center;transition:all var(--duration-fast) var(--ease-in-out);width:32px}.rm-drawer__close:hover{background-color:var(--bg-surface-3);color:var(--text-secondary)}.rm-drawer__body{flex:1;overflow-y:auto;padding:var(--space-24)}.rm-drawer__footer{border-top:1px solid var(--border-default);padding:var(--space-16) var(--space-24)}.rm-drawer-overlay-enter-active,.rm-drawer-overlay-leave-active{transition:opacity .25s ease}.rm-drawer-overlay-leave-active,.rm-drawer-overlay-leave-to,.rm-drawer-slide-left-leave-active,.rm-drawer-slide-left-leave-to,.rm-drawer-slide-right-leave-active,.rm-drawer-slide-right-leave-to{pointer-events:none}.rm-drawer-overlay-enter-from,.rm-drawer-overlay-leave-to{opacity:0}.rm-drawer-slide-right-enter-active,.rm-drawer-slide-right-leave-active{transition:transform .3s cubic-bezier(.4,0,.2,1)}.rm-drawer-slide-right-enter-from,.rm-drawer-slide-right-leave-to{transform:translateX(100%)}.rm-drawer-slide-left-enter-active,.rm-drawer-slide-left-leave-active{transition:transform .3s cubic-bezier(.4,0,.2,1)}.rm-drawer-slide-left-enter-from,.rm-drawer-slide-left-leave-to{transform:translateX(-100%)}
125
+ .rm-drawer-overlay{backdrop-filter:blur(2px);background-color:rgba(0,0,0,.2);inset:0;position:fixed;z-index:90}.rm-drawer{background-color:var(--bg-surface);bottom:0;box-shadow:var(--shadow-lg);color:var(--text-primary);display:flex;flex-direction:column;font-family:var(--font-sans);max-width:100%;position:fixed;top:0;z-index:91}.rm-drawer--right{border-left:1px solid var(--border-default)}.rm-drawer--left{border-right:1px solid var(--border-default)}.rm-drawer--inset{border:1px solid var(--border-default);border-radius:var(--radius-xl,12px);overflow:hidden}.rm-drawer--inset.rm-drawer--attached.rm-drawer--right{border-bottom-right-radius:0;border-right:0;border-top-right-radius:0}.rm-drawer--inset.rm-drawer--attached.rm-drawer--left{border-bottom-left-radius:0;border-left:0;border-top-left-radius:0}.rm-drawer__header{align-items:center;border-bottom:1px solid var(--border-default);display:flex;justify-content:space-between;min-height:64px;padding:var(--space-16) var(--space-24)}.rm-drawer__close{align-items:center;background:none;border:none;border-radius:var(--radius-md);color:var(--text-secondary);cursor:pointer;display:flex;flex-shrink:0;height:32px;justify-content:center;transition:all var(--duration-fast) var(--ease-in-out);width:32px}.rm-drawer__close:hover{background-color:var(--bg-surface-3);color:var(--text-secondary)}.rm-drawer__body{flex:1;overflow-y:auto;padding:var(--space-24)}.rm-drawer__footer{border-top:1px solid var(--border-default);padding:var(--space-16) var(--space-24)}.rm-drawer-overlay-enter-active,.rm-drawer-overlay-leave-active{transition:opacity .25s ease}.rm-drawer-overlay-leave-active,.rm-drawer-overlay-leave-to,.rm-drawer-slide-left-leave-active,.rm-drawer-slide-left-leave-to,.rm-drawer-slide-right-leave-active,.rm-drawer-slide-right-leave-to{pointer-events:none}.rm-drawer-overlay-enter-from,.rm-drawer-overlay-leave-to{opacity:0}.rm-drawer-slide-right-enter-active,.rm-drawer-slide-right-leave-active{transition:transform .3s cubic-bezier(.4,0,.2,1)}.rm-drawer-slide-right-enter-from,.rm-drawer-slide-right-leave-to{transform:translateX(100%)}.rm-drawer-slide-left-enter-active,.rm-drawer-slide-left-leave-active{transition:transform .3s cubic-bezier(.4,0,.2,1)}.rm-drawer-slide-left-enter-from,.rm-drawer-slide-left-leave-to{transform:translateX(-100%)}
119
126
  </style>
@@ -89,7 +89,7 @@ function submit() {
89
89
  </template>
90
90
  <form class="rm-project-dialog__form" @submit.prevent="submit">
91
91
  <RmInput v-model="title" :label="T.name" :placeholder="T.placeholder" :error="missing ? T.required : ''" />
92
- <RmInput v-model="description" :label="T.description" />
92
+ <RmTextarea v-model="description" :label="T.description" :rows="5" />
93
93
  <p v-if="error" class="rm-project-dialog__error">{{ error }}</p>
94
94
  <!-- Entree valide le formulaire. -->
95
95
  <button type="submit" hidden />
@@ -16,7 +16,7 @@
16
16
  disparaitre en silence.
17
17
  -->
18
18
  <script setup lang="ts">
19
- import { computed, ref } from 'vue'
19
+ import { computed, reactive, ref } from 'vue'
20
20
  import {
21
21
  rmProjectCount,
22
22
  rmProjectFamilies,
@@ -55,6 +55,7 @@ const WORDS = {
55
55
  families: 'Filtrer par famille', all: 'Toutes', resources: 'Ressources', noMatch: 'Aucune ressource ne correspond à ces filtres.',
56
56
  comment: 'Commenter', commentsN: (n: number) => `Commentaires (${n})`, remove: 'Retirer du projet',
57
57
  unknown: (id: string) => `Élément inconnu (id ${id})`, source: 'Source', added: 'Ajouté le',
58
+ bundleCount: (n: number, family: string) => `${n} fiches ${family}, à déplier`,
58
59
  filed: (n: number) => `${rmProjectCount(n, 'fr')} ${n > 1 ? 'rangées' : 'rangée'} dans le projet.`,
59
60
  shown: (s: number, n: number) => `${s} ${s > 1 ? 'affichées' : 'affichée'} sur ${rmProjectCount(n, 'fr')}.`,
60
61
  sorts: { 'date-desc': 'Ajout, plus récent d\'abord', 'date-asc': 'Ajout, plus ancien d\'abord', 'title': 'Titre', 'family': 'Famille' },
@@ -66,6 +67,7 @@ const WORDS = {
66
67
  families: 'Filter by family', all: 'All', resources: 'Resources', noMatch: 'No resource matches these filters.',
67
68
  comment: 'Comment', commentsN: (n: number) => `Comments (${n})`, remove: 'Remove from the project',
68
69
  unknown: (id: string) => `Unknown item (id ${id})`, source: 'Source', added: 'Added on',
70
+ bundleCount: (n: number, family: string) => `${n} ${family} records, expand to see them`,
69
71
  filed: (n: number) => `${rmProjectCount(n, 'en')} filed in the project.`,
70
72
  shown: (s: number, n: number) => `${s} shown out of ${rmProjectCount(n, 'en')}.`,
71
73
  sorts: { 'date-desc': 'Newest first', 'date-asc': 'Oldest first', 'title': 'Title', 'family': 'Family' },
@@ -102,6 +104,34 @@ const shown = computed(() => rmProjectFilterRows(props.rows, {
102
104
  sort: sort.value,
103
105
  }, props.lang))
104
106
 
107
+ /**
108
+ * Les lignes affichees, une marque par entree pour les familles qui le
109
+ * demandent (RmProjectKind.bundle) : l'entree prend la place de sa premiere
110
+ * ligne, le tri et les filtres restent ceux des lignes.
111
+ */
112
+ const entries = computed(() => {
113
+ const out: Array<{ key: string, title: string, rows: RmProjectResource[], comments: number }> = []
114
+ const byKey = new Map<string, (typeof out)[number]>()
115
+ for (const row of shown.value) {
116
+ if (!row.bundle) {
117
+ out.push({ key: `${row.type}-${row.id}`, title: row.title, rows: [row], comments: row.comments ?? 0 })
118
+ continue
119
+ }
120
+ const key = `bundle-${row.group ?? row.type}-${row.bundle}`
121
+ const known = byKey.get(key)
122
+ if (known) {
123
+ known.rows.push(row)
124
+ known.comments += row.comments ?? 0
125
+ continue
126
+ }
127
+ const entry = { key, title: row.bundle, rows: [row], comments: row.comments ?? 0 }
128
+ byKey.set(key, entry)
129
+ out.push(entry)
130
+ }
131
+ return out
132
+ })
133
+ const openBundles = reactive<Record<string, boolean>>({})
134
+
105
135
  const context = computed(() => {
106
136
  const total = props.rows.length
107
137
  return shown.value.length === total ? T.value.filed(total) : T.value.shown(shown.value.length, total)
@@ -188,7 +218,36 @@ function onTitle(event: MouseEvent, row: RmProjectResource) {
188
218
  </div>
189
219
 
190
220
  <ol v-if="shown.length" class="rm-project-res__list">
191
- <li v-for="row in shown" :key="`${row.type}-${row.id}`" class="rm-project-res__item">
221
+ <template v-for="entry in entries" :key="entry.key">
222
+ <!-- Un ensemble (une marque) : une entree repliee, ses lignes dessous. -->
223
+ <li v-if="entry.rows.length > 1" class="rm-project-res__item rm-project-res__bundle">
224
+ <span class="rm-project-res__icon" aria-hidden="true">
225
+ <RmIcon :name="entry.rows[0]!.icon" :size="17" />
226
+ </span>
227
+ <div class="rm-project-res__text">
228
+ <p class="rm-project-res__item-title">
229
+ <button
230
+ type="button"
231
+ class="rm-project-res__bundle-toggle"
232
+ :aria-expanded="!!openBundles[entry.key]"
233
+ @click="openBundles[entry.key] = !openBundles[entry.key]"
234
+ >
235
+ <RmIcon :name="openBundles[entry.key] ? 'CaretDown' : 'CaretRight'" :size="14" />
236
+ {{ entry.title }}
237
+ </button>
238
+ </p>
239
+ <p class="rm-project-res__sub">{{ T.bundleCount(entry.rows.length, entry.rows[0]!.family) }}</p>
240
+ <p v-if="entry.comments" class="rm-project-res__meta">{{ T.commentsN(entry.comments) }}</p>
241
+ </div>
242
+ <RmBadge variant="info" class="rm-project-res__family">{{ entry.rows[0]!.family }}</RmBadge>
243
+ <div class="rm-project-res__actions" />
244
+ </li>
245
+ <li
246
+ v-for="row in (entry.rows.length === 1 || openBundles[entry.key] ? entry.rows : [])"
247
+ :key="`${row.type}-${row.id}`"
248
+ class="rm-project-res__item"
249
+ :class="{ 'rm-project-res__item--nested': entry.rows.length > 1 }"
250
+ >
192
251
  <span class="rm-project-res__icon" aria-hidden="true">
193
252
  <RmIcon :name="row.icon" :size="17" />
194
253
  </span>
@@ -241,6 +300,7 @@ function onTitle(event: MouseEvent, row: RmProjectResource) {
241
300
  </RmTooltip>
242
301
  </div>
243
302
  </li>
303
+ </template>
244
304
  </ol>
245
305
 
246
306
  <p v-else class="rm-project-res__none">
@@ -253,5 +313,5 @@ function onTitle(event: MouseEvent, row: RmProjectResource) {
253
313
  </template>
254
314
 
255
315
  <style scoped>
256
- .rm-project-res{display:flex;flex-direction:column;gap:16px}.rm-project-res__search{flex:0 1 360px;min-width:160px}.rm-project-res__chips{display:flex;flex-wrap:wrap;gap:6px}.rm-project-res__chip-count{background:var(--bg-surface-3);border-radius:999px;color:var(--text-secondary);font-size:10px;font-weight:700;padding:1px 6px}.toolbar-pill--active .rm-project-res__chip-count{background:hsla(0,0%,100%,.25);color:var(--color-text-inverse)}.rm-project-res__head{display:flex;flex-direction:column;gap:4px;margin-bottom:8px}.rm-project-res__title{color:var(--text-primary);font-size:15px;font-weight:var(--weight-bold);margin:0}.rm-project-res__context{color:var(--text-muted);font-size:12px;margin:0}.rm-project-res__list{display:flex;flex-direction:column;list-style:none;margin:0;padding:0}.rm-project-res__item{align-items:center;border-bottom:1px solid var(--border-soft,var(--border-default));display:flex;gap:12px;padding:10px 0}.rm-project-res__item:last-child{border-bottom:none}.rm-project-res__icon{align-items:center;background:var(--bg-surface-3);border-radius:var(--radius-lg,8px);color:var(--text-secondary);display:flex;flex:none;height:34px;justify-content:center;width:34px}.rm-project-res__text{flex:1;min-width:0}.rm-project-res__item-title{align-items:center;color:var(--text-primary);display:flex;font-size:13px;font-weight:var(--weight-semibold);gap:6px;margin:0}.rm-project-res__item-title a{color:var(--color-primary);text-decoration:underline;text-underline-offset:2px}.rm-project-res__comment{display:inline-flex;position:relative}.rm-project-res__count{background:var(--color-primary);border-radius:9999px;color:#fff;font-size:var(--font-10);font-weight:700;height:16px;line-height:16px;min-width:16px;padding:0 var(--space-4);pointer-events:none;position:absolute;right:-4px;text-align:center;top:-4px}.rm-project-res__sub{color:var(--text-secondary);font-size:12px;margin:2px 0 0}.rm-project-res__meta{align-items:center;color:var(--text-muted);display:flex;font-size:11px;gap:5px;margin:2px 0 0}.rm-project-res__family,.rm-project-res__flag{flex:none}.rm-project-res__actions{align-items:center;display:flex;flex:none;gap:2px}.rm-project-res__none{align-items:center;color:var(--text-secondary);display:flex;font-size:13px;gap:6px;margin:8px 0}
316
+ .rm-project-res{display:flex;flex-direction:column;gap:16px}.rm-project-res__search{flex:0 1 360px;min-width:160px}.rm-project-res__chips{display:flex;flex-wrap:wrap;gap:6px}.rm-project-res__chip-count{background:var(--bg-surface-3);border-radius:999px;color:var(--text-secondary);font-size:10px;font-weight:700;padding:1px 6px}.toolbar-pill--active .rm-project-res__chip-count{background:hsla(0,0%,100%,.25);color:var(--color-text-inverse)}.rm-project-res__bundle-toggle{align-items:center;background:none;border:0;color:inherit;cursor:pointer;display:inline-flex;font:inherit;gap:6px;padding:0}.rm-project-res__bundle-toggle:hover{color:var(--color-primary)}.rm-project-res__head{display:flex;flex-direction:column;gap:4px;margin-bottom:8px}.rm-project-res__title{color:var(--text-primary);font-size:15px;font-weight:var(--weight-bold);margin:0}.rm-project-res__context{color:var(--text-muted);font-size:12px;margin:0}.rm-project-res__list{display:flex;flex-direction:column;list-style:none;margin:0;padding:0}.rm-project-res__item{align-items:center;border-bottom:1px solid var(--border-soft,var(--border-default));display:flex;gap:12px;padding:10px 0}.rm-project-res__item:last-child{border-bottom:none}.rm-project-res__item.rm-project-res__bundle{background:var(--bg-surface-2);border-bottom:none;border-radius:var(--radius-lg,8px);margin:4px -12px 0;padding:10px 12px}.rm-project-res__item.rm-project-res__item--nested{border-left:2px solid var(--border-default);margin-left:28px;padding:8px 0 8px 16px}.rm-project-res__bundle .rm-project-res__actions{width:58px}.rm-project-res__item--nested .rm-project-res__icon{display:none}.rm-project-res__item--nested .rm-project-res__item-title{font-size:13px}.rm-project-res__icon{align-items:center;background:var(--bg-surface-3);border-radius:var(--radius-lg,8px);color:var(--text-secondary);display:flex;flex:none;height:34px;justify-content:center;width:34px}.rm-project-res__text{flex:1;min-width:0}.rm-project-res__item-title{align-items:center;color:var(--text-primary);display:flex;font-size:13px;font-weight:var(--weight-semibold);gap:6px;margin:0}.rm-project-res__item-title a{color:var(--color-primary);text-decoration:underline;text-underline-offset:2px}.rm-project-res__comment{display:inline-flex;position:relative}.rm-project-res__count{background:var(--color-primary);border-radius:9999px;color:#fff;font-size:var(--font-10);font-weight:700;height:16px;line-height:16px;min-width:16px;padding:0 var(--space-4);pointer-events:none;position:absolute;right:-4px;text-align:center;top:-4px}.rm-project-res__sub{color:var(--text-secondary);font-size:12px;margin:2px 0 0}.rm-project-res__meta{align-items:center;color:var(--text-muted);display:flex;font-size:11px;gap:5px;margin:2px 0 0}.rm-project-res__family,.rm-project-res__flag{flex:none}.rm-project-res__actions{align-items:center;display:flex;flex:none;gap:2px}.rm-project-res__none{align-items:center;color:var(--text-secondary);display:flex;font-size:13px;gap:6px;margin:8px 0}
257
317
  </style>
@@ -77,6 +77,13 @@ export interface RmProjectKind<S = any> {
77
77
  path?: (source: S, id: string) => string;
78
78
  /** Titre lisible dans l'identifiant seul, quand le document a disparu. */
79
79
  titleFromId?: (id: string) => string;
80
+ /**
81
+ * L'ensemble sous lequel la liste du projet range la ligne (la marque d'une
82
+ * presentation, d'une specialite...) : les lignes d'une meme famille et d'un
83
+ * meme ensemble s'affichent repliees sous une seule entree, depliable.
84
+ * Absent : la ligne s'affiche seule.
85
+ */
86
+ bundle?: (source: S, lang: RmProjectLang) => string;
80
87
  }
81
88
  /** Un element du projet, tel que l'API le rend. */
82
89
  export interface RmProjectItem {
@@ -108,6 +115,8 @@ export interface RmProjectResource {
108
115
  known: boolean;
109
116
  /** Le document relu, pour un affichage propre a l'app. */
110
117
  source?: unknown;
118
+ /** L'ensemble d'affichage (cf. RmProjectKind.bundle), une marque par exemple. */
119
+ bundle?: string;
111
120
  }
112
121
  /** Une fiche refusee parce qu'archivee, nommee pour la question a poser. */
113
122
  export interface RmProjectArchivedEntry {
@@ -96,7 +96,8 @@ export function rmProjectRows(items, documents, kinds, lang = "fr") {
96
96
  createdAt: item.createdAt,
97
97
  comments: item.commentsCount ?? 0,
98
98
  known: !!kind,
99
- source
99
+ source,
100
+ bundle: kind && source ? kind.bundle?.(source, lang) || void 0 : void 0
100
101
  };
101
102
  });
102
103
  }
@@ -1,12 +1,88 @@
1
1
  <!--
2
- Un appel a projets (PHRC) range dans un projet : sa carte de resultat, celle
3
- de la liste des appels a projets de France Augmented Science, relue dans
4
- l'index par son identifiant.
2
+ Un appel a projets (PHRC) range dans un projet : sa fiche, telle que France
3
+ Augmented Science la montre (pages/appel-a-projet/[id]) : le resume (type,
4
+ discipline, periode, titres, financement, statut de tranche), puis
5
+ l'etablissement et l'investigateur (cartes des annuaires FINESS et RPPS),
6
+ les maladies rares, et l'essai clinique lie (carte CT.gov).
7
+ Relu dans l'index par son identifiant.
5
8
  -->
6
9
  <template>
7
10
  <div class="oip-science oip-sc-phrc">
8
- <RmLoadingState v-if="pending" spinner />
9
- <OipScienceAppelAProjetCards v-else-if="doc" :data="doc" :highlight="highlight" />
11
+ <RmLoadingState v-if="pending" :lines="3" :chart-height="240" />
12
+
13
+ <div v-else-if="doc" class="oip_grid gap-24">
14
+ <!-- Resume -->
15
+ <div class="oip_card oip_grid gap-24">
16
+ <div class="oip_grid gap-4">
17
+ <h2 class="kk_title_medium_2">{{ lang === "en" ? "Summary" : "Résumé" }}</h2>
18
+ <OipScienceCommonSource :sources="['Appel à projet']" :lang="lang" />
19
+ </div>
20
+
21
+ <div class="oip_row v-center gap-8">
22
+ <RmTag variant="purple">{{ doc.project_type || "-" }}</RmTag>
23
+ <RmTag variant="blue">{{ doc.discipline_fr || "-" }}</RmTag>
24
+ </div>
25
+
26
+ <div class="oip_grid gap-4">
27
+ <p class="kk_text cool_grey">
28
+ {{ doc.period || "-" }}
29
+ <span v-if="doc.acronym"> - <strong>{{ doc.acronym }}</strong></span>
30
+ </p>
31
+ <h3 class="kk_title_medium">{{ doc.title_fr || "-" }}</h3>
32
+ <p v-if="doc.title_en" class="kk_text cool_grey">{{ doc.title_en }}</p>
33
+ </div>
34
+
35
+ <div class="oip_grid gap-8">
36
+ <OipScienceCommonTableTags
37
+ icon="Coin"
38
+ :title="lang === 'en' ? 'Funding' : 'Financement'"
39
+ :values="doc.total_amount ? [amount(doc.total_amount)] : []"
40
+ />
41
+ <OipScienceCommonTableTags
42
+ icon="ChartBar"
43
+ :title="lang === 'en' ? 'Tranche status' : 'Statut de la tranche'"
44
+ :values="doc.status_code ? [doc.status_code] : []"
45
+ />
46
+ </div>
47
+ </div>
48
+
49
+ <!-- Etablissement et investigateur : les cartes des annuaires. -->
50
+ <div v-if="establishmentCard" class="oip_grid gap-12">
51
+ <h2 class="kk_title_medium_2">{{ lang === "en" ? "Establishment" : "Établissement" }}</h2>
52
+ <OipScienceEstablishmentsCards :data="establishmentCard" />
53
+ </div>
54
+
55
+ <div v-if="hcpCard" class="oip_grid gap-12">
56
+ <h2 class="kk_title_medium_2">{{ lang === "en" ? "Investigator" : "Investigateur" }}</h2>
57
+ <OipScienceHcpsCards :data="hcpCard" :aap-count="hcpAapCount" />
58
+ </div>
59
+
60
+ <!-- Maladies rares -->
61
+ <div v-if="rareDiseases.length" class="oip_card oip_grid gap-24">
62
+ <h2 class="kk_title_medium_2">{{ lang === "en" ? "Rare diseases" : "Maladies rares" }}</h2>
63
+ <OipScienceCommonTableTags
64
+ icon="Bandaids"
65
+ :title="lang === 'en' ? 'Rare diseases' : 'Maladies rares'"
66
+ :values="rareDiseases"
67
+ :is-full-results="true"
68
+ />
69
+ </div>
70
+
71
+ <!-- Essai clinique lie : la carte CT.gov. -->
72
+ <div v-if="trialDoc" class="oip_grid gap-12">
73
+ <h2 class="kk_title_medium_2">{{ lang === "en" ? "Clinical trial" : "Essai clinique" }}</h2>
74
+ <OipScienceClinicalTrialsCardsGlobal :data="trialDoc" />
75
+ </div>
76
+
77
+ <!-- Numero absent de CT.gov (PROSPERO, EU PAS...) : le lien seul. -->
78
+ <div v-else-if="doc.nct_number" class="oip_card oip_grid gap-24">
79
+ <h2 class="kk_title_medium_2">{{ lang === "en" ? "Links" : "Liens" }}</h2>
80
+ <a class="kk_link_btn_underline" :href="trialUrl" target="_blank" rel="noopener">
81
+ {{ lang === "en" ? "See the trial" : "Voir l'essai" }} ({{ doc.nct_number }}) ↗
82
+ </a>
83
+ </div>
84
+ </div>
85
+
10
86
  <RmEmptyState
11
87
  v-else
12
88
  icon="FileX"
@@ -17,7 +93,8 @@
17
93
  </template>
18
94
 
19
95
  <script setup lang="ts">
20
- import { oipEsGet } from "../../../composables/useOipResources";
96
+ import { oipEsGet, oipEsSearch } from "../../../composables/useOipResources";
97
+ import { oipResourceAppUrl } from "../../../utils/oipResources";
21
98
  import indexConfig from "../../../oip-science/indexConfig.json";
22
99
 
23
100
  const props = withDefaults(defineProps<{ id: string; highlight?: string[]; lang?: "fr" | "en" }>(), {
@@ -25,11 +102,87 @@ const props = withDefaults(defineProps<{ id: string; highlight?: string[]; lang?
25
102
  lang: "fr",
26
103
  });
27
104
 
28
- const { data: doc, pending } = useAsyncData(
105
+ interface Detail {
106
+ doc: Record<string, any> | null;
107
+ establishment: Record<string, any> | null;
108
+ hcp: Record<string, any> | null;
109
+ trial: Record<string, any> | null;
110
+ hcpAapCount: number;
111
+ }
112
+
113
+ const first = (response: any) => response?.hits?.hits?.[0]?._source ?? null;
114
+
115
+ /**
116
+ * L'appel a projets, puis en parallele les fiches liees (etablissement,
117
+ * investigateur, essai) et le nombre d'appels a projets de l'investigateur.
118
+ */
119
+ const { data, pending } = useAsyncData<Detail>(
29
120
  () => `oip-phrc-${props.id}`,
30
- async () => (await oipEsGet("science", indexConfig.phrc.index, props.id))?._source ?? null,
121
+ async () => {
122
+ const doc = (await oipEsGet("science", indexConfig.phrc.index, props.id))?._source ?? null;
123
+ if (!doc) return { doc: null, establishment: null, hcp: null, trial: null, hcpAapCount: 0 };
124
+ const etCode = doc.hco_et_code ? String(doc.hco_et_code) : "";
125
+ const rpps = doc.hcp_code ? String(doc.hcp_code) : "";
126
+ const nct = doc.nct_number ? String(doc.nct_number) : "";
127
+ const none = Promise.resolve(null);
128
+ const [hco, hcp, aap, trial] = await Promise.all([
129
+ etCode ? oipEsSearch("science", indexConfig.establishments.index, { size: 1, query: { term: { hco_et_code: etCode } } }).catch(() => null) : none,
130
+ rpps ? oipEsSearch("science", indexConfig.hcps.index, { size: 1, query: { term: { hcp_code: rpps } } }).catch(() => null) : none,
131
+ rpps
132
+ ? oipEsSearch("science", indexConfig.phrc.index, { size: 0, track_total_hits: true, query: { term: { "hcp_code.keyword": rpps } } }).catch(() => null)
133
+ : none,
134
+ nct ? oipEsSearch("science", indexConfig.globalCT.index, { size: 1, query: { ids: { values: [nct] } } }).catch(() => null) : none,
135
+ ]);
136
+ return {
137
+ doc,
138
+ establishment: first(hco),
139
+ hcp: first(hcp),
140
+ trial: first(trial),
141
+ hcpAapCount: (aap as any)?.hits?.total?.value ?? 0,
142
+ };
143
+ },
31
144
  { server: false, watch: [() => props.id] },
32
145
  );
146
+
147
+ const doc = computed(() => data.value?.doc ?? null);
148
+ const trialDoc = computed(() => data.value?.trial ?? null);
149
+ const hcpAapCount = computed(() => data.value?.hcpAapCount ?? 0);
150
+
151
+ /**
152
+ * Carte etablissement : la fiche de l'annuaire, sinon la meme carte nourrie
153
+ * par l'appel a projets (sans les compteurs d'essais).
154
+ */
155
+ const establishmentCard = computed(() => {
156
+ if (data.value?.establishment) return data.value.establishment;
157
+ const d = doc.value;
158
+ if (!d?.hco_et_code && !d?.hco_et_label) return null;
159
+ return { hco_et_code: d.hco_et_code, hco_et_label: d.hco_et_label, hco_et_city: d.hco_et_city, hco_ej_label: d.hco_ej_label };
160
+ });
161
+
162
+ /** Carte investigateur : meme principe, depuis l'annuaire RPPS. */
163
+ const hcpCard = computed(() => {
164
+ if (data.value?.hcp) return data.value.hcp;
165
+ const d = doc.value;
166
+ if (!d?.hcp_family_name) return null;
167
+ const principal = d.hcp_principal_specialty;
168
+ const specialty = [
169
+ ...(principal && principal !== "AUCUNE" ? [{ hcp_specialty_type: "PRINCIPAL", hcp_specialty_label_regroup: principal }] : []),
170
+ ...[d.hcp_secondary_specialty_1, d.hcp_secondary_specialty_2]
171
+ .filter((value) => value && value !== "AUCUNE")
172
+ .map((value) => ({ hcp_specialty_type: "SECONDAIRE", hcp_specialty_label_regroup: value })),
173
+ ];
174
+ return { hcp_code: d.hcp_code, hcp_first_name: d.hcp_first_name, hcp_family_name: d.hcp_family_name, specialty };
175
+ });
176
+
177
+ const rareDiseases = computed(() => [
178
+ ...new Set<string>((doc.value?.rare_diseases_fr ?? []).map((entry: any) => entry?.concat_disease_name_orpha_code).filter(Boolean)),
179
+ ]);
180
+
181
+ const amount = (value: number) => new Intl.NumberFormat("fr-FR", { style: "currency", currency: "EUR", maximumFractionDigits: 0 }).format(value);
182
+
183
+ const trialUrl = computed(() =>
184
+ oipResourceAppUrl("france_augmented_science_app", `/ctgov/${doc.value?.nct_number}/study-description`, props.lang),
185
+ );
33
186
  </script>
34
187
 
35
188
  <style scoped>