@tekkare/romulus 0.1.105 → 0.1.107

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.104",
7
+ "version": "0.1.106",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -46,6 +46,14 @@ const props = withDefaults(
46
46
  /** Nombre d'elements que la vue tient a l'ecran, s'il est connu. */
47
47
  scopeCount?: number | null
48
48
  submitting?: boolean
49
+ /**
50
+ * `edit` prefixe le formulaire avec une alerte existante et retire le
51
+ * choix de la vue : changer de vue voudrait dire recapturer une requete,
52
+ * ce qui n'est possible que depuis la page. On en cree une autre.
53
+ */
54
+ mode?: 'create' | 'edit'
55
+ /** Alerte a modifier, en mode `edit`. */
56
+ initial?: Partial<RmAlertDraft>
49
57
  lang?: 'fr' | 'en'
50
58
  }>(),
51
59
  {
@@ -54,6 +62,8 @@ const props = withDefaults(
54
62
  fields: () => [],
55
63
  scopeCount: null,
56
64
  submitting: false,
65
+ mode: 'create',
66
+ initial: undefined,
57
67
  lang: 'fr',
58
68
  },
59
69
  )
@@ -102,6 +112,8 @@ const FR = {
102
112
  cadenceHint:
103
113
  'Un plafond, pas un rythme : rien ne part quand rien n’a bougé, et la détection suit celle des données.',
104
114
  submit: 'Créer l’alerte',
115
+ save: 'Enregistrer',
116
+ reseed: 'Changer les champs suivis repart d’une nouvelle référence : vous ne serez prévenu que de ce qui bouge ensuite.',
105
117
  cancel: 'Annuler',
106
118
  baseline:
107
119
  'À la création, la référence est capturée sans rien signaler : vous ne serez prévenu que de ce qui bouge ensuite.',
@@ -141,6 +153,8 @@ const EN = {
141
153
  cadenceHint:
142
154
  'A cap, not a rhythm: nothing goes out when nothing moved, and detection follows the data.',
143
155
  submit: 'Create the alert',
156
+ save: 'Save',
157
+ reseed: 'Changing the watched fields restarts from a new baseline: you are only told about what moves afterwards.',
144
158
  cancel: 'Cancel',
145
159
  baseline:
146
160
  'On creation the baseline is captured silently: you are only told about what moves afterwards.',
@@ -165,16 +179,23 @@ const selectedView = computed(
165
179
  () => viewOptions.value.find((option) => option.id === selectedViewId.value) ?? viewOptions.value[0],
166
180
  )
167
181
 
168
- const title = ref(props.viewTitle)
169
- const triggers = ref<RmAlertTrigger[]>(['appeared'])
170
- const watchedFields = ref<string[]>([])
182
+ const editing = computed(() => props.mode === 'edit')
183
+
184
+ const title = ref(props.initial?.title ?? props.viewTitle)
185
+ const triggers = ref<RmAlertTrigger[]>(props.initial?.triggers ?? ['appeared'])
186
+ const watchedFields = ref<string[]>(
187
+ (props.initial?.watchedFields ?? []).filter((field) => field !== RM_ALERT_ANY_FIELD),
188
+ )
171
189
  /** Surveiller le document entier plutot qu'une liste de champs. */
172
- const anyField = ref(false)
173
- const emailOn = ref(false)
174
- const cadence = ref<RmAlertCadence>('weekly')
190
+ const anyField = ref(!!props.initial?.watchedFields?.includes(RM_ALERT_ANY_FIELD))
191
+ const emailOn = ref(!!props.initial?.channels?.includes('email'))
192
+ const cadence = ref<RmAlertCadence>(props.initial?.cadence ?? 'weekly')
193
+
194
+ /** Champs suivis au chargement, pour dire quand la reference va repartir. */
195
+ const initialFields = JSON.stringify([...(props.initial?.watchedFields ?? [])].sort())
175
196
 
176
197
  /** Titre libre des que l'utilisateur y touche : on ne l'ecrase plus. */
177
- const titleTouched = ref(false)
198
+ const titleTouched = ref(props.mode === 'edit')
178
199
 
179
200
  watch(
180
201
  () => props.viewTitle,
@@ -235,6 +256,21 @@ const valid = computed(
235
256
  () => title.value.trim().length > 0 && triggers.value.length > 0 && !missingFields.value,
236
257
  )
237
258
 
259
+ /**
260
+ * Les champs suivis ont bouge depuis l'ouverture.
261
+ *
262
+ * C'est le seul changement qui fait repartir l'alerte d'une nouvelle
263
+ * reference cote API : le hachage ne couvre plus les memes valeurs.
264
+ */
265
+ const fieldsChanged = computed(() => {
266
+ const next = anyField.value
267
+ ? [RM_ALERT_ANY_FIELD]
268
+ : watchesChanges.value
269
+ ? watchedFields.value
270
+ : []
271
+ return JSON.stringify([...next].sort()) !== initialFields
272
+ })
273
+
238
274
  function submit() {
239
275
  if (!valid.value) return
240
276
  emit('submit', {
@@ -268,10 +304,12 @@ function submit() {
268
304
  "
269
305
  />
270
306
 
271
- <div class="rm-alert-form__view">
307
+ <div v-if="!editing" class="rm-alert-form__view">
272
308
  <p class="rm-alert-form__label">{{ T.view }}</p>
273
309
  <p class="rm-alert-form__hint">
274
- {{ viewOptions.length > 1 ? T.viewApplied : T.viewHint }}
310
+ <!-- L'avertissement sur l'application ne vaut que pour une vue deja
311
+ enregistree : « ecran actuel », lui, part de ce qui est deja la. -->
312
+ {{ viewOptions.length > 1 && selectedViewId ? T.viewApplied : T.viewHint }}
275
313
  </p>
276
314
 
277
315
  <RmDropdownSelect
@@ -295,6 +333,11 @@ function submit() {
295
333
  <p v-if="!selectedViewId" class="rm-alert-form__hint">{{ T.screenNote }}</p>
296
334
  </div>
297
335
 
336
+ <p v-else class="rm-alert-form__view-name">
337
+ <RmIcon name="BookmarkSimple" :size="14" />
338
+ {{ T.view }} : {{ viewTitle }}
339
+ </p>
340
+
298
341
  <fieldset class="rm-alert-form__group">
299
342
  <legend class="rm-alert-form__label">{{ T.triggers }}</legend>
300
343
  <p class="rm-alert-form__hint">{{ T.triggersHint }}</p>
@@ -350,9 +393,12 @@ function submit() {
350
393
  </div>
351
394
  </fieldset>
352
395
 
353
- <p class="rm-alert-form__baseline">
396
+ <p
397
+ v-if="!editing || fieldsChanged"
398
+ class="rm-alert-form__baseline"
399
+ >
354
400
  <RmIcon name="Info" :size="14" />
355
- {{ T.baseline }}
401
+ {{ editing ? T.reseed : T.baseline }}
356
402
  </p>
357
403
 
358
404
  <div class="rm-alert-form__actions">
@@ -363,7 +409,7 @@ function submit() {
363
409
  :disabled="!valid || submitting"
364
410
  :loading="submitting"
365
411
  >
366
- {{ T.submit }}
412
+ {{ editing ? T.save : T.submit }}
367
413
  </RmButton>
368
414
  </div>
369
415
  </form>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.105",
3
+ "version": "0.1.107",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",