@tekkare/romulus 0.1.282 → 0.1.283
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/CardActions.vue +27 -8
- package/dist/runtime/composables/useRmCardActions.d.ts +27 -14
- package/dist/runtime/composables/useRmCardActions.js +36 -19
- package/layer/app/components/OipShell.vue +8 -0
- package/layer/app/components/layout/tool/export.vue +134 -5
- package/layer/app/composables/useExportSource.ts +32 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
26
26
|
import type { RmExportPayload, RmExportSource } from '../utils/export'
|
|
27
27
|
import { rmCardCharts, rmCardOf } from '../utils/cardData'
|
|
28
|
-
import { useRmCardActions } from '../composables/useRmCardActions'
|
|
28
|
+
import { rmCardExportHandler, useRmCardActions } from '../composables/useRmCardActions'
|
|
29
29
|
|
|
30
30
|
const props = withDefaults(defineProps<{
|
|
31
31
|
/** Langue du menu. Le reste de la carte garde la sienne. */
|
|
@@ -170,6 +170,32 @@ async function act(action: 'png' | 'svg' | 'csv' | 'xlsx' | 'link') {
|
|
|
170
170
|
const card = cardEl()
|
|
171
171
|
if (!card || busy.value) return
|
|
172
172
|
|
|
173
|
+
const events = {
|
|
174
|
+
png: 'exportPng',
|
|
175
|
+
svg: 'exportSvg',
|
|
176
|
+
csv: 'exportCsv',
|
|
177
|
+
xlsx: 'exportXlsx',
|
|
178
|
+
link: 'copyLink',
|
|
179
|
+
} as const
|
|
180
|
+
|
|
181
|
+
// Le cadre a un panneau Export : le fichier s'y prepare, comme ceux de la
|
|
182
|
+
// page. Le lien, lui, se copie sur place.
|
|
183
|
+
const handler = rmCardExportHandler()
|
|
184
|
+
if (handler && action !== 'link') {
|
|
185
|
+
menuOpen.value = false
|
|
186
|
+
handler({
|
|
187
|
+
action,
|
|
188
|
+
card,
|
|
189
|
+
lang: props.lang,
|
|
190
|
+
name: props.name,
|
|
191
|
+
link: props.link,
|
|
192
|
+
sources: props.sources,
|
|
193
|
+
payload: props.payload,
|
|
194
|
+
})
|
|
195
|
+
emit(events[action])
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
|
|
173
199
|
busy.value = true
|
|
174
200
|
note.value = t.value.working
|
|
175
201
|
try {
|
|
@@ -202,13 +228,6 @@ async function act(action: 'png' | 'svg' | 'csv' | 'xlsx' | 'link') {
|
|
|
202
228
|
busy.value = false
|
|
203
229
|
}
|
|
204
230
|
|
|
205
|
-
const events = {
|
|
206
|
-
png: 'exportPng',
|
|
207
|
-
svg: 'exportSvg',
|
|
208
|
-
csv: 'exportCsv',
|
|
209
|
-
xlsx: 'exportXlsx',
|
|
210
|
-
link: 'copyLink',
|
|
211
|
-
} as const
|
|
212
231
|
emit(events[action])
|
|
213
232
|
}
|
|
214
233
|
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useRmCardActions - ce que fait le menu en haut a droite d'une carte.
|
|
3
|
-
*
|
|
4
|
-
* Le menu est le meme sur toutes les cartes du portail, donc son travail vit
|
|
5
|
-
* dans le paquet : deux apps ne peuvent pas sortir le PNG d'un graphique avec
|
|
6
|
-
* deux en-tetes differents, ni nommer leurs fichiers autrement. Les fichiers
|
|
7
|
-
* sont produits par les generateurs du panneau d'export (`useRmExport`), pas
|
|
8
|
-
* par une seconde chaine parallele : la carte n'est qu'un perimetre plus
|
|
9
|
-
* etroit que la page.
|
|
10
|
-
*
|
|
11
|
-
* La donnee, elle, est relue dans le DOM de la carte (`rmCardSheets`) faute
|
|
12
|
-
* d'une declaration de la page : c'est ce qui rend le menu utilisable sur les
|
|
13
|
-
* cartes deja ecrites, sans les rouvrir une par une.
|
|
14
|
-
*/
|
|
15
1
|
import type { RmExportPayload, RmExportSource } from '../utils/export.js';
|
|
16
2
|
/** Les actions qu'une carte propose. `link` copie, il ne telecharge pas. */
|
|
17
3
|
export type RmCardAction = 'png' | 'svg' | 'csv' | 'xlsx' | 'link';
|
|
@@ -44,6 +30,33 @@ export interface RmCardActionContext {
|
|
|
44
30
|
*/
|
|
45
31
|
payload?: RmCardPayload | (() => RmCardPayload | null | undefined | Promise<RmCardPayload | null | undefined>);
|
|
46
32
|
}
|
|
33
|
+
/** Un export de fichier demande depuis le menu d'une carte. */
|
|
34
|
+
export type RmCardFileAction = Exclude<RmCardAction, 'link'>;
|
|
35
|
+
export interface RmCardExportRequest extends RmCardActionContext {
|
|
36
|
+
action: RmCardFileAction;
|
|
37
|
+
}
|
|
38
|
+
export type RmCardExportHandler = (request: RmCardExportRequest) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Detourne les exports de fichier du menu des cartes vers le panneau d'export
|
|
41
|
+
* du cadre. A appeler dans le `setup` du cadre (layout) : un cadre qui a un
|
|
42
|
+
* panneau Export y fait passer tous les exports, pour qu'on y retrouve les
|
|
43
|
+
* memes etapes (format, colonnes, mise en page) et l'historique « Mes
|
|
44
|
+
* exports », au lieu d'un fichier telecharge sans rien demander. Sans cadre,
|
|
45
|
+
* le menu telecharge directement.
|
|
46
|
+
*/
|
|
47
|
+
export declare function provideRmCardExportHandler(handler: RmCardExportHandler): void;
|
|
48
|
+
/** Le gestionnaire pose par le cadre, s'il y en a un. */
|
|
49
|
+
export declare function rmCardExportHandler(): RmCardExportHandler | null;
|
|
50
|
+
/**
|
|
51
|
+
* Ce qu'une carte donne a exporter : titre, onglets (ceux de la page, sinon
|
|
52
|
+
* relus dans le DOM), graphiques, sources. Partage par le telechargement
|
|
53
|
+
* direct et par le panneau du cadre : une carte sort le meme fichier par les
|
|
54
|
+
* deux chemins.
|
|
55
|
+
*/
|
|
56
|
+
export declare function rmCardExportPayload(context: RmCardActionContext, withSheets?: boolean): Promise<{
|
|
57
|
+
fileName: string;
|
|
58
|
+
payload: RmExportPayload;
|
|
59
|
+
}>;
|
|
47
60
|
export declare function useRmCardActions(): {
|
|
48
61
|
runCardAction: (action: RmCardAction, context: RmCardActionContext) => Promise<import("./useRmExport").RmExportResult>;
|
|
49
62
|
toggleCardFullscreen: (card: Element) => Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getCurrentScope, onScopeDispose, shallowRef } from "vue";
|
|
1
2
|
import { rmCardCharts, rmCardSheets, rmCardTags, rmCardTitle } from "../utils/cardData.js";
|
|
2
3
|
import { useRmExport } from "./useRmExport.js";
|
|
3
4
|
import { rmExportDefaults } from "./useRmExportDefaults.js";
|
|
@@ -38,28 +39,44 @@ function closeZoom() {
|
|
|
38
39
|
function onZoomKey(event) {
|
|
39
40
|
if (event.key === "Escape") closeZoom();
|
|
40
41
|
}
|
|
42
|
+
const cardExportHandler = shallowRef(null);
|
|
43
|
+
export function provideRmCardExportHandler(handler) {
|
|
44
|
+
cardExportHandler.value = handler;
|
|
45
|
+
if (getCurrentScope()) {
|
|
46
|
+
onScopeDispose(() => {
|
|
47
|
+
if (cardExportHandler.value === handler) cardExportHandler.value = null;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function rmCardExportHandler() {
|
|
52
|
+
return cardExportHandler.value;
|
|
53
|
+
}
|
|
54
|
+
export async function rmCardExportPayload(context, withSheets = true) {
|
|
55
|
+
const { card, lang = "fr" } = context;
|
|
56
|
+
const provided = await (typeof context.payload === "function" ? context.payload() : context.payload) ?? {};
|
|
57
|
+
const defaults = rmExportDefaults();
|
|
58
|
+
const title = context.name || provided.title || rmCardTitle(card) || "Export";
|
|
59
|
+
const sources = provided.sources?.length ? provided.sources : defaults.sources?.length ? defaults.sources : context.sources;
|
|
60
|
+
const sheets = !withSheets ? [] : provided.sheets?.length ? provided.sheets : await rmCardSheets(card, title, lang);
|
|
61
|
+
const payload = {
|
|
62
|
+
...defaults,
|
|
63
|
+
title,
|
|
64
|
+
charts: rmCardCharts(card).map((el) => ({ title, el, tags: rmCardTags(card) })),
|
|
65
|
+
// Le lien de la carte, sinon celui du cadre : le permalien de la page
|
|
66
|
+
// porte la vue et les filtres, la ou l'URL courante ne dit rien de ce
|
|
67
|
+
// qui est affiche.
|
|
68
|
+
permalink: absolute(context.link) ?? defaults.permalink,
|
|
69
|
+
...provided,
|
|
70
|
+
sheets,
|
|
71
|
+
sources
|
|
72
|
+
};
|
|
73
|
+
return { fileName: fileNameOf(title), payload };
|
|
74
|
+
}
|
|
41
75
|
export function useRmCardActions() {
|
|
42
76
|
const { run } = useRmExport();
|
|
43
77
|
async function runCardAction(action, context) {
|
|
44
|
-
const {
|
|
45
|
-
|
|
46
|
-
const defaults = rmExportDefaults();
|
|
47
|
-
const title = context.name || provided.title || rmCardTitle(card) || "Export";
|
|
48
|
-
const sources = provided.sources?.length ? provided.sources : defaults.sources?.length ? defaults.sources : context.sources;
|
|
49
|
-
const format = action === "link" ? "link" : action;
|
|
50
|
-
const sheets = action === "png" || action === "svg" ? [] : provided.sheets?.length ? provided.sheets : await rmCardSheets(card, title, lang);
|
|
51
|
-
return run(configOf(format, fileNameOf(title)), {
|
|
52
|
-
...defaults,
|
|
53
|
-
title,
|
|
54
|
-
charts: rmCardCharts(card).map((el) => ({ title, el, tags: rmCardTags(card) })),
|
|
55
|
-
// Le lien de la carte, sinon celui du cadre : le permalien de la page
|
|
56
|
-
// porte la vue et les filtres, la ou l'URL courante ne dit rien de ce
|
|
57
|
-
// qui est affiche.
|
|
58
|
-
permalink: absolute(context.link) ?? defaults.permalink,
|
|
59
|
-
...provided,
|
|
60
|
-
sheets,
|
|
61
|
-
sources
|
|
62
|
-
}, lang);
|
|
78
|
+
const { fileName, payload } = await rmCardExportPayload(context, action !== "png" && action !== "svg");
|
|
79
|
+
return run(configOf(action, fileName), payload, context.lang ?? "fr");
|
|
63
80
|
}
|
|
64
81
|
async function toggleCardFullscreen(card) {
|
|
65
82
|
if (typeof document === "undefined") return;
|
|
@@ -99,6 +99,14 @@ const props = withDefaults(
|
|
|
99
99
|
/** Tuile ouverte, ou null quand la toolbar est fermee. */
|
|
100
100
|
const tool = defineModel<string | null>("tool", { default: null });
|
|
101
101
|
|
|
102
|
+
// Un export demande depuis le menu d'une carte se prepare dans la tuile
|
|
103
|
+
// Export, comme ceux de la page. Une app qui garde son propre
|
|
104
|
+
// `useExportSource` n'a pas de demande de carte : son menu telecharge direct.
|
|
105
|
+
const cardExport = useExportSource().card;
|
|
106
|
+
watch(() => cardExport?.value, (request) => {
|
|
107
|
+
if (request && tool.value !== "Export") tool.value = "Export";
|
|
108
|
+
});
|
|
109
|
+
|
|
102
110
|
const config = useAppConfig().oip;
|
|
103
111
|
const route = useRoute();
|
|
104
112
|
const { locale, locales, setLocale } = useI18n();
|
|
@@ -12,11 +12,19 @@
|
|
|
12
12
|
-->
|
|
13
13
|
<template>
|
|
14
14
|
<div v-if="source" class="oip_export_tool">
|
|
15
|
+
<!-- Export demande depuis le menu d'une carte : le panneau s'y limite, et
|
|
16
|
+
dit comment revenir a la page entiere. -->
|
|
17
|
+
<RmCallout v-if="cardSource" tone="info" icon="SquaresFour" class="oip_export_notice">
|
|
18
|
+
{{ cardText }}
|
|
19
|
+
<template #actions>
|
|
20
|
+
<RmButton variant="tertiary" size="sm" @click="card = null">{{ wholePageText }}</RmButton>
|
|
21
|
+
</template>
|
|
22
|
+
</RmCallout>
|
|
15
23
|
<!-- Une page d'analyse ne montre rien tant qu'aucune vue n'est posee : ses
|
|
16
24
|
onglets d'export sont donc vides, et les formats de donnees sortent
|
|
17
25
|
grises avec « aucun tableau sur cette page », ce qui laisse croire que
|
|
18
26
|
la page n'exporte jamais. Le vrai motif est dit ici. -->
|
|
19
|
-
<RmCallout v-if="needsView" tone="info" icon="BookmarkSimple" class="oip_export_notice">
|
|
27
|
+
<RmCallout v-else-if="needsView" tone="info" icon="BookmarkSimple" class="oip_export_notice">
|
|
20
28
|
{{ emptyText }}
|
|
21
29
|
</RmCallout>
|
|
22
30
|
<!-- La page refuse d'exporter sa donnee (selection trop large) : dit ici,
|
|
@@ -25,7 +33,25 @@
|
|
|
25
33
|
{{ source.blocked }}
|
|
26
34
|
</RmCallout>
|
|
27
35
|
|
|
36
|
+
<!-- Fichiers prets de la page (classeur source d'un rapport). -->
|
|
37
|
+
<div v-if="!cardSource && source.files?.length" class="oip_export_files">
|
|
38
|
+
<p class="oip_export_files__title">{{ filesText }}</p>
|
|
39
|
+
<a
|
|
40
|
+
v-for="file in source.files"
|
|
41
|
+
:key="file.href"
|
|
42
|
+
class="oip_export_file"
|
|
43
|
+
:href="file.href"
|
|
44
|
+
:download="file.fileName"
|
|
45
|
+
@click="trackFile(file.fileName)"
|
|
46
|
+
>
|
|
47
|
+
<RmIcon name="FileXls" :size="18" />
|
|
48
|
+
<span>{{ file.label }}</span>
|
|
49
|
+
<RmIcon name="DownloadSimple" :size="16" class="oip_export_file__go" />
|
|
50
|
+
</a>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
28
53
|
<RmExportPanel
|
|
54
|
+
:key="card?.at ?? 'page'"
|
|
29
55
|
:file-name="source.fileName"
|
|
30
56
|
:formats="formats"
|
|
31
57
|
:sections="sections"
|
|
@@ -59,7 +85,59 @@ import { oipTrack } from "#oip-app/ui";
|
|
|
59
85
|
import { useExportTracking } from "#oip-app/export";
|
|
60
86
|
|
|
61
87
|
const { locale } = useI18n();
|
|
62
|
-
const { current:
|
|
88
|
+
const { current: pageSource, pageSources, quick, card } = useExportSource();
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Source tiree de la carte dont le menu a demande l'export : son titre, ses
|
|
92
|
+
* onglets (ceux de la page, sinon relus dans son DOM), ses graphiques. Les
|
|
93
|
+
* onglets demandent parfois une requete : calculee une fois, a la demande.
|
|
94
|
+
*/
|
|
95
|
+
const cardSource = shallowRef<ExportSource | null>(null);
|
|
96
|
+
watch(
|
|
97
|
+
card,
|
|
98
|
+
async (request) => {
|
|
99
|
+
if (!request) {
|
|
100
|
+
cardSource.value = null;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const { fileName, payload } = await rmCardExportPayload(request);
|
|
104
|
+
if (card.value !== request) return;
|
|
105
|
+
cardSource.value = {
|
|
106
|
+
title: payload.title,
|
|
107
|
+
subtitle: payload.subtitle,
|
|
108
|
+
fileName,
|
|
109
|
+
sheets: payload.sheets ?? [],
|
|
110
|
+
kpi: payload.kpi,
|
|
111
|
+
sources: payload.sources,
|
|
112
|
+
charts: () => payload.charts ?? [],
|
|
113
|
+
screen: () => ({ sheets: payload.sheets ?? [], kpi: payload.kpi }),
|
|
114
|
+
layout: "table",
|
|
115
|
+
permalink: payload.permalink ? () => payload.permalink! : undefined,
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
{ immediate: true },
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// Fermer le panneau clot la demande : rouvert depuis le rail, il exporte la page.
|
|
122
|
+
onBeforeUnmount(() => {
|
|
123
|
+
card.value = null;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/** La carte si son menu a demande l'export, la page sinon. */
|
|
127
|
+
const source = computed(() => (card.value ? cardSource.value : pageSource.value));
|
|
128
|
+
|
|
129
|
+
const cardText = computed(() =>
|
|
130
|
+
locale.value === "en"
|
|
131
|
+
? `Export limited to the card "${cardSource.value?.title ?? ""}".`
|
|
132
|
+
: `Export limité à la carte « ${cardSource.value?.title ?? ""} ».`,
|
|
133
|
+
);
|
|
134
|
+
const filesText = computed(() => (locale.value === "en" ? "Ready-made files" : "Fichiers prêts"));
|
|
135
|
+
|
|
136
|
+
function trackFile(fileName: string) {
|
|
137
|
+
oipTrack("download", getExportPosthogProps(fileName, { exportType: "file", format: fileName.split(".").pop() ?? "" }));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const wholePageText = computed(() => (locale.value === "en" ? "Export the whole page" : "Exporter toute la page"));
|
|
63
141
|
const { run } = useRmExport();
|
|
64
142
|
const { getExportPosthogProps } = useExportTracking();
|
|
65
143
|
const saved = useSavedExports();
|
|
@@ -116,6 +194,10 @@ function pageSheets() {
|
|
|
116
194
|
* system, ou a defaut les blocs de la page (cf. visibleExportNodes).
|
|
117
195
|
*/
|
|
118
196
|
function pageNodes() {
|
|
197
|
+
if (card.value) {
|
|
198
|
+
const el = card.value.card;
|
|
199
|
+
return [{ kind: (cardSource.value?.charts?.().length ? "chart" : "table") as "chart" | "table", el, title: cardSource.value?.title }];
|
|
200
|
+
}
|
|
119
201
|
return visibleExportNodes();
|
|
120
202
|
}
|
|
121
203
|
|
|
@@ -132,6 +214,7 @@ const views = useViews();
|
|
|
132
214
|
*/
|
|
133
215
|
const needsView = computed(
|
|
134
216
|
() =>
|
|
217
|
+
!card.value &&
|
|
135
218
|
!!views.current.value &&
|
|
136
219
|
(source.value?.sheets.length ?? 0) === 0 &&
|
|
137
220
|
views.criteriaOf().filter((item: any) => viewFilledValues(item).length > 0).length === 0,
|
|
@@ -170,7 +253,7 @@ const formats = computed(() => {
|
|
|
170
253
|
|
|
171
254
|
const blocked = source.value?.blocked;
|
|
172
255
|
|
|
173
|
-
|
|
256
|
+
const mapped = base.map((format) => {
|
|
174
257
|
// Un format qui emporte des enregistrements (tableau ou rapport) sort
|
|
175
258
|
// grise quand la page refuse : le motif est dans le bandeau au-dessus.
|
|
176
259
|
if (blocked && (format.tabular || format.paged)) {
|
|
@@ -189,6 +272,10 @@ const formats = computed(() => {
|
|
|
189
272
|
}
|
|
190
273
|
return format;
|
|
191
274
|
});
|
|
275
|
+
// Le format clique dans le menu de la carte ouvre le wizard : le panneau
|
|
276
|
+
// part du premier format utilisable.
|
|
277
|
+
const asked = card.value?.action;
|
|
278
|
+
return asked ? [...mapped].sort((a, b) => Number(b.key === asked) - Number(a.key === asked)) : mapped;
|
|
192
279
|
});
|
|
193
280
|
|
|
194
281
|
/**
|
|
@@ -317,6 +404,8 @@ const templates = computed<RmExportTemplate[]>(() => {
|
|
|
317
404
|
// « Data brute Excel » ne dit pas quoi, sur un ecran qui porte dix onglets
|
|
318
405
|
// de natures differentes, part dans le fichier. La page les nomme, le cadre
|
|
319
406
|
// garde les tuiles dont le libelle ne depend pas de l'ecran (PDF, lien).
|
|
407
|
+
// Une carte va droit au wizard, sur le format clique.
|
|
408
|
+
if (card.value) return [];
|
|
320
409
|
const declared = source.value?.templates ?? [];
|
|
321
410
|
const catalog = declared.length
|
|
322
411
|
? all.flatMap((template) => (template.key === "xlsx-raw" ? declared : [template]))
|
|
@@ -359,7 +448,7 @@ onMounted(async () => {
|
|
|
359
448
|
// Le cadre monte ce panneau quand la tuile s'ouvre : c'est le moment ou une
|
|
360
449
|
// page qui ne garde pas ses lignes va les chercher, pour que l'etape
|
|
361
450
|
// « Colonnes » ait de quoi parler.
|
|
362
|
-
await
|
|
451
|
+
await pageSource.value?.prepare?.();
|
|
363
452
|
await quickLaunch();
|
|
364
453
|
});
|
|
365
454
|
|
|
@@ -505,7 +594,7 @@ async function launch(config: RmExportConfig, replaces?: string) {
|
|
|
505
594
|
oipTrack(
|
|
506
595
|
"download",
|
|
507
596
|
getExportPosthogProps(now.posthogName ?? now.fileName, {
|
|
508
|
-
exportType: "page",
|
|
597
|
+
exportType: card.value ? "card" : "page",
|
|
509
598
|
format: config.format,
|
|
510
599
|
rows: result.rows,
|
|
511
600
|
sections: config.sections.join(","),
|
|
@@ -587,4 +676,44 @@ function forget(id: string) {
|
|
|
587
676
|
.oip_export_notice {
|
|
588
677
|
margin-bottom: 16px;
|
|
589
678
|
}
|
|
679
|
+
|
|
680
|
+
.oip_export_files {
|
|
681
|
+
display: flex;
|
|
682
|
+
flex-direction: column;
|
|
683
|
+
gap: 8px;
|
|
684
|
+
margin-bottom: 20px;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.oip_export_files__title {
|
|
688
|
+
margin: 0;
|
|
689
|
+
font-size: var(--font-12);
|
|
690
|
+
font-weight: var(--weight-semibold);
|
|
691
|
+
color: var(--text-muted);
|
|
692
|
+
text-transform: uppercase;
|
|
693
|
+
letter-spacing: 0.04em;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
.oip_export_file {
|
|
697
|
+
display: flex;
|
|
698
|
+
gap: 10px;
|
|
699
|
+
align-items: center;
|
|
700
|
+
padding: 10px 12px;
|
|
701
|
+
font-size: var(--font-13);
|
|
702
|
+
color: var(--text-primary);
|
|
703
|
+
text-decoration: none;
|
|
704
|
+
background: var(--bg-surface);
|
|
705
|
+
border: 1px solid var(--border-default);
|
|
706
|
+
border-radius: 10px;
|
|
707
|
+
transition: border-color 0.15s ease, color 0.15s ease;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
.oip_export_file:hover {
|
|
711
|
+
color: var(--color-primary);
|
|
712
|
+
border-color: var(--color-primary);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.oip_export_file__go {
|
|
716
|
+
margin-left: auto;
|
|
717
|
+
color: var(--text-muted);
|
|
718
|
+
}
|
|
590
719
|
</style>
|
|
@@ -130,6 +130,13 @@ export interface ExportSource {
|
|
|
130
130
|
beforeExport?: (range: string) => void | Promise<void>;
|
|
131
131
|
/** Nom de l'export dans PostHog. Defaut : le nom de fichier. */
|
|
132
132
|
posthogName?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Fichiers deja prets que la page met a disposition (le classeur source
|
|
135
|
+
* d'un rapport) : listes en tete du panneau, pour que tout ce qui se
|
|
136
|
+
* telecharge depuis l'ecran passe par la tuile Export plutot que par un
|
|
137
|
+
* bouton d'en-tete.
|
|
138
|
+
*/
|
|
139
|
+
files?: { label: string; href: string; fileName: string }[];
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
/**
|
|
@@ -156,6 +163,16 @@ const pageSources = shallowRef<RmSource[]>([]);
|
|
|
156
163
|
*/
|
|
157
164
|
const quick = useState<string | null>("export:quick", () => null);
|
|
158
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Export demande depuis le menu d'une carte (CSV, XLSX, PNG, SVG). Le menu ne
|
|
168
|
+
* telecharge plus lui-meme : il pose sa demande ici, le cadre ouvre la tuile
|
|
169
|
+
* Export et le panneau se limite a la carte, format clique preselectionne.
|
|
170
|
+
* Un `shallowRef` de module et pas un `useState` : la demande porte le noeud
|
|
171
|
+
* de la carte, qui ne se serialise pas.
|
|
172
|
+
*/
|
|
173
|
+
type CardExportRequest = Parameters<Parameters<typeof provideRmCardExportHandler>[0]>[0];
|
|
174
|
+
const card = shallowRef<(CardExportRequest & { at: number }) | null>(null);
|
|
175
|
+
|
|
159
176
|
/**
|
|
160
177
|
* Declare les sources de la page a partir des uuids que le cadre suit deja
|
|
161
178
|
* pour son panneau « Sources ». A appeler dans le `setup` du layout.
|
|
@@ -195,6 +212,18 @@ export function providePageExportSources(uuids: Ref<string[]>) {
|
|
|
195
212
|
});
|
|
196
213
|
|
|
197
214
|
provideRmExportDefaults(() => ({ sources: pageSources.value, permalink: pageLink.value }));
|
|
215
|
+
|
|
216
|
+
// Le menu des cartes passe par le panneau Export ; une demande ne survit
|
|
217
|
+
// pas a la navigation, sa carte n'est plus a l'ecran.
|
|
218
|
+
provideRmCardExportHandler((request) => {
|
|
219
|
+
card.value = { ...request, at: Date.now() };
|
|
220
|
+
});
|
|
221
|
+
watch(
|
|
222
|
+
() => route.path,
|
|
223
|
+
() => {
|
|
224
|
+
card.value = null;
|
|
225
|
+
},
|
|
226
|
+
);
|
|
198
227
|
}
|
|
199
228
|
|
|
200
229
|
export function useExportSource() {
|
|
@@ -226,10 +255,12 @@ export function useExportSource() {
|
|
|
226
255
|
declare,
|
|
227
256
|
/** Format d'un export a lancer des que le panneau s'ouvre (cf. ci-dessus). */
|
|
228
257
|
quick,
|
|
258
|
+
/** Export d'une seule carte, demande par son menu (cf. ci-dessus). */
|
|
259
|
+
card,
|
|
229
260
|
/** La source courante, relue a chaque acces : elle suit les filtres. */
|
|
230
261
|
current: computed(() => registry.value?.() ?? null),
|
|
231
262
|
/** Vrai quand la page declare une source qui a effectivement du contenu. */
|
|
232
|
-
has: computed(() => (registry.value?.() ?? null) !== null),
|
|
263
|
+
has: computed(() => !!card.value || (registry.value?.() ?? null) !== null),
|
|
233
264
|
/** Sources Directus de la page, avec leur date de mise a jour. */
|
|
234
265
|
pageSources: computed(() => pageSources.value),
|
|
235
266
|
};
|