@tekkare/romulus 0.1.284 → 0.1.286

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.283",
7
+ "version": "0.1.285",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -237,7 +237,7 @@ function urlOf(type: string, id: string, tab?: string, doc?: Record<string, any>
237
237
  * Les vues sans bandeau a elles (une carte de resultat) : le tiroir garde son
238
238
  * en-tete, titre et lien.
239
239
  */
240
- const CARD_VIEWS = new Set(["drugs-national-assembly", "science-phrc"]);
240
+ const CARD_VIEWS = new Set(["drugs-national-assembly", "drugs-national-assembly-amendment", "science-phrc"]);
241
241
 
242
242
  /** Une fiche du layer : elle porte son bandeau, le tiroir efface le sien. */
243
243
  function isPage(entry: Entry) {
@@ -22,6 +22,20 @@
22
22
  <template #title>{{ title }}</template>
23
23
  <template #subtitle>{{ subtitle }}</template>
24
24
 
25
+ <template #actions>
26
+ <!-- Emplacement libre pour un appelant (la fiche projet y pose son
27
+ bouton « Commenter ») avant le bouton projet : vide partout ailleurs. -->
28
+ <slot name="hubr-actions" />
29
+ <component
30
+ :is="projectButton"
31
+ v-if="projectButton"
32
+ :resource-id="amendmentId || amendment[AMENDMENT_FIELDS.id]"
33
+ type="FrNationalAssemblyAmendment"
34
+ :label="title"
35
+ compact
36
+ />
37
+ </template>
38
+
25
39
  <template #meta>
26
40
  <RmTag v-if="outcome" :variant="outcomeVariant">{{ outcome }}</RmTag>
27
41
  <RmTag v-if="statusLabel" variant="amber">{{ statusLabel }}</RmTag>
@@ -54,11 +68,16 @@
54
68
  <div v-if="textBlocks.length > 0" class="am_texts">
55
69
  <div v-for="block in textBlocks" :key="block.key" class="oip_list gap-4">
56
70
  <p class="oip_label">{{ block.label }}</p>
57
- <p :id="`${blockId}-${block.key}`" class="am_text" :class="{ 'am_text--clamped': !expanded[block.key] }">
71
+ <p
72
+ :id="`${blockId}-${block.key}`"
73
+ :ref="(el) => watchOverflow(block.key, el as HTMLElement | null)"
74
+ class="am_text"
75
+ :class="{ 'am_text--clamped': !expanded[block.key] }"
76
+ >
58
77
  <template v-for="(seg, si) in block.segments" :key="si"><mark v-if="seg.hit">{{ seg.text }}</mark><template v-else>{{ seg.text }}</template></template>
59
78
  </p>
60
79
  <button
61
- v-if="block.long"
80
+ v-if="overflowing[block.key]"
62
81
  type="button"
63
82
  class="am_toggle"
64
83
  :aria-expanded="!!expanded[block.key]"
@@ -103,7 +122,7 @@
103
122
  </template>
104
123
 
105
124
  <script lang="ts" setup>
106
- import { useId } from "vue";
125
+ import { nextTick, onBeforeUnmount, useId, watch } from "vue";
107
126
  import { AMENDMENT_FIELDS, amendmentDiscussed } from "../../../../oip-drugs/utils/associationFields";
108
127
  import { highlightSegments } from "../../../../oip-drugs/utils/esHighlight";
109
128
  import { drugsAssociationPath } from "../../../../oip-drugs/kinds";
@@ -116,8 +135,13 @@ const props = withDefaults(
116
135
  highlight?: Record<string, string[]>;
117
136
  /** L'association dont on lit la fiche : elle ne se cite pas elle-meme. */
118
137
  currentAssociation?: string;
138
+ /**
139
+ * Le `_id` du document, pour le bouton Projet. A defaut, `amendment_id`,
140
+ * qui le vaut dans cet index (verifie sur les 2 364 amendements).
141
+ */
142
+ amendmentId?: string;
119
143
  }>(),
120
- { highlight: undefined, currentAssociation: "" },
144
+ { highlight: undefined, currentAssociation: "", amendmentId: "" },
121
145
  );
122
146
 
123
147
  /**
@@ -129,6 +153,7 @@ const emit = defineEmits<{ read: [amendment: any]; report: [amendment: any] }>()
129
153
 
130
154
  const { t, locale } = useI18n();
131
155
  const nav = useOipResourceNav();
156
+ const { projectButton } = useOipResourceHooks();
132
157
  const dateLang = computed(() => (locale.value === "en" ? "en" : "fr"));
133
158
  const blockId = `am-${useId()}`;
134
159
 
@@ -204,9 +229,6 @@ const associations = computed<string[]>(() => {
204
229
  .sort((a, b) => a.localeCompare(b, "fr"));
205
230
  });
206
231
 
207
- /** Au-dela, le texte se replie sur quatre lignes. */
208
- const LONG_TEXT = 320;
209
-
210
232
  /** Dispositif puis expose, surlignes quand le moteur l'a fait. */
211
233
  const textBlocks = computed(() =>
212
234
  (
@@ -221,7 +243,6 @@ const textBlocks = computed(() =>
221
243
  return {
222
244
  key,
223
245
  label: t(`oipDrugs.heart.associations.nationalAssembly.amendments.card.${key}`),
224
- long: plain.length > LONG_TEXT,
225
246
  segments: highlighted ? highlightSegments(highlighted) : [{ text: plain, hit: false }],
226
247
  plain,
227
248
  };
@@ -231,6 +252,35 @@ const textBlocks = computed(() =>
231
252
 
232
253
  const expanded = reactive<Record<string, boolean>>({});
233
254
 
255
+ /**
256
+ * « Afficher tout » ne vaut que si le texte deborde vraiment ses quatre
257
+ * lignes. Un seuil en caracteres se trompe selon la largeur de la carte :
258
+ * on mesure le paragraphe replie, et on garde la reponse une fois deplie
259
+ * pour pouvoir le replier.
260
+ */
261
+ const overflowing = reactive<Record<string, boolean>>({});
262
+ const observed = new Map<string, HTMLElement>();
263
+ function measure() {
264
+ for (const [key, el] of observed) {
265
+ if (!expanded[key]) overflowing[key] = el.scrollHeight > el.clientHeight + 1;
266
+ }
267
+ }
268
+ const resizeObserver = import.meta.client ? new ResizeObserver(measure) : null;
269
+ // Un nouveau surlignage peut changer le texte sans changer la hauteur repliee.
270
+ watch(textBlocks, () => nextTick(measure));
271
+
272
+ function watchOverflow(key: string, el: HTMLElement | null) {
273
+ const previous = observed.get(key);
274
+ if (previous === el) return;
275
+ if (previous) resizeObserver?.unobserve(previous);
276
+ if (el) {
277
+ observed.set(key, el);
278
+ resizeObserver?.observe(el);
279
+ } else observed.delete(key);
280
+ }
281
+
282
+ onBeforeUnmount(() => resizeObserver?.disconnect());
283
+
234
284
  function openLink(url: string) {
235
285
  if (url) window.open(url, "_blank");
236
286
  }
@@ -0,0 +1,126 @@
1
+ <!--
2
+ Vue de ressource d'un amendement PLFSS de l'Assemblee nationale
3
+ (FrNationalAssemblyAmendment) : le document relu par son `_id`, monte dans
4
+ la carte de la liste. Le PDF de l'Assemblee et le compte rendu de la seance
5
+ ou il est discute s'ouvrent dans la visionneuse.
6
+ -->
7
+ <template>
8
+ <div class="oip-drugs oip_list gap-12 full">
9
+
10
+ <RmLoadingState v-if="loading" />
11
+ <RmEmptyState v-else-if="!amendment" :title="t('oipDrugs.heart.errors.results')" icon="Prohibit" />
12
+ <OipDrugsHeartAssociationsNationalAssemblyAmendmentCard
13
+ v-else
14
+ :amendment="amendment"
15
+ :amendment-id="id"
16
+ @read="openPdf"
17
+ @report="openReport"
18
+ />
19
+
20
+ <OipDocumentPreview
21
+ v-model="previewOpen"
22
+ :src="previewSrc"
23
+ :title="previewTitle"
24
+ :external-src="previewExternal"
25
+ :query="previewQuery"
26
+ :fallback-src="previewFallback"
27
+ />
28
+ </div>
29
+ </template>
30
+
31
+ <script setup lang="ts">
32
+ import { ES_INDEX } from "../../../oip-drugs/esIndices";
33
+ import {
34
+ AMENDMENT_FIELDS,
35
+ NATIONAL_ASSEMBLY_FIELDS,
36
+ amendmentPdfUrl,
37
+ amendmentReportsQuery,
38
+ } from "../../../oip-drugs/utils/associationFields";
39
+ import { oipEsSearch } from "../../../composables/useOipResources";
40
+
41
+ const props = withDefaults(
42
+ defineProps<{
43
+ id: string;
44
+ type?: string;
45
+ lang?: "fr" | "en";
46
+ highlight?: string[];
47
+ }>(),
48
+ { type: "FrNationalAssemblyAmendment", lang: "fr", highlight: () => [] },
49
+ );
50
+
51
+ const { t } = useI18n();
52
+
53
+ const amendment = ref<any>(null);
54
+ const loading = ref(true);
55
+
56
+ watch(
57
+ () => props.id,
58
+ async (id) => {
59
+ loading.value = true;
60
+ amendment.value = null;
61
+ try {
62
+ const res: any = await oipEsSearch("drugs", ES_INDEX.ASSOCIATION_AMENDMENT_NATIONAL_ASSEMBLY, {
63
+ size: 1,
64
+ query: { ids: { values: [id] } },
65
+ });
66
+ amendment.value = res?.hits?.hits?.[0]?._source ?? null;
67
+ } catch {
68
+ amendment.value = null;
69
+ }
70
+ loading.value = false;
71
+ },
72
+ { immediate: true },
73
+ );
74
+
75
+ const previewOpen = ref(false);
76
+ const previewSrc = ref<string | null>(null);
77
+ const previewTitle = ref("");
78
+ const previewExternal = ref<string | null>(null);
79
+ const previewFallback = ref<string | null>(null);
80
+ const previewQuery = ref<string[] | null>(null);
81
+
82
+ /** Le PDF de l'Assemblee, par le proxy du layer (cf. amendmentPdfUrl). */
83
+ function openPdf(doc: any) {
84
+ const url = amendmentPdfUrl(doc);
85
+ if (!url) return;
86
+ previewQuery.value = null;
87
+ previewFallback.value = null;
88
+ previewExternal.value = url;
89
+ previewSrc.value = `/api/oip/pdf?url=${encodeURIComponent(url)}`;
90
+ previewTitle.value = t("oipDrugs.heart.associations.nationalAssembly.amendments.card.number", {
91
+ n: doc?.[AMENDMENT_FIELDS.number] ?? "",
92
+ });
93
+ previewOpen.value = true;
94
+ }
95
+
96
+ /**
97
+ * Le compte rendu de la seance ou il est discute, ouvert sur son numero
98
+ * (cf. amendmentReportsQuery). Sans compte rendu trouve, la page de
99
+ * l'amendement.
100
+ */
101
+ async function openReport(doc: any) {
102
+ let report: any = null;
103
+ try {
104
+ const res: any = await oipEsSearch(
105
+ "drugs",
106
+ ES_INDEX.ASSOCIATION_COMMISSION_SESSION_NATIONAL_ASSEMBLY,
107
+ amendmentReportsQuery(doc),
108
+ );
109
+ report = res?.hits?.hits?.[0]?._source ?? null;
110
+ } catch {
111
+ report = null;
112
+ }
113
+ const url = report?.[NATIONAL_ASSEMBLY_FIELDS.tekkareUrl];
114
+ if (!url) {
115
+ if (doc?.[AMENDMENT_FIELDS.url]) window.open(doc[AMENDMENT_FIELDS.url], "_blank");
116
+ return;
117
+ }
118
+ previewSrc.value = `/api/oip/pdf?url=${encodeURIComponent(url)}`;
119
+ previewFallback.value = url;
120
+ previewExternal.value = report[NATIONAL_ASSEMBLY_FIELDS.htmlUrl] || null;
121
+ previewQuery.value = [doc[AMENDMENT_FIELDS.number]];
122
+ previewTitle.value =
123
+ report[NATIONAL_ASSEMBLY_FIELDS.agenda] || t("oipDrugs.heart.associations.nationalAssembly.card.untitled");
124
+ previewOpen.value = true;
125
+ }
126
+ </script>
@@ -91,6 +91,8 @@ const VIEW_LOADERS: Record<string, () => Promise<any>> = {
91
91
  "drugs-association": () => import("../components/oip-drugs/resources/Association.vue"),
92
92
  "drugs-contribution": () => import("../components/oip-drugs/resources/Contribution.vue"),
93
93
  "drugs-national-assembly": () => import("../components/oip-drugs/resources/NationalAssembly.vue"),
94
+ "drugs-national-assembly-amendment": () =>
95
+ import("../components/oip-drugs/resources/NationalAssemblyAmendment.vue"),
94
96
  "drugs-medicam": () => import("../components/oip-drugs/resources/Medicam.vue"),
95
97
  "drugs-outpatient": () => import("../components/oip-drugs/resources/Outpatient.vue"),
96
98
  "drugs-hospital": () => import("../components/oip-drugs/resources/Hospital.vue"),
@@ -208,6 +208,26 @@ export const DRUG_PROJECT_KINDS: RmProjectKind[] = [
208
208
  source: ["agenda", "parliamentary_session", "session_date"],
209
209
  title: (s) => s?.agenda ?? "",
210
210
  subtitle: (s) => s?.parliamentary_session ?? "",
211
+ // Les amendements ouvrent la page : un compte rendu se lit sur son onglet.
212
+ path: () => "/hubr/heart/associations/national-assembly?tab=reports",
213
+ },
214
+ {
215
+ type: "FrNationalAssemblyAmendment",
216
+ index: ES_INDEX.ASSOCIATION_AMENDMENT_NATIONAL_ASSEMBLY,
217
+ label: { fr: "Amendements PLFSS", en: "Social security bill amendments" },
218
+ section: ASSOCIATIONS,
219
+ country: "fr",
220
+ icon: "Scales",
221
+ source: ["amendment_number", "location", "outcome", "status", "examination_date", "filing_date"],
222
+ // « AS592 · ART. 21 BIS », comme le titre de la carte.
223
+ title: (s) => [s?.amendment_number, s?.location].filter(Boolean).join(" · "),
224
+ // Le sort quand il existe, l'etat sinon (irrecevable, retire), puis la date.
225
+ subtitle: (s, l) => {
226
+ const raw = s?.examination_date ?? s?.filing_date;
227
+ const date = raw ? new Date(raw) : null;
228
+ const day = date && !Number.isNaN(date.getTime()) ? date.toLocaleDateString(l === "en" ? "en-GB" : "fr-FR") : "";
229
+ return [s?.outcome || s?.status, day].filter(Boolean).join(" · ");
230
+ },
211
231
  path: () => "/hubr/heart/associations/national-assembly",
212
232
  },
213
233
  {
@@ -222,6 +222,7 @@ const DRUG_VIEWS: Record<string, string> = {
222
222
  FrPatientAssociation: "drugs-association",
223
223
  FrPatientContribution: "drugs-contribution",
224
224
  FrNationalAssemblySession: "drugs-national-assembly",
225
+ FrNationalAssemblyAmendment: "drugs-national-assembly-amendment",
225
226
  FrMedicamBrand: "drugs-medicam",
226
227
  FrOutpatientBrand: "drugs-outpatient",
227
228
  FrSusBrand: "drugs-hospital",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.284",
3
+ "version": "0.1.286",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",