@tekkare/romulus 0.1.373 → 0.1.375
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/ExportPanel.vue +35 -8
- package/layer/app/components/layout/tool/export.vue +1 -0
- package/layer/app/composables/useExportSource.ts +5 -0
- package/layer/app/middleware/00.locale-from-query.global.ts +5 -0
- package/layer/app/utils/localeFromQuery.ts +52 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -55,6 +55,14 @@ const props = withDefaults(
|
|
|
55
55
|
* classeur de vingt onglets quand on en veut deux.
|
|
56
56
|
*/
|
|
57
57
|
sheets?: string[]
|
|
58
|
+
/**
|
|
59
|
+
* Les onglets se choisissent, rien n'est coche d'office : l'export ne part
|
|
60
|
+
* pas tant qu'il n'y en a aucun, et les modeles tableur menent a ce choix
|
|
61
|
+
* plutot que de tout sortir. Les colonnes ne sont pas proposees (celles de
|
|
62
|
+
* vingt onglets melangees ne se lisent pas). Pour une fiche qui couvre
|
|
63
|
+
* beaucoup de sujets.
|
|
64
|
+
*/
|
|
65
|
+
requireSheets?: boolean
|
|
58
66
|
options?: RmExportOption[]
|
|
59
67
|
layouts?: RmExportLayout[]
|
|
60
68
|
/** Modeles pre-remplis. Vide : le panneau ouvre directement le wizard. */
|
|
@@ -79,6 +87,7 @@ const props = withDefaults(
|
|
|
79
87
|
ranges: () => [],
|
|
80
88
|
columns: () => [],
|
|
81
89
|
sheets: () => [],
|
|
90
|
+
requireSheets: false,
|
|
82
91
|
options: () => RM_EXPORT_OPTIONS,
|
|
83
92
|
layouts: () => RM_EXPORT_LAYOUTS,
|
|
84
93
|
templates: () => [],
|
|
@@ -133,6 +142,7 @@ const LABELS = {
|
|
|
133
142
|
sheetsLabel: 'Onglets du classeur',
|
|
134
143
|
sheetsAll: 'Tout cocher',
|
|
135
144
|
sheetsNone: 'Tout décocher',
|
|
145
|
+
sheetsRequired: 'Choisissez au moins un onglet à exporter.',
|
|
136
146
|
fileNameLabel: 'Nom du fichier',
|
|
137
147
|
fileNameHint: 'Extension ajoutée automatiquement selon le format.',
|
|
138
148
|
layoutLabel: 'Mise en page',
|
|
@@ -197,6 +207,7 @@ const LABELS = {
|
|
|
197
207
|
sheetsLabel: 'Workbook sheets',
|
|
198
208
|
sheetsAll: 'Select all',
|
|
199
209
|
sheetsNone: 'Clear',
|
|
210
|
+
sheetsRequired: 'Pick at least one sheet to export.',
|
|
200
211
|
fileNameLabel: 'File name',
|
|
201
212
|
fileNameHint: 'Extension added automatically, based on the format.',
|
|
202
213
|
layoutLabel: 'Layout',
|
|
@@ -251,7 +262,7 @@ const config = reactive<RmExportConfig>({
|
|
|
251
262
|
range: props.ranges[0]?.key ?? 'filtered',
|
|
252
263
|
sections: props.sections.filter(section => section.on).map(section => section.key),
|
|
253
264
|
columns: [...props.columns],
|
|
254
|
-
sheets: [...props.sheets],
|
|
265
|
+
sheets: props.requireSheets ? [] : [...props.sheets],
|
|
255
266
|
options: props.options.filter(option => option.on).map(option => option.key),
|
|
256
267
|
fileName: props.fileName,
|
|
257
268
|
layout: props.layouts[0]?.key ?? 'a4-portrait',
|
|
@@ -302,17 +313,24 @@ watch(
|
|
|
302
313
|
watch(
|
|
303
314
|
() => props.sheets,
|
|
304
315
|
(next, previous) => {
|
|
305
|
-
const added = next.filter(sheet => !(previous ?? []).includes(sheet))
|
|
306
316
|
const kept = (config.sheets ?? []).filter(sheet => next.includes(sheet))
|
|
317
|
+
if (props.requireSheets) {
|
|
318
|
+
config.sheets = next.filter(sheet => kept.includes(sheet))
|
|
319
|
+
return
|
|
320
|
+
}
|
|
321
|
+
const added = next.filter(sheet => !(previous ?? []).includes(sheet))
|
|
307
322
|
config.sheets = next.filter(sheet => kept.includes(sheet) || added.includes(sheet))
|
|
308
323
|
if (!config.sheets.length) config.sheets = [...next]
|
|
309
324
|
},
|
|
310
325
|
)
|
|
311
326
|
|
|
312
|
-
/**
|
|
327
|
+
/**
|
|
328
|
+
* Un onglet au moins : un classeur vide ne s'ouvre pas. Avec `requireSheets`
|
|
329
|
+
* la liste peut se vider, c'est le bouton de lancement qui attend.
|
|
330
|
+
*/
|
|
313
331
|
function toggleSheet(sheet: string) {
|
|
314
332
|
const list = config.sheets ?? []
|
|
315
|
-
if (list.includes(sheet) && list.length === 1) return
|
|
333
|
+
if (!props.requireSheets && list.includes(sheet) && list.length === 1) return
|
|
316
334
|
config.sheets = list.includes(sheet)
|
|
317
335
|
? list.filter(item => item !== sheet)
|
|
318
336
|
: props.sheets.filter(item => item === sheet || list.includes(item))
|
|
@@ -343,8 +361,14 @@ function enabled(section: RmExportSection) {
|
|
|
343
361
|
return !!format.value.document
|
|
344
362
|
}
|
|
345
363
|
|
|
346
|
-
const showColumns = computed(() => !!format.value?.tabular && props.columns.length > 0)
|
|
347
364
|
const showSheets = computed(() => !!format.value?.tabular && props.sheets.length > 1)
|
|
365
|
+
const showColumns = computed(
|
|
366
|
+
() => !!format.value?.tabular && props.columns.length > 0 && !(props.requireSheets && showSheets.value),
|
|
367
|
+
)
|
|
368
|
+
/** Onglets a choisir et aucun choisi : rien ne part. */
|
|
369
|
+
const missingSheets = computed(
|
|
370
|
+
() => props.requireSheets && showSheets.value && !(config.sheets?.length),
|
|
371
|
+
)
|
|
348
372
|
const showLayout = computed(() => !!format.value?.paged && props.layouts.length > 0)
|
|
349
373
|
const showRange = computed(() => !!format.value?.tabular && props.ranges.length > 0)
|
|
350
374
|
const isPermalink = computed(() => !format.value?.tabular && !format.value?.visual)
|
|
@@ -430,7 +454,8 @@ function applyTemplate(template: RmExportTemplate | null) {
|
|
|
430
454
|
if (template.config.fileName) renamed.value = true
|
|
431
455
|
templateKey.value = template.key
|
|
432
456
|
mode.value = 'wizard'
|
|
433
|
-
|
|
457
|
+
// Un modele tableur sur une fiche a onglets a choisir mene a ce choix.
|
|
458
|
+
step.value = missingSheets.value ? 2 : 4
|
|
434
459
|
}
|
|
435
460
|
|
|
436
461
|
function goto(next: number) {
|
|
@@ -691,7 +716,7 @@ const recentDate = (at: string | Date) =>
|
|
|
691
716
|
<span class="rm-export__label">
|
|
692
717
|
{{ t.sheetsLabel }} ({{ config.sheets?.length ?? 0 }} {{ t.of }} {{ sheets.length }})
|
|
693
718
|
<button class="rm-export__mini" type="button" @click="config.sheets = [...sheets]">{{ t.sheetsAll }}</button>
|
|
694
|
-
<button class="rm-export__mini" type="button" @click="config.sheets = sheets.slice(0, 1)">{{ t.sheetsNone }}</button>
|
|
719
|
+
<button class="rm-export__mini" type="button" @click="config.sheets = requireSheets ? [] : sheets.slice(0, 1)">{{ t.sheetsNone }}</button>
|
|
695
720
|
</span>
|
|
696
721
|
<div class="rm-export__chips">
|
|
697
722
|
<button
|
|
@@ -727,6 +752,7 @@ const recentDate = (at: string | Date) =>
|
|
|
727
752
|
</div>
|
|
728
753
|
</div>
|
|
729
754
|
|
|
755
|
+
<p v-if="missingSheets" class="rm-export__hint">{{ t.sheetsRequired }}</p>
|
|
730
756
|
<p v-if="emptyForFormat" class="rm-export__hint">{{ t.nothing }}</p>
|
|
731
757
|
</div>
|
|
732
758
|
|
|
@@ -938,7 +964,8 @@ const recentDate = (at: string | Date) =>
|
|
|
938
964
|
variant="primary-fill"
|
|
939
965
|
size="sm"
|
|
940
966
|
prefix-icon="DownloadSimple"
|
|
941
|
-
:disabled="busy || emptyForFormat || format?.loading"
|
|
967
|
+
:disabled="busy || emptyForFormat || missingSheets || format?.loading"
|
|
968
|
+
:title="missingSheets ? t.sheetsRequired : undefined"
|
|
942
969
|
@click="launch"
|
|
943
970
|
>
|
|
944
971
|
{{ busy ? t.running : t.launch }}
|
|
@@ -37,6 +37,11 @@ export interface ExportSource {
|
|
|
37
37
|
filters?: RmExportFilter[];
|
|
38
38
|
/** Plages proposees a l'etape « Donnees ». Vide : pas de choix de plage. */
|
|
39
39
|
ranges?: RmExportRange[];
|
|
40
|
+
/**
|
|
41
|
+
* Les onglets du classeur se choisissent (cf. RmExportPanel
|
|
42
|
+
* `requireSheets`) : aucun coche d'office, pas de colonnes proposees.
|
|
43
|
+
*/
|
|
44
|
+
requireSheets?: boolean;
|
|
40
45
|
/**
|
|
41
46
|
* Plages qui partent avec TOUTES les colonnes : le choix des colonnes
|
|
42
47
|
* disparait du panneau et chaque onglet garde son schema entier.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Langue transmise par une autre app OIP (`?lang=fr`).
|
|
3
|
+
*
|
|
4
|
+
* Le portail oip7 et les apps n'ont ni le meme domaine ni la meme strategie
|
|
5
|
+
* i18n : sans ce relais, l'utilisateur qui lit oip7 en francais arrive dans
|
|
6
|
+
* l'app dans sa langue par defaut. Le lien sortant porte `lang` ; a l'arrivee
|
|
7
|
+
* on applique la langue puis on retire le parametre de l'URL.
|
|
8
|
+
*
|
|
9
|
+
* - Strategies a prefixe (`prefix_and_default`, `prefix`...) : redirection vers
|
|
10
|
+
* la meme route dans la langue demandee (`/hco/1?lang=fr` -> `/fr/hco/1`).
|
|
11
|
+
* - `no_prefix` : la langue n'est pas dans l'URL, on l'applique avec setLocale.
|
|
12
|
+
*
|
|
13
|
+
* Une langue inconnue de l'app est ignoree (le parametre est seulement retire).
|
|
14
|
+
*
|
|
15
|
+
* Les apps qui n'etendent pas le layer branchent la meme fonction dans un
|
|
16
|
+
* middleware global :
|
|
17
|
+
* import { localeFromQuery } from "@tekkare/romulus/layer-utils/localeFromQuery";
|
|
18
|
+
* export default defineNuxtRouteMiddleware(localeFromQuery);
|
|
19
|
+
*/
|
|
20
|
+
import type { RouteLocationNormalized } from "vue-router";
|
|
21
|
+
import { navigateTo, useLocalePath, useNuxtApp, useRouteBaseName } from "#imports";
|
|
22
|
+
|
|
23
|
+
export const LOCALE_QUERY_KEY = "lang";
|
|
24
|
+
|
|
25
|
+
export async function localeFromQuery(to: RouteLocationNormalized) {
|
|
26
|
+
const lang = to.query[LOCALE_QUERY_KEY];
|
|
27
|
+
if (lang === undefined) return;
|
|
28
|
+
|
|
29
|
+
const query = { ...to.query };
|
|
30
|
+
delete query[LOCALE_QUERY_KEY];
|
|
31
|
+
const stripped = { path: to.path, query, hash: to.hash };
|
|
32
|
+
|
|
33
|
+
const i18n = useNuxtApp().$i18n as any;
|
|
34
|
+
const codes: string[] = i18n?.localeCodes?.value ?? [];
|
|
35
|
+
if (typeof lang !== "string" || !codes.includes(lang)) {
|
|
36
|
+
return navigateTo(stripped, { replace: true });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const baseName = useRouteBaseName()(to);
|
|
40
|
+
const target = baseName
|
|
41
|
+
? useLocalePath()({ name: baseName, params: to.params, query, hash: to.hash }, lang)
|
|
42
|
+
: "";
|
|
43
|
+
|
|
44
|
+
// Strategie a prefixe : la langue vit dans l'URL, la redirection suffit.
|
|
45
|
+
if (target && target.split(/[?#]/)[0] !== to.path) {
|
|
46
|
+
return navigateTo(target, { replace: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// no_prefix (ou deja dans la bonne langue) : appliquer puis nettoyer l'URL.
|
|
50
|
+
if (i18n.locale?.value !== lang) await i18n.setLocale(lang);
|
|
51
|
+
return navigateTo(stripped, { replace: true });
|
|
52
|
+
}
|