@tekkare/romulus 0.1.331 → 0.1.333
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 +1 -1
- package/dist/runtime/components/AlertCard.vue +7 -1
- package/dist/runtime/components/AlertEvents.vue +45 -15
- package/dist/runtime/components/Alerts.vue +10 -1
- package/dist/runtime/utils/alerts.d.ts +7 -0
- package/layer/app/components/OipShell.vue +3 -0
- package/layer/app/components/layout/tool/alerts.vue +53 -8
- package/layer/app/components/layout/viewLoader.vue +115 -0
- package/layer/app/components/panels/OipPanelInbox.vue +4 -2
- package/layer/app/composables/useOipViewLoader.ts +68 -0
- package/layer/app/composables/useViews.ts +38 -1
- package/layer/app/oip-defaults/alerts.ts +17 -0
- package/layer/app/utils/alertChanges.ts +250 -0
- package/layer/app/utils/alertFieldLabels.ts +7 -4
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -48,6 +48,7 @@ const emit = defineEmits<{
|
|
|
48
48
|
toggle: [id: string]
|
|
49
49
|
rearm: [id: string]
|
|
50
50
|
menu: [payload: { key: string; id: string }]
|
|
51
|
+
'open-event': [id: string]
|
|
51
52
|
}>()
|
|
52
53
|
|
|
53
54
|
const FR = {
|
|
@@ -366,7 +367,12 @@ function pick(item: RmAlertMenuItem) {
|
|
|
366
367
|
|
|
367
368
|
<div v-if="expanded" class="rm-alert__journal">
|
|
368
369
|
<RmLoadingState v-if="eventsLoading" />
|
|
369
|
-
<RmAlertEvents
|
|
370
|
+
<RmAlertEvents
|
|
371
|
+
v-else-if="events.length"
|
|
372
|
+
:events="events"
|
|
373
|
+
:lang="lang"
|
|
374
|
+
@open-event="emit('open-event', $event)"
|
|
375
|
+
/>
|
|
370
376
|
<p v-else class="rm-alert__journal-empty">{{ T.noEvents }}</p>
|
|
371
377
|
</div>
|
|
372
378
|
</div>
|
|
@@ -23,22 +23,29 @@ const props = withDefaults(
|
|
|
23
23
|
{ showSource: false, lang: 'fr' },
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
+
const emit = defineEmits<{
|
|
27
|
+
/** Une carte cliquable est ouverte : l'appelant mene a la fiche. */
|
|
28
|
+
'open-event': [id: string]
|
|
29
|
+
}>()
|
|
30
|
+
|
|
26
31
|
const FR = {
|
|
27
32
|
appeared: 'Nouveau',
|
|
28
33
|
changed: 'Modifié',
|
|
29
34
|
disappeared: 'Sorti du périmètre',
|
|
30
|
-
becomes: 'devient',
|
|
31
35
|
empty: '(vide)',
|
|
32
|
-
more: (n: number) => `et ${n} autre${n > 1 ? 's' : ''}
|
|
36
|
+
more: (n: number) => `et ${n} autre${n > 1 ? 's' : ''} changement${n > 1 ? 's' : ''}`,
|
|
37
|
+
open: 'Voir la fiche',
|
|
38
|
+
from: 'Alerte',
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
const EN = {
|
|
36
42
|
appeared: 'New',
|
|
37
43
|
changed: 'Changed',
|
|
38
44
|
disappeared: 'Left the scope',
|
|
39
|
-
becomes: 'becomes',
|
|
40
45
|
empty: '(empty)',
|
|
41
|
-
more: (n: number) => `and ${n} other
|
|
46
|
+
more: (n: number) => `and ${n} other change${n > 1 ? 's' : ''}`,
|
|
47
|
+
open: 'Open the record',
|
|
48
|
+
from: 'Alert',
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
const T = computed(() => (props.lang === 'en' ? EN : FR))
|
|
@@ -51,7 +58,7 @@ const T = computed(() => (props.lang === 'en' ? EN : FR))
|
|
|
51
58
|
* des autres reste affiche : masquer sans le dire ferait croire que c'est
|
|
52
59
|
* tout ce qui a bouge.
|
|
53
60
|
*/
|
|
54
|
-
const MAX_LINES =
|
|
61
|
+
const MAX_LINES = 3
|
|
55
62
|
|
|
56
63
|
function shown(event: RmAlertEvent) {
|
|
57
64
|
return (event.changes ?? []).slice(0, MAX_LINES)
|
|
@@ -83,6 +90,10 @@ function blocks(event: RmAlertEvent) {
|
|
|
83
90
|
function hidden(event: RmAlertEvent) {
|
|
84
91
|
return Math.max((event.changes ?? []).length - MAX_LINES, 0)
|
|
85
92
|
}
|
|
93
|
+
|
|
94
|
+
function open(event: RmAlertEvent) {
|
|
95
|
+
if (event.openable) emit('open-event', event.id)
|
|
96
|
+
}
|
|
86
97
|
</script>
|
|
87
98
|
|
|
88
99
|
<template>
|
|
@@ -91,7 +102,14 @@ function hidden(event: RmAlertEvent) {
|
|
|
91
102
|
v-for="event in events"
|
|
92
103
|
:key="event.id"
|
|
93
104
|
class="rm-alert-events__item"
|
|
94
|
-
:class="{
|
|
105
|
+
:class="{
|
|
106
|
+
'rm-alert-events__item--unread': !event.read,
|
|
107
|
+
'rm-alert-events__item--openable': event.openable,
|
|
108
|
+
}"
|
|
109
|
+
:role="event.openable ? 'link' : undefined"
|
|
110
|
+
:tabindex="event.openable ? 0 : undefined"
|
|
111
|
+
@click="open(event)"
|
|
112
|
+
@keydown.enter="open(event)"
|
|
95
113
|
>
|
|
96
114
|
<header class="rm-alert-events__head">
|
|
97
115
|
<span class="rm-alert-events__kind" :class="`rm-alert-events__kind--${event.kind}`">
|
|
@@ -117,13 +135,16 @@ function hidden(event: RmAlertEvent) {
|
|
|
117
135
|
:key="line"
|
|
118
136
|
class="rm-alert-events__change"
|
|
119
137
|
>
|
|
120
|
-
|
|
138
|
+
<!-- Espaces explicites : entre une balise et la suivante, le
|
|
139
|
+
compilateur retire le blanc, et on lisait « Code ATC4 :L01FF ». -->
|
|
140
|
+
<span class="rm-alert-events__field">{{ change.label || change.field }} :</span>{{ ' ' }}
|
|
141
|
+
<!-- Une phrase quand les valeurs ne se lisent pas (entree resumee,
|
|
142
|
+
texte long) ; sinon l'avant et l'apres, separes d'une fleche. -->
|
|
143
|
+
<template v-if="change.note">{{ change.note }}</template>
|
|
121
144
|
<!-- Une entree qui entre ou qui sort n'a qu'un cote : annoncer
|
|
122
145
|
« (vide) devient X » remplissait la ligne de ce qui n'existe pas. -->
|
|
123
|
-
<template v-if="change.before && change.after">
|
|
124
|
-
<s>{{ change.before }}</s>
|
|
125
|
-
{{ T.becomes }}
|
|
126
|
-
<strong>{{ change.after }}</strong>
|
|
146
|
+
<template v-else-if="change.before && change.after">
|
|
147
|
+
<s>{{ change.before }}</s>{{ ' → ' }}<strong>{{ change.after }}</strong>
|
|
127
148
|
</template>
|
|
128
149
|
<s v-else-if="change.before">{{ change.before }}</s>
|
|
129
150
|
<strong v-else>{{ change.after || T.empty }}</strong>
|
|
@@ -132,13 +153,22 @@ function hidden(event: RmAlertEvent) {
|
|
|
132
153
|
<p v-if="hidden(event)" class="rm-alert-events__more">
|
|
133
154
|
{{ T.more(hidden(event)) }}
|
|
134
155
|
</p>
|
|
135
|
-
<
|
|
136
|
-
|
|
137
|
-
|
|
156
|
+
<footer
|
|
157
|
+
v-if="(showSource && event.alertTitle) || event.openable"
|
|
158
|
+
class="rm-alert-events__foot"
|
|
159
|
+
>
|
|
160
|
+
<span v-if="showSource && event.alertTitle" class="rm-alert-events__from">
|
|
161
|
+
{{ T.from }} : {{ event.alertTitle }}
|
|
162
|
+
</span>
|
|
163
|
+
<span v-if="event.openable" class="rm-alert-events__open">
|
|
164
|
+
{{ T.open }}
|
|
165
|
+
<RmIcon name="ArrowRight" :size="12" />
|
|
166
|
+
</span>
|
|
167
|
+
</footer>
|
|
138
168
|
</article>
|
|
139
169
|
</div>
|
|
140
170
|
</template>
|
|
141
171
|
|
|
142
172
|
<style scoped>
|
|
143
|
-
.rm-alert-events{display:flex;flex-direction:column;gap:10px}.rm-alert-events__item{border:1px solid var(--border-default);border-radius:9px;display:flex;flex-direction:column;gap:3px;padding:10px 12px}.rm-alert-events__item--unread{border-left:3px solid var(--color-primary)}.rm-alert-events__head{align-items:center;display:flex;gap:8px;justify-content:space-between}.rm-alert-events__source{color:var(--text-muted);font-size:11px;font-weight:600;margin:0}.rm-alert-events__kind{color:var(--text-secondary);font-size:10.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase}.rm-alert-events__kind--appeared{color:var(--color-success)}.rm-alert-events__kind--changed{color:var(--color-info)}.rm-alert-events__kind--disappeared{color:var(--color-warning)}.rm-alert-events__date{color:var(--text-muted);font-size:11px}.rm-alert-events__title{color:var(--text-primary);font-size:13.5px;line-height:1.4
|
|
173
|
+
.rm-alert-events{display:flex;flex-direction:column;gap:10px}.rm-alert-events__item{border:1px solid var(--border-default);border-radius:9px;display:flex;flex-direction:column;gap:3px;padding:10px 12px}.rm-alert-events__item--unread{border-left:3px solid var(--color-primary)}.rm-alert-events__item--openable{cursor:pointer}.rm-alert-events__item--openable:hover{background:var(--bg-hover)}.rm-alert-events__item--openable:focus-visible{outline:2px solid var(--color-secondary);outline-offset:2px}.rm-alert-events__head{align-items:center;display:flex;gap:8px;justify-content:space-between}.rm-alert-events__source{color:var(--text-muted);font-size:11px;font-weight:600;margin:0}.rm-alert-events__kind{color:var(--text-secondary);font-size:10.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase}.rm-alert-events__kind--appeared{color:var(--color-success)}.rm-alert-events__kind--changed{color:var(--color-info)}.rm-alert-events__kind--disappeared{color:var(--color-warning)}.rm-alert-events__date{color:var(--text-muted);font-size:11px}.rm-alert-events__title{display:-webkit-box;margin:0;overflow:hidden;-webkit-box-orient:vertical;color:var(--text-primary);font-size:13.5px;font-weight:600;-webkit-line-clamp:3;line-clamp:3;line-height:1.4}.rm-alert-events__from,.rm-alert-events__sub{color:var(--text-muted);font-size:11.5px;margin:0}.rm-alert-events__block{margin-top:4px}.rm-alert-events__block--grouped{border-left:2px solid var(--border-default);padding-left:8px}.rm-alert-events__group{color:var(--text-primary);font-size:11.5px;font-weight:600;margin:0}.rm-alert-events__change{color:var(--text-secondary);font-size:12.5px;margin:2px 0 0}.rm-alert-events__field{color:var(--text-muted)}.rm-alert-events__change s{opacity:.65}.rm-alert-events__foot{align-items:center;display:flex;gap:8px;justify-content:space-between;margin-top:4px}.rm-alert-events__open{align-items:center;color:var(--color-primary);display:inline-flex;font-size:12px;font-weight:600;gap:4px;margin-left:auto;white-space:nowrap}.rm-alert-events__more{color:var(--text-muted);font-size:12px;font-style:italic;margin:2px 0 0}
|
|
144
174
|
</style>
|
|
@@ -66,6 +66,8 @@ const emit = defineEmits<{
|
|
|
66
66
|
rearm: [id: string]
|
|
67
67
|
menu: [payload: { key: string; id: string }]
|
|
68
68
|
'read-all': []
|
|
69
|
+
/** Un evenement du journal est ouvert : mener a sa fiche. */
|
|
70
|
+
'open-event': [id: string]
|
|
69
71
|
}>()
|
|
70
72
|
|
|
71
73
|
const FR = {
|
|
@@ -202,7 +204,12 @@ function setTab(value: 'active' | 'paused' | 'events') {
|
|
|
202
204
|
{{ T.readAll }}
|
|
203
205
|
</button>
|
|
204
206
|
|
|
205
|
-
<RmAlertEvents
|
|
207
|
+
<RmAlertEvents
|
|
208
|
+
:events="events"
|
|
209
|
+
show-source
|
|
210
|
+
:lang="lang"
|
|
211
|
+
@open-event="emit('open-event', $event)"
|
|
212
|
+
/>
|
|
206
213
|
</div>
|
|
207
214
|
|
|
208
215
|
<RmEmptyState v-else framed icon="Bell" :title="T.emptyEvents" :text="T.emptyEventsText" />
|
|
@@ -232,6 +239,7 @@ function setTab(value: 'active' | 'paused' | 'events') {
|
|
|
232
239
|
@open="emit('open', $event)"
|
|
233
240
|
@rearm="emit('rearm', $event)"
|
|
234
241
|
@menu="emit('menu', $event)"
|
|
242
|
+
@open-event="emit('open-event', $event)"
|
|
235
243
|
/>
|
|
236
244
|
</div>
|
|
237
245
|
</RmCollapse>
|
|
@@ -253,6 +261,7 @@ function setTab(value: 'active' | 'paused' | 'events') {
|
|
|
253
261
|
@open="emit('open', $event)"
|
|
254
262
|
@rearm="emit('rearm', $event)"
|
|
255
263
|
@menu="emit('menu', $event)"
|
|
264
|
+
@open-event="emit('open-event', $event)"
|
|
256
265
|
/>
|
|
257
266
|
</section>
|
|
258
267
|
</template>
|
|
@@ -97,6 +97,11 @@ export interface RmAlertChange {
|
|
|
97
97
|
group?: string | null;
|
|
98
98
|
before: string;
|
|
99
99
|
after: string;
|
|
100
|
+
/**
|
|
101
|
+
* Phrase qui remplace les valeurs quand elles ne se lisent pas : une entree
|
|
102
|
+
* resumee (« retrait de KEYTRUDA 50 MG »), un texte long (« modifie »).
|
|
103
|
+
*/
|
|
104
|
+
note?: string | null;
|
|
100
105
|
}
|
|
101
106
|
export interface RmAlertEvent {
|
|
102
107
|
id: string;
|
|
@@ -115,6 +120,8 @@ export interface RmAlertEvent {
|
|
|
115
120
|
source?: string | null;
|
|
116
121
|
alertTitle?: string | null;
|
|
117
122
|
read?: boolean;
|
|
123
|
+
/** La carte mene a la fiche du document : un clic emet `open-event`. */
|
|
124
|
+
openable?: boolean;
|
|
118
125
|
}
|
|
119
126
|
/** Un champ que la page propose de surveiller. */
|
|
120
127
|
export interface RmAlertField {
|
|
@@ -38,6 +38,7 @@ import OipPanelStatistics from "./panels/OipPanelStatistics.vue";
|
|
|
38
38
|
import OipPanelTopics from "./panels/OipPanelTopics.vue";
|
|
39
39
|
import OipPanelTutorials from "./panels/OipPanelTutorials.vue";
|
|
40
40
|
import OipNewsModal from "./layout/newsModal.vue";
|
|
41
|
+
import OipViewLoader from "./layout/viewLoader.vue";
|
|
41
42
|
|
|
42
43
|
// Relatif et non `~/` : dans un layer, `~` designe l'app qui l'etend.
|
|
43
44
|
import tekkareLogoRaw from "../assets/tekkare_logo.svg?raw";
|
|
@@ -666,6 +667,8 @@ const tekkareLogo = tekkareLogoRaw.replaceAll('fill="#2100AD"', 'fill="currentCo
|
|
|
666
667
|
<div ref="chatwootLayer" class="oip-chatwoot-layer" />
|
|
667
668
|
<!-- Nouveautés sur les sujets favoris de cette app, une fois par news. -->
|
|
668
669
|
<OipNewsModal :lang="en ? 'en' : 'fr'" />
|
|
670
|
+
<!-- « On charge votre vue » : arrivee par un lien de vue (Inbox). -->
|
|
671
|
+
<OipViewLoader :lang="en ? 'en' : 'fr'" />
|
|
669
672
|
</template>
|
|
670
673
|
</RmAppShell>
|
|
671
674
|
</template>
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
<script setup lang="ts">
|
|
15
15
|
import { sameViewPage } from "../../../utils/viewPages";
|
|
16
16
|
import { ALERT_BRAND_DIRECTORY, alertEventSourceLabel, alertProjectPath } from "#oip-app/alerts";
|
|
17
|
+
// Par namespace, avec repli : une app qui fournit son propre `#oip-app/alerts`
|
|
18
|
+
// sans ces deux fonctions (ajoutees en nov. 2026) doit continuer de builder.
|
|
19
|
+
// Sans elles, aucune carte du journal n'est cliquable.
|
|
20
|
+
import * as appAlerts from "#oip-app/alerts";
|
|
21
|
+
|
|
22
|
+
const alertEventOpenable = (docId: string | null | undefined): boolean =>
|
|
23
|
+
(appAlerts as any).alertEventOpenable?.(docId) ?? false;
|
|
24
|
+
const alertEventPath = async (docId: string): Promise<string | null> =>
|
|
25
|
+
(await (appAlerts as any).alertEventPath?.(docId)) ?? null;
|
|
17
26
|
import { oipSnackbar } from "#oip-app/ui";
|
|
18
27
|
import type {
|
|
19
28
|
RmAlert,
|
|
@@ -297,14 +306,29 @@ function toEventCard(event: any, alertTitle: string) {
|
|
|
297
306
|
// Les cles techniques ne se montrent pas : un identifiant interne qui
|
|
298
307
|
// bouge n'apprend rien et noie la ligne d'a cote. Le moteur ne les
|
|
299
308
|
// rapporte plus, ce filtre vaut pour ce qui est deja journalise.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
309
|
+
// Puis le diff devient quelques lignes lisibles : entrees nommees et
|
|
310
|
+
// comptees, textes longs resumes, doublon de langue tu (cf.
|
|
311
|
+
// simplifyAlertChanges). Une entree garde son resume brut : c'est la
|
|
312
|
+
// qu'on lit son libelle et son identifiant.
|
|
313
|
+
changes: simplifyAlertChanges(
|
|
314
|
+
(event.changes ?? [])
|
|
315
|
+
.filter((change: any) => !isAlertNoiseField(change.field))
|
|
316
|
+
.map((change: any) => {
|
|
317
|
+
const named = alertFieldLabel(change.field, change.label, t, locale.value);
|
|
318
|
+
return {
|
|
319
|
+
field: change.field,
|
|
320
|
+
label: named.label,
|
|
321
|
+
what: named.what,
|
|
322
|
+
entry: named.entry,
|
|
323
|
+
before: named.entry ? change.before ?? "" : alertChangeValue(change.before, t, locale.value),
|
|
324
|
+
after: named.entry ? change.after ?? "" : alertChangeValue(change.after, t, locale.value),
|
|
325
|
+
};
|
|
326
|
+
}),
|
|
327
|
+
lang.value,
|
|
328
|
+
),
|
|
329
|
+
// Un clic mene a la fiche, quand l'app sait la retrouver.
|
|
330
|
+
docId: event.docId,
|
|
331
|
+
openable: alertEventOpenable(event.docId),
|
|
308
332
|
dateLabel: whenExact(event.detectedAt),
|
|
309
333
|
// Une alerte de marque traverse tout le hub : sans la provenance, la carte
|
|
310
334
|
// dit qu'il s'est passe quelque chose sans dire ou aller le lire.
|
|
@@ -381,6 +405,26 @@ async function onOpen(id: string) {
|
|
|
381
405
|
}
|
|
382
406
|
}
|
|
383
407
|
|
|
408
|
+
/**
|
|
409
|
+
* Un evenement ouvre sa fiche : c'est la qu'on lit ce qui a change, en entier
|
|
410
|
+
* et en contexte. L'app seule sait ou vit la fiche d'un document (certaines se
|
|
411
|
+
* construisent avec un champ du document, relu a la demande). L'evenement
|
|
412
|
+
* passe lu au passage : on vient de le consulter.
|
|
413
|
+
*/
|
|
414
|
+
async function onOpenEvent(id: string) {
|
|
415
|
+
const card: any =
|
|
416
|
+
events.value.find((event) => event.id === id) ??
|
|
417
|
+
expandedEvents.value.find((event) => event.id === id);
|
|
418
|
+
if (!card?.docId) return;
|
|
419
|
+
const path = await alertEventPath(card.docId);
|
|
420
|
+
if (!path) {
|
|
421
|
+
notify(lang.value === "en" ? "This record cannot be opened any more." : "Cette fiche ne peut plus être ouverte.");
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (!card.read) void alerts.markRead({ eventIds: [id] }).catch(() => {});
|
|
425
|
+
await navigateTo(localePath(path));
|
|
426
|
+
}
|
|
427
|
+
|
|
384
428
|
const menu = computed<RmAlertMenuItem[]>(() => [
|
|
385
429
|
{
|
|
386
430
|
key: "edit",
|
|
@@ -852,6 +896,7 @@ const onWatchedPage = computed(
|
|
|
852
896
|
:expanded-loading="expandedLoading"
|
|
853
897
|
:lang="lang"
|
|
854
898
|
@open="onOpen"
|
|
899
|
+
@open-event="onOpenEvent"
|
|
855
900
|
@create="editing = null; creating = true"
|
|
856
901
|
@rearm="onRearm"
|
|
857
902
|
@menu="onMenu"
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Modale « On charge votre vue », montee par OipShell.
|
|
3
|
+
|
|
4
|
+
S'ouvre quand on arrive sur une page par un lien de vue (`?oipView=`, cf.
|
|
5
|
+
useOipViewLoader) et reste au moins trois secondes, le temps que la vue
|
|
6
|
+
s'applique et que le lecteur voie ce qui se passe. La barre avance seule
|
|
7
|
+
jusqu'a 90 %, puis finit sa course quand la vue est posee.
|
|
8
|
+
-->
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
const props = defineProps<{ lang: "fr" | "en" }>();
|
|
11
|
+
const en = computed(() => props.lang === "en");
|
|
12
|
+
|
|
13
|
+
const loader = useOipViewLoader();
|
|
14
|
+
|
|
15
|
+
const open = computed({
|
|
16
|
+
get: () => !!loader.state.value,
|
|
17
|
+
set: (value: boolean) => {
|
|
18
|
+
if (!value) loader.close();
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<RmModal v-model="open" size="sm" mode="free" :label="en ? 'Loading your view' : 'Chargement de votre vue'">
|
|
25
|
+
<template #header>
|
|
26
|
+
<span class="view-loader_title">{{ en ? "Loading your view" : "On charge votre vue" }}</span>
|
|
27
|
+
</template>
|
|
28
|
+
<div class="view-loader">
|
|
29
|
+
<i class="ph ph-bookmark-simple view-loader_icon" aria-hidden="true" />
|
|
30
|
+
<p class="view-loader_name">
|
|
31
|
+
{{
|
|
32
|
+
loader.state.value?.title
|
|
33
|
+
|| (en ? "Applying the filters of the shared view…" : "Application des filtres de la vue partagée…")
|
|
34
|
+
}}
|
|
35
|
+
</p>
|
|
36
|
+
<div
|
|
37
|
+
class="view-loader_track"
|
|
38
|
+
role="progressbar"
|
|
39
|
+
:aria-valuetext="en ? 'Loading' : 'Chargement'"
|
|
40
|
+
>
|
|
41
|
+
<div class="view-loader_bar" :class="{ 'is-done': loader.state.value?.done }" />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</RmModal>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<style scoped>
|
|
48
|
+
.view-loader_title {
|
|
49
|
+
font-weight: var(--weight-semibold);
|
|
50
|
+
font-size: var(--font-16);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.view-loader {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: 12px;
|
|
58
|
+
padding: 8px 8px 16px;
|
|
59
|
+
text-align: center;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.view-loader_icon {
|
|
63
|
+
font-size: 32px;
|
|
64
|
+
color: var(--color-primary);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.view-loader_name {
|
|
68
|
+
margin: 0;
|
|
69
|
+
color: var(--text-secondary);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.view-loader_track {
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 6px;
|
|
75
|
+
border-radius: 999px;
|
|
76
|
+
background: var(--bg-surface-3);
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.view-loader_bar {
|
|
81
|
+
height: 100%;
|
|
82
|
+
width: 0;
|
|
83
|
+
border-radius: inherit;
|
|
84
|
+
background: var(--color-primary);
|
|
85
|
+
animation: view-loader-fill 2.8s ease-out forwards;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.view-loader_bar.is-done {
|
|
89
|
+
animation: view-loader-finish 0.25s ease-out forwards;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@keyframes view-loader-fill {
|
|
93
|
+
from {
|
|
94
|
+
width: 0;
|
|
95
|
+
}
|
|
96
|
+
to {
|
|
97
|
+
width: 90%;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@keyframes view-loader-finish {
|
|
102
|
+
from {
|
|
103
|
+
width: 90%;
|
|
104
|
+
}
|
|
105
|
+
to {
|
|
106
|
+
width: 100%;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@media (prefers-reduced-motion: reduce) {
|
|
111
|
+
.view-loader_bar {
|
|
112
|
+
animation-duration: 0.01s;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
<script setup lang="ts">
|
|
17
17
|
import type { OipInboxItem } from "../../composables/useOipInbox";
|
|
18
18
|
import { PROJECTS_PATH } from "#oip-projects";
|
|
19
|
+
import { withViewParam } from "../../composables/useOipViewLoader";
|
|
19
20
|
|
|
20
21
|
// Passee par OipShell a tous les panneaux ; l'Inbox n'en depend pas.
|
|
21
22
|
defineProps<{ appKey?: string; superAdmin?: boolean }>();
|
|
@@ -49,10 +50,11 @@ function hostOf(url?: string): string {
|
|
|
49
50
|
|
|
50
51
|
const localePath = useLocalePath();
|
|
51
52
|
|
|
52
|
-
/** Un projet s'ouvre sur sa page dans cette app ; une vue a son adresse. */
|
|
53
|
+
/** Un projet s'ouvre sur sa page dans cette app ; une vue a son adresse, appliquee. */
|
|
53
54
|
function hrefOf(item: OipInboxItem): string {
|
|
54
55
|
if (item.kind === "project") return localePath(`${PROJECTS_PATH}/${encodeURIComponent(item.id)}`);
|
|
55
|
-
|
|
56
|
+
// L'identifiant fait appliquer la vue a l'arrivee (cf. useOipViewLoader).
|
|
57
|
+
return withViewParam(item.url ?? "", item.id);
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
/** Fichier ouvert dans l'apercu, ou null. */
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useOipViewLoader - ouvrir une vue depuis un lien, et le montrer.
|
|
3
|
+
*
|
|
4
|
+
* Un lien vers une vue (l'Inbox du rail, celle d'OIP 7) porte son identifiant
|
|
5
|
+
* dans `?oipView=` en plus de l'adresse de sa page. La page, en se declarant
|
|
6
|
+
* (cf. `useViews().declare`), applique la vue au lieu de laisser le lecteur la
|
|
7
|
+
* chercher dans « Mes vues ». Avant, le lien n'amenait que sur la page : il
|
|
8
|
+
* fallait recliquer sur la vue une fois arrive.
|
|
9
|
+
*
|
|
10
|
+
* Pendant ce temps, une modale annonce le chargement. Elle reste ouverte au
|
|
11
|
+
* moins `MIN_MS`, meme quand la vue s'applique tout de suite : sans ce temps,
|
|
12
|
+
* l'ecran change sous les yeux du lecteur sans qu'il comprenne pourquoi.
|
|
13
|
+
*
|
|
14
|
+
* Etat de module, comme `useViews` : pose et retire dans des hooks client,
|
|
15
|
+
* donc rien ne traverse le rendu serveur.
|
|
16
|
+
*/
|
|
17
|
+
export const OIP_VIEW_PARAM = "oipView";
|
|
18
|
+
|
|
19
|
+
const MIN_MS = 3000;
|
|
20
|
+
|
|
21
|
+
/** Ajoute l'identifiant de la vue a l'adresse de sa page. */
|
|
22
|
+
export function withViewParam(url: string, id: string): string {
|
|
23
|
+
if (!url || !id) return url;
|
|
24
|
+
try {
|
|
25
|
+
const target = new URL(url, "http://relative.invalid");
|
|
26
|
+
target.searchParams.set(OIP_VIEW_PARAM, id);
|
|
27
|
+
return target.origin === "http://relative.invalid"
|
|
28
|
+
? `${target.pathname}${target.search}${target.hash}`
|
|
29
|
+
: target.toString();
|
|
30
|
+
} catch {
|
|
31
|
+
return url;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface LoaderState {
|
|
36
|
+
startedAt: number;
|
|
37
|
+
/** Nom de la vue, connu une fois les vues chargees. */
|
|
38
|
+
title: string;
|
|
39
|
+
done: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const state = ref<LoaderState | null>(null);
|
|
43
|
+
|
|
44
|
+
export function useOipViewLoader() {
|
|
45
|
+
return {
|
|
46
|
+
state: readonly(state),
|
|
47
|
+
open() {
|
|
48
|
+
state.value = { startedAt: Date.now(), title: "", done: false };
|
|
49
|
+
},
|
|
50
|
+
name(title: string) {
|
|
51
|
+
if (state.value) state.value = { ...state.value, title };
|
|
52
|
+
},
|
|
53
|
+
/** Ferme apres `MIN_MS` depuis l'ouverture ; la barre finit sa course juste avant. */
|
|
54
|
+
async finish() {
|
|
55
|
+
const current = state.value;
|
|
56
|
+
if (!current) return;
|
|
57
|
+
const left = MIN_MS - (Date.now() - current.startedAt);
|
|
58
|
+
if (left > 0) await new Promise((resolve) => setTimeout(resolve, left));
|
|
59
|
+
if (state.value !== current) return;
|
|
60
|
+
state.value = { ...current, done: true };
|
|
61
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
62
|
+
if (state.value?.startedAt === current.startedAt) state.value = null;
|
|
63
|
+
},
|
|
64
|
+
close() {
|
|
65
|
+
state.value = null;
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
// panneau.
|
|
33
33
|
|
|
34
34
|
import { sameViewPage } from "../utils/viewPages";
|
|
35
|
+
import { OIP_VIEW_PARAM, useOipViewLoader } from "./useOipViewLoader";
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* Nom du pseudo-filtre qui porte le « Personnaliser » dans les criteres d'une
|
|
@@ -344,8 +345,28 @@ export function useViews(scopes: ViewsScopes = useDefaultScopes) {
|
|
|
344
345
|
// Lu dans le `setup` : dans un hook de cycle de vie, l'injection du
|
|
345
346
|
// routeur n'a plus d'instance a interroger.
|
|
346
347
|
const route = useRoute();
|
|
348
|
+
const router = useRouter();
|
|
349
|
+
const loader = useOipViewLoader();
|
|
347
350
|
|
|
348
351
|
onMounted(async () => {
|
|
352
|
+
// Un lien de vue (Inbox, cf. useOipViewLoader) : la modale s'ouvre tout
|
|
353
|
+
// de suite et se ferme quoi qu'il arrive, vue trouvee ou non.
|
|
354
|
+
const raw = route.query[OIP_VIEW_PARAM];
|
|
355
|
+
const wantedId = typeof raw === "string" && raw ? raw : null;
|
|
356
|
+
if (!wantedId) return run(null);
|
|
357
|
+
loader.open();
|
|
358
|
+
try {
|
|
359
|
+
await run(wantedId);
|
|
360
|
+
} finally {
|
|
361
|
+
await loader.finish();
|
|
362
|
+
// Le parametre a fait son office : le garder rappliquerait la vue a
|
|
363
|
+
// chaque rechargement, par-dessus ce que le lecteur a change depuis.
|
|
364
|
+
const { [OIP_VIEW_PARAM]: _, ...query } = route.query;
|
|
365
|
+
router.replace({ query });
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
async function run(wantedId: string | null) {
|
|
349
370
|
registry.value = { build, scopes };
|
|
350
371
|
|
|
351
372
|
const store = scopes();
|
|
@@ -357,6 +378,22 @@ export function useViews(scopes: ViewsScopes = useDefaultScopes) {
|
|
|
357
378
|
const source = build();
|
|
358
379
|
if (!source) return;
|
|
359
380
|
|
|
381
|
+
// La vue demandee par le lien passe avant tout le reste : c'est
|
|
382
|
+
// exactement ce que le lecteur a clique. Introuvable (supprimee, plus
|
|
383
|
+
// partagee), la page suit son cours normal.
|
|
384
|
+
if (wantedId) {
|
|
385
|
+
const wanted = store.scopeList.value.find((scope: any) => scope.id === wantedId);
|
|
386
|
+
if (wanted) {
|
|
387
|
+
loader.name(wanted.title ?? "");
|
|
388
|
+
defaultApplied.add(source.page);
|
|
389
|
+
// Copie volontaire, comme pour la vue par defaut plus bas.
|
|
390
|
+
store.setSelectedScope({ ...wanted });
|
|
391
|
+
applyPrefs(wanted, source.prefsScope);
|
|
392
|
+
source.onApply?.(wanted);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
360
397
|
// Un lien partage porte les filtres de l'expediteur (cf. usePermalink) :
|
|
361
398
|
// ils gagnent sur la vue par defaut du destinataire, sinon le lien
|
|
362
399
|
// ouvrirait un autre ecran que celui qui a ete partage. La vue posee n'a
|
|
@@ -422,7 +459,7 @@ export function useViews(scopes: ViewsScopes = useDefaultScopes) {
|
|
|
422
459
|
applyPrefs(wanted, source.prefsScope);
|
|
423
460
|
source.onApply?.(wanted);
|
|
424
461
|
}
|
|
425
|
-
}
|
|
462
|
+
}
|
|
426
463
|
|
|
427
464
|
onBeforeUnmount(() => {
|
|
428
465
|
if (registry.value?.build === build) registry.value = null;
|
|
@@ -51,6 +51,23 @@ export function alertEventSourceLabel(
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Un evenement mene-t-il a une fiche ? Rend vite, sans appel : la carte s'en
|
|
56
|
+
* sert pour se dire cliquable. Par defaut, aucune.
|
|
57
|
+
*/
|
|
58
|
+
export function alertEventOpenable(_docId: string | null | undefined): boolean {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Le chemin de la fiche d'un evenement, sans prefixe de langue. Peut relire le
|
|
64
|
+
* document quand le chemin se construit avec l'un de ses champs. `null` quand
|
|
65
|
+
* la fiche n'existe pas (ou plus).
|
|
66
|
+
*/
|
|
67
|
+
export async function alertEventPath(_docId: string): Promise<string | null> {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
54
71
|
/** La page d'un projet. */
|
|
55
72
|
export const alertProjectPath = (id: string) => `/projects/${id}`;
|
|
56
73
|
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Les changements d'un evenement d'alerte, dits en quelques lignes lisibles.
|
|
3
|
+
*
|
|
4
|
+
* Le moteur rapporte un diff : un changement par champ, le chemin complet du
|
|
5
|
+
* champ, et pour une entree entiere qui entre ou qui sort, le resume brut de
|
|
6
|
+
* son contenu (`cip_code 3400894095354, cip_ucd_type UCD, product_label ...`).
|
|
7
|
+
* Lu tel quel dans le journal, c'etait illisible : des clefs de collection
|
|
8
|
+
* (`c_2639673`), des identifiants, la meme maladie en francais puis en
|
|
9
|
+
* anglais, deux paragraphes d'indication barre et gras.
|
|
10
|
+
*
|
|
11
|
+
* Ici, chaque changement devient une ligne courte :
|
|
12
|
+
* - une entree qui entre ou sort se nomme par son libelle, et les entrees d'une
|
|
13
|
+
* meme collection se comptent ensemble (« 2 retraits : A, B ») ;
|
|
14
|
+
* - une entree qui sort et revient avec le meme identifiant est une mise a
|
|
15
|
+
* jour, pas un retrait suivi d'un ajout ;
|
|
16
|
+
* - un texte long ne se recopie pas, la ligne dit qu'il a change ;
|
|
17
|
+
* - le doublon anglais d'un champ francais (et l'inverse) se tait.
|
|
18
|
+
*
|
|
19
|
+
* Fonction pure : le layer lui passe des changements deja libelles avec les
|
|
20
|
+
* mots de l'app, elle ne connait aucun index.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
export interface AlertRawChange {
|
|
24
|
+
/** Chemin du champ, tel que le moteur le rapporte. */
|
|
25
|
+
field: string
|
|
26
|
+
/** Libelle du champ, deja traduit. */
|
|
27
|
+
label: string
|
|
28
|
+
/** Libelle de la collection (premier segment du chemin), deja traduit. */
|
|
29
|
+
what: string
|
|
30
|
+
/** Une entree entiere qui entre ou qui sort, et non un champ qui change. */
|
|
31
|
+
entry: boolean
|
|
32
|
+
before: string
|
|
33
|
+
after: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AlertSimpleChange {
|
|
37
|
+
field: string
|
|
38
|
+
label: string
|
|
39
|
+
before: string
|
|
40
|
+
after: string
|
|
41
|
+
/** Phrase qui remplace les valeurs, quand elles ne se lisent pas. */
|
|
42
|
+
note?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Clefs d'une entree qui la nomment, par ordre de preference. */
|
|
46
|
+
const NAME_KEYS = [
|
|
47
|
+
'preferred_label',
|
|
48
|
+
'product_label',
|
|
49
|
+
'presentation_label',
|
|
50
|
+
'label',
|
|
51
|
+
'name',
|
|
52
|
+
'title',
|
|
53
|
+
'brand',
|
|
54
|
+
'disease_name',
|
|
55
|
+
'libelle',
|
|
56
|
+
'indication',
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
/** Au-dela, une valeur est un texte, pas une donnee : on dit qu'il a change. */
|
|
60
|
+
const LONG_VALUE = 60
|
|
61
|
+
/** Noms cites par ligne ; le reste se compte. */
|
|
62
|
+
const MAX_NAMES = 2
|
|
63
|
+
/** Un nom trop long se coupe : la ligne doit tenir dans le rail. */
|
|
64
|
+
const MAX_NAME_LENGTH = 48
|
|
65
|
+
|
|
66
|
+
const CHUNK = /^([a-z0-9_]+) (.+)$/
|
|
67
|
+
|
|
68
|
+
const WORDS = {
|
|
69
|
+
fr: {
|
|
70
|
+
added: (n: number) => (n > 1 ? `${n} ajouts` : '1 ajout'),
|
|
71
|
+
removed: (n: number) => (n > 1 ? `${n} retraits` : '1 retrait'),
|
|
72
|
+
updated: (n: number) => (n > 1 ? `${n} mises à jour` : '1 mise à jour'),
|
|
73
|
+
addedOf: 'ajout de',
|
|
74
|
+
removedOf: 'retrait de',
|
|
75
|
+
updatedOf: 'mise à jour de',
|
|
76
|
+
others: (n: number) => `et ${n} autre${n > 1 ? 's' : ''}`,
|
|
77
|
+
changed: 'modifié',
|
|
78
|
+
filled: 'renseigné',
|
|
79
|
+
emptied: 'retiré',
|
|
80
|
+
},
|
|
81
|
+
en: {
|
|
82
|
+
added: (n: number) => (n > 1 ? `${n} added` : '1 added'),
|
|
83
|
+
removed: (n: number) => (n > 1 ? `${n} removed` : '1 removed'),
|
|
84
|
+
updated: (n: number) => (n > 1 ? `${n} updated` : '1 updated'),
|
|
85
|
+
addedOf: 'added',
|
|
86
|
+
removedOf: 'removed',
|
|
87
|
+
updatedOf: 'updated',
|
|
88
|
+
others: (n: number) => `and ${n} more`,
|
|
89
|
+
changed: 'changed',
|
|
90
|
+
filled: 'filled in',
|
|
91
|
+
emptied: 'removed',
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Le resume brut d'une entree, en paires clef/valeur. Vide s'il n'en est pas un. */
|
|
96
|
+
function chunks(summary: string): Array<[string, string]> {
|
|
97
|
+
const out: Array<[string, string]> = []
|
|
98
|
+
for (const part of String(summary ?? '').split(', ')) {
|
|
99
|
+
const match = part.match(CHUNK)
|
|
100
|
+
if (!match) return []
|
|
101
|
+
out.push([match[1]!, match[2]!])
|
|
102
|
+
}
|
|
103
|
+
return out
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function nameOf(summary: string): string | null {
|
|
107
|
+
const pairs = chunks(summary)
|
|
108
|
+
for (const key of NAME_KEYS) {
|
|
109
|
+
const found = pairs.find(([k]) => k === key)
|
|
110
|
+
if (found) return shorten(found[1].replace(/…$/, '').trim())
|
|
111
|
+
}
|
|
112
|
+
return null
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Ce qui identifie l'entree d'un releve a l'autre. */
|
|
116
|
+
function idOf(summary: string): string | null {
|
|
117
|
+
const found = chunks(summary).find(([key]) => key === 'id' || key.endsWith('_id'))
|
|
118
|
+
return found ? found[1].replace(/…$/, '').trim() : null
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function shorten(value: string): string {
|
|
122
|
+
return value.length > MAX_NAME_LENGTH ? `${value.slice(0, MAX_NAME_LENGTH - 1).trimEnd()}…` : value
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Le segment de tete, sans son suffixe de langue. */
|
|
126
|
+
function base(field: string): { root: string; lang: 'fr' | 'en' | null } {
|
|
127
|
+
const top = String(field ?? '').split('.')[0] ?? ''
|
|
128
|
+
const match = top.match(/^(.*)_(fr|en)$/)
|
|
129
|
+
return match ? { root: match[1]!, lang: match[2] as 'fr' | 'en' } : { root: top, lang: null }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Le doublon d'un champ dans l'autre langue se tait quand sa version dans la
|
|
134
|
+
* langue de l'ecran a aussi bouge : c'est le meme mouvement, dit deux fois.
|
|
135
|
+
*/
|
|
136
|
+
function dropOtherLanguage(changes: AlertRawChange[], lang: 'fr' | 'en'): AlertRawChange[] {
|
|
137
|
+
const roots = new Set(
|
|
138
|
+
changes.map((change) => base(change.field)).filter((b) => b.lang !== (lang === 'fr' ? 'en' : 'fr')).map((b) => b.root),
|
|
139
|
+
)
|
|
140
|
+
return changes.filter((change) => {
|
|
141
|
+
const b = base(change.field)
|
|
142
|
+
return !(b.lang && b.lang !== lang && roots.has(b.root))
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function listOf(names: string[], count: number, W: (typeof WORDS)['fr']): string {
|
|
147
|
+
const shown = names.slice(0, MAX_NAMES).join(', ')
|
|
148
|
+
const rest = count - Math.min(names.length, MAX_NAMES)
|
|
149
|
+
return rest > 0 ? `${shown} ${W.others(rest)}` : shown
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function simplifyAlertChanges(
|
|
153
|
+
raw: AlertRawChange[],
|
|
154
|
+
lang: 'fr' | 'en' = 'fr',
|
|
155
|
+
): AlertSimpleChange[] {
|
|
156
|
+
const W = WORDS[lang]
|
|
157
|
+
const changes = dropOtherLanguage(raw, lang)
|
|
158
|
+
|
|
159
|
+
// Les entrees se rassemblent par collection et par sens ; leur ligne prend
|
|
160
|
+
// la place du premier changement de la collection, pour garder l'ordre du
|
|
161
|
+
// moteur (cf. R-05 : il a deja classe par portee metier).
|
|
162
|
+
type Bucket = { what: string; field: string; added: string[]; removed: string[]; updated: string[]; counts: Record<'added' | 'removed' | 'updated', number> }
|
|
163
|
+
const buckets = new Map<string, Bucket>()
|
|
164
|
+
const order: Array<{ bucket: string } | { change: AlertSimpleChange }> = []
|
|
165
|
+
|
|
166
|
+
const entries = changes.filter((change) => change.entry)
|
|
167
|
+
// Une entree qui sort et revient sous le meme identifiant : mise a jour.
|
|
168
|
+
const removedIds = new Map<string, AlertRawChange>()
|
|
169
|
+
for (const change of entries) {
|
|
170
|
+
if (change.before && !change.after) {
|
|
171
|
+
const id = idOf(change.before)
|
|
172
|
+
if (id) removedIds.set(`${change.what}|${id}`, change)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const paired = new Set<AlertRawChange>()
|
|
176
|
+
for (const change of entries) {
|
|
177
|
+
if (!change.before && change.after) {
|
|
178
|
+
const id = idOf(change.after)
|
|
179
|
+
const twin = id ? removedIds.get(`${change.what}|${id}`) : undefined
|
|
180
|
+
if (twin && !paired.has(twin)) {
|
|
181
|
+
paired.add(twin)
|
|
182
|
+
paired.add(change)
|
|
183
|
+
;(change as AlertRawChange & { updated?: boolean }).updated = true
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
for (const change of changes) {
|
|
189
|
+
if (!change.entry) {
|
|
190
|
+
if (sameList(change.before, change.after)) continue
|
|
191
|
+
order.push({ change: simpleField(change, W) })
|
|
192
|
+
continue
|
|
193
|
+
}
|
|
194
|
+
const isUpdate = (change as AlertRawChange & { updated?: boolean }).updated === true
|
|
195
|
+
// Le retrait apparie se fond dans la mise a jour, il ne compte pas a part.
|
|
196
|
+
if (paired.has(change) && !isUpdate) continue
|
|
197
|
+
|
|
198
|
+
const key = change.what || change.field.split('.')[0] || change.field
|
|
199
|
+
let bucket = buckets.get(key)
|
|
200
|
+
if (!bucket) {
|
|
201
|
+
bucket = { what: key, field: change.field, added: [], removed: [], updated: [], counts: { added: 0, removed: 0, updated: 0 } }
|
|
202
|
+
buckets.set(key, bucket)
|
|
203
|
+
order.push({ bucket: key })
|
|
204
|
+
}
|
|
205
|
+
const side = isUpdate ? 'updated' : change.after ? 'added' : 'removed'
|
|
206
|
+
const name = nameOf(isUpdate ? change.after : change.after || change.before)
|
|
207
|
+
bucket.counts[side] += 1
|
|
208
|
+
if (name && !bucket[side].includes(name)) bucket[side].push(name)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const out: AlertSimpleChange[] = []
|
|
212
|
+
for (const item of order) {
|
|
213
|
+
if ('change' in item) {
|
|
214
|
+
out.push(item.change)
|
|
215
|
+
continue
|
|
216
|
+
}
|
|
217
|
+
const bucket = buckets.get(item.bucket)!
|
|
218
|
+
for (const side of ['updated', 'added', 'removed'] as const) {
|
|
219
|
+
const count = bucket.counts[side]
|
|
220
|
+
if (!count) continue
|
|
221
|
+
const names = bucket[side]
|
|
222
|
+
const of = side === 'added' ? W.addedOf : side === 'removed' ? W.removedOf : W.updatedOf
|
|
223
|
+
const note = names.length
|
|
224
|
+
? `${of} ${listOf(names, count, W)}`
|
|
225
|
+
: (side === 'added' ? W.added : side === 'removed' ? W.removed : W.updated)(count)
|
|
226
|
+
out.push({ field: bucket.field, label: bucket.what, before: '', after: '', note })
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return out
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* La meme liste dans un autre ordre (« L01XC, L01FF » puis « L01FF, L01XC ») :
|
|
234
|
+
* le moteur la voit changer, le lecteur n'y apprend rien.
|
|
235
|
+
*/
|
|
236
|
+
function sameList(before: string, after: string): boolean {
|
|
237
|
+
if (!before || !after || before === after || !before.includes(', ')) return false
|
|
238
|
+
const sorted = (value: string) => value.split(', ').map((v) => v.trim()).sort().join('\u0000')
|
|
239
|
+
return sorted(before) === sorted(after)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function simpleField(change: AlertRawChange, W: (typeof WORDS)['fr']): AlertSimpleChange {
|
|
243
|
+
const { field, label, before, after } = change
|
|
244
|
+
const long = (value: string) => value.length > LONG_VALUE || value.includes('\n')
|
|
245
|
+
if (long(before) || long(after)) {
|
|
246
|
+
const note = before && after ? W.changed : after ? W.filled : W.emptied
|
|
247
|
+
return { field, label, before: '', after: '', note }
|
|
248
|
+
}
|
|
249
|
+
return { field, label, before, after }
|
|
250
|
+
}
|
|
@@ -92,11 +92,11 @@ export function alertFieldLabel(
|
|
|
92
92
|
serverLabel: string | null | undefined,
|
|
93
93
|
t: (key: string) => string,
|
|
94
94
|
locale: string,
|
|
95
|
-
): { group: string | null; label: string } {
|
|
95
|
+
): { group: string | null; label: string; what: string; entry: boolean } {
|
|
96
96
|
// Le compteur de debordement n'est pas un champ : son libelle est deja une
|
|
97
97
|
// phrase.
|
|
98
98
|
if (!field || field.startsWith("__")) {
|
|
99
|
-
return { group: null, label: serverLabel || field };
|
|
99
|
+
return { group: null, label: serverLabel || field, what: "", entry: false };
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
const segments = field.split(".");
|
|
@@ -108,6 +108,9 @@ export function alertFieldLabel(
|
|
|
108
108
|
return translate(NESTED, part, t);
|
|
109
109
|
})
|
|
110
110
|
.filter(Boolean);
|
|
111
|
+
// La collection que le changement touche, pour les lignes qui la resument
|
|
112
|
+
// (cf. simplifyAlertChanges).
|
|
113
|
+
const what = parts[0] ?? field;
|
|
111
114
|
|
|
112
115
|
// Une entree entiere qui entre ou qui sort : le chemin ne nomme aucun champ,
|
|
113
116
|
// c'est la marque qui dit ce qui s'est passe. Elle remplace alors le champ,
|
|
@@ -117,7 +120,7 @@ export function alertFieldLabel(
|
|
|
117
120
|
(serverLabel ?? "").endsWith(entry),
|
|
118
121
|
);
|
|
119
122
|
if (marker) {
|
|
120
|
-
return { group: parts.join(" · ") || null, label: t(ENTRY_MARKERS[marker]!) };
|
|
123
|
+
return { group: parts.join(" · ") || null, label: t(ENTRY_MARKERS[marker]!), what, entry: true };
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
// Champ inconnu du catalogue : le libelle que la page a envoye avec l'alerte
|
|
@@ -130,7 +133,7 @@ export function alertFieldLabel(
|
|
|
130
133
|
if (!known && fallback && parts.length > 0) parts[parts.length - 1] = fallback;
|
|
131
134
|
|
|
132
135
|
const label = parts.pop() ?? field;
|
|
133
|
-
return { group: parts.join(" · ") || null, label };
|
|
136
|
+
return { group: parts.join(" · ") || null, label, what, entry: false };
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
/**
|