@tekkare/romulus 0.1.261 → 0.1.262
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/layer/app/components/panels/OipPanelProjects.vue +70 -21
- package/layer/app/components/project/AddButton.vue +127 -0
- package/layer/app/components/project/Banner.vue +68 -0
- package/layer/app/components/project/Dashboard.vue +85 -0
- package/layer/app/components/project/DiscardConfirm.vue +74 -0
- package/layer/app/components/project/Documents.vue +611 -0
- package/layer/app/components/project/Export.vue +205 -0
- package/layer/app/components/project/Inbox.vue +1241 -0
- package/layer/app/components/project/ListPage.vue +102 -0
- package/layer/app/components/project/NewButton.vue +147 -0
- package/layer/app/components/project/Notes.vue +1158 -0
- package/layer/app/components/project/Page.vue +820 -0
- package/layer/app/components/project/Share.vue +135 -0
- package/layer/app/components/project/Watch.vue +273 -0
- package/layer/app/composables/useOipProjectKinds.ts +71 -0
- package/layer/app/composables/useOipResourceHooks.ts +8 -3
- package/layer/app/composables/useProjectDashboard.ts +22 -0
- package/layer/app/composables/useProjects.ts +646 -0
- package/layer/app/oip-defaults/projects.ts +175 -0
- package/layer/app/pages/projects/[id].vue +8 -0
- package/layer/app/pages/projects/index.vue +8 -0
- package/layer/app/types/projects.ts +168 -0
- package/layer/app/utils/projectNoteWelcome.ts +137 -0
- package/layer/nuxt.config.ts +16 -0
- package/layer/server/api/oip/sharing/artifacts.get.ts +44 -0
- package/package.json +2 -1
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Onglet « Documents » d'un projet.
|
|
3
|
+
|
|
4
|
+
Un projet ne rassemble pas que des fiches de l'app : il recoit aussi les
|
|
5
|
+
fichiers que l'utilisateur depose (un compte rendu, une note, un tableau).
|
|
6
|
+
L'API en extrait le texte a l'envoi, d'ou l'apercu : ce qui s'affiche ici est
|
|
7
|
+
ce que le projet a vraiment retenu du fichier, pas le fichier lui-meme.
|
|
8
|
+
|
|
9
|
+
Un depot qui contient des donnees personnelles est refuse par l'API (422).
|
|
10
|
+
Le message qu'elle rend nomme les categories trouvees : il s'affiche tel
|
|
11
|
+
quel, parce qu'un « echec de l'envoi » generique laisserait chercher.
|
|
12
|
+
-->
|
|
13
|
+
<template>
|
|
14
|
+
<div class="project_pd">
|
|
15
|
+
<div class="project_pd_head">
|
|
16
|
+
<p class="project_pd_count">
|
|
17
|
+
{{ rows.length }} {{ rows.length > 1 ? "documents" : "document" }}
|
|
18
|
+
</p>
|
|
19
|
+
<RmButton variant="primary" size="sm" prefix-icon="UploadSimple" :loading="uploading" @click="pick">
|
|
20
|
+
{{ locale === "en" ? "Upload a document" : "Déposer un document" }}
|
|
21
|
+
</RmButton>
|
|
22
|
+
<input
|
|
23
|
+
ref="input"
|
|
24
|
+
type="file"
|
|
25
|
+
class="project_pd_input"
|
|
26
|
+
accept=".pdf,.txt,.md,.csv,.xlsx,application/pdf,text/plain,text/markdown,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
27
|
+
@change="onPick"
|
|
28
|
+
/>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<RmCallout v-if="refusal" tone="danger">
|
|
32
|
+
<p class="project_pd_refusal_title">{{ refusalTitle }}</p>
|
|
33
|
+
<p class="project_pd_refusal_text">{{ refusal }}</p>
|
|
34
|
+
</RmCallout>
|
|
35
|
+
|
|
36
|
+
<RmLoadingState v-if="loading" spinner :label="locale === 'en' ? 'Loading' : 'Chargement'" />
|
|
37
|
+
|
|
38
|
+
<RmCallout v-else-if="loadFailed" tone="danger">
|
|
39
|
+
<p class="project_pd_refusal_title">
|
|
40
|
+
{{ locale === "en" ? "Documents unavailable" : "Documents indisponibles" }}
|
|
41
|
+
</p>
|
|
42
|
+
<p class="project_pd_refusal_text">
|
|
43
|
+
{{
|
|
44
|
+
locale === "en"
|
|
45
|
+
? "The list could not be loaded. Reload the page to try again."
|
|
46
|
+
: "La liste n'a pas pu être chargée. Rechargez la page pour réessayer."
|
|
47
|
+
}}
|
|
48
|
+
</p>
|
|
49
|
+
</RmCallout>
|
|
50
|
+
|
|
51
|
+
<RmEmptyState
|
|
52
|
+
v-else-if="!rows.length"
|
|
53
|
+
icon="FilePlus"
|
|
54
|
+
:title="locale === 'en' ? 'No document yet' : 'Aucun document'"
|
|
55
|
+
:text="
|
|
56
|
+
locale === 'en'
|
|
57
|
+
? 'A PDF, a note, a table: what you drop here is read alongside the records of the project.'
|
|
58
|
+
: 'Un PDF, une note, un tableau : ce que vous déposez ici se lit à côté des fiches du projet.'
|
|
59
|
+
"
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
<!-- Une seule liste, du plus recent au plus ancien : ce que les membres ont
|
|
63
|
+
depose et ce que Tekkare a partage se distinguent par leur badge. -->
|
|
64
|
+
<RmCard v-else padding="sm">
|
|
65
|
+
<div class="project_pd_list">
|
|
66
|
+
<div v-for="row in rows" :key="row.key" class="project_pd_row">
|
|
67
|
+
<RmFileRow
|
|
68
|
+
:name="row.name"
|
|
69
|
+
:format="row.format"
|
|
70
|
+
:size="row.size"
|
|
71
|
+
:action="row.artifact ? 'open' : 'preview'"
|
|
72
|
+
@select="row.artifact ? openShared(row.artifact) : openPreview(row.document!)"
|
|
73
|
+
/>
|
|
74
|
+
<span v-if="row.document?.status === 'no_text'" class="project_pd_flag">
|
|
75
|
+
{{ locale === "en" ? "No readable text" : "Aucun texte lisible" }}
|
|
76
|
+
</span>
|
|
77
|
+
<RmBadge class="project_pd_tag" :variant="row.artifact ? 'info' : 'grey'">
|
|
78
|
+
{{ row.artifact ? (locale === "en" ? "Shared by Tekkare" : "Partagé par Tekkare") : locale === "en" ? "Uploaded" : "Déposé" }}
|
|
79
|
+
</RmBadge>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</RmCard>
|
|
83
|
+
|
|
84
|
+
<RmDrawer v-model="previewing" size="xl" :label="opened?.title || ''">
|
|
85
|
+
<div class="project_pd_preview">
|
|
86
|
+
<div class="project_pd_preview_head">
|
|
87
|
+
<p class="project_pd_preview_title">{{ preview?.title || opened?.title }}</p>
|
|
88
|
+
<div class="project_pd_preview_actions">
|
|
89
|
+
<RmButton variant="tertiary" size="sm" prefix-icon="DownloadSimple" @click="download">
|
|
90
|
+
{{ locale === "en" ? "Download" : "Télécharger" }}
|
|
91
|
+
</RmButton>
|
|
92
|
+
<RmButton
|
|
93
|
+
variant="text-danger"
|
|
94
|
+
size="sm"
|
|
95
|
+
prefix-icon="Trash"
|
|
96
|
+
:loading="deleting"
|
|
97
|
+
@click="remove"
|
|
98
|
+
>
|
|
99
|
+
{{
|
|
100
|
+
confirming
|
|
101
|
+
? locale === "en"
|
|
102
|
+
? "Confirm removal"
|
|
103
|
+
: "Confirmer la suppression"
|
|
104
|
+
: locale === "en"
|
|
105
|
+
? "Remove"
|
|
106
|
+
: "Supprimer"
|
|
107
|
+
}}
|
|
108
|
+
</RmButton>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
<RmSegmented
|
|
113
|
+
v-if="viewable"
|
|
114
|
+
v-model="mode"
|
|
115
|
+
class="project_pd_mode"
|
|
116
|
+
:options="modeOptions"
|
|
117
|
+
size="sm"
|
|
118
|
+
variant="soft"
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
<template v-if="mode === 'file'">
|
|
122
|
+
<RmLoadingState v-if="filePending" spinner />
|
|
123
|
+
<RmEmptyState
|
|
124
|
+
v-else-if="!fileUrl"
|
|
125
|
+
icon="WarningCircle"
|
|
126
|
+
:title="locale === 'en' ? 'Document unavailable' : 'Document indisponible'"
|
|
127
|
+
:text="
|
|
128
|
+
locale === 'en'
|
|
129
|
+
? 'The file could not be opened here. Its extracted text remains readable.'
|
|
130
|
+
: 'Le fichier n\'a pas pu s\'ouvrir ici. Son texte extrait reste lisible.'
|
|
131
|
+
"
|
|
132
|
+
/>
|
|
133
|
+
<iframe v-else :src="fileUrl" :title="opened?.title" class="project_pd_frame" />
|
|
134
|
+
</template>
|
|
135
|
+
|
|
136
|
+
<RmLoadingState v-else-if="previewPending" spinner />
|
|
137
|
+
|
|
138
|
+
<RmEmptyState
|
|
139
|
+
v-else-if="previewFailed"
|
|
140
|
+
icon="WarningCircle"
|
|
141
|
+
:title="locale === 'en' ? 'Preview unavailable' : 'Aperçu indisponible'"
|
|
142
|
+
:text="
|
|
143
|
+
locale === 'en'
|
|
144
|
+
? 'The extracted text could not be loaded. The file itself can still be downloaded.'
|
|
145
|
+
: 'Le texte extrait n\'a pas pu être chargé. Le fichier reste téléchargeable.'
|
|
146
|
+
"
|
|
147
|
+
/>
|
|
148
|
+
|
|
149
|
+
<RmEmptyState
|
|
150
|
+
v-else-if="!preview?.sections?.length"
|
|
151
|
+
icon="FileDashed"
|
|
152
|
+
:title="locale === 'en' ? 'Nothing was extracted' : 'Rien n\'a été extrait'"
|
|
153
|
+
:text="
|
|
154
|
+
locale === 'en'
|
|
155
|
+
? 'The file is kept, but it carries no text layer to read (a scan, for instance).'
|
|
156
|
+
: 'Le fichier est conservé, mais il ne porte aucun texte à lire (un scan, par exemple).'
|
|
157
|
+
"
|
|
158
|
+
/>
|
|
159
|
+
|
|
160
|
+
<div v-else class="project_pd_sections">
|
|
161
|
+
<section v-for="section in preview.sections" :key="section.slug">
|
|
162
|
+
<p class="project_pd_section_name">{{ section.name }}</p>
|
|
163
|
+
<p class="project_pd_section_text">{{ section.text }}</p>
|
|
164
|
+
</section>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
</RmDrawer>
|
|
168
|
+
</div>
|
|
169
|
+
</template>
|
|
170
|
+
|
|
171
|
+
<script setup lang="ts">
|
|
172
|
+
import { useOipApi } from "#oip-app/api";
|
|
173
|
+
import { useExportTracking } from "#oip-app/export";
|
|
174
|
+
import { oipSnackbar, oipTrack } from "#oip-app/ui";
|
|
175
|
+
import type { SharedArtifact, UploadedDocument } from "../../types/projects";
|
|
176
|
+
|
|
177
|
+
const props = defineProps<{
|
|
178
|
+
projectId: string;
|
|
179
|
+
/** Un document a ouvrir des le chargement : celui choisi dans l'Inbox. */
|
|
180
|
+
openId?: string;
|
|
181
|
+
}>();
|
|
182
|
+
const emit = defineEmits<{
|
|
183
|
+
(event: "changed"): void;
|
|
184
|
+
/** Un document a ete ouvert : l'Inbox le compte comme lu. */
|
|
185
|
+
(event: "opened", id: string): void;
|
|
186
|
+
}>();
|
|
187
|
+
|
|
188
|
+
const { locale } = useI18n();
|
|
189
|
+
const api = useOipApi();
|
|
190
|
+
const { getExportPosthogProps } = useExportTracking();
|
|
191
|
+
|
|
192
|
+
const documents = ref<UploadedDocument[]>([]);
|
|
193
|
+
/**
|
|
194
|
+
* Les livrables publies sur share-platform pour ce projet. Lecture seule ici :
|
|
195
|
+
* ils se deposent et se suppriment depuis share-platform, et s'ouvrent dans
|
|
196
|
+
* son lecteur.
|
|
197
|
+
*/
|
|
198
|
+
const shared = ref<SharedArtifact[]>([]);
|
|
199
|
+
|
|
200
|
+
/** Les deux provenances dans une liste, du plus recent au plus ancien. */
|
|
201
|
+
const rows = computed(() =>
|
|
202
|
+
[
|
|
203
|
+
...documents.value.map((document) => ({
|
|
204
|
+
key: `doc-${document.id}`,
|
|
205
|
+
name: document.title,
|
|
206
|
+
format: document.mimeType,
|
|
207
|
+
size: fileSize(document),
|
|
208
|
+
date: document.createdAt ?? "",
|
|
209
|
+
document,
|
|
210
|
+
artifact: null as SharedArtifact | null,
|
|
211
|
+
})),
|
|
212
|
+
...shared.value.map((artifact) => ({
|
|
213
|
+
key: `shared-${artifact.id}`,
|
|
214
|
+
name: artifact.title || artifact.filename,
|
|
215
|
+
format: artifact.contentType,
|
|
216
|
+
size: formatBytes(artifact.size),
|
|
217
|
+
date: artifact.createdAt ?? "",
|
|
218
|
+
document: null as UploadedDocument | null,
|
|
219
|
+
artifact,
|
|
220
|
+
})),
|
|
221
|
+
].sort((a, b) => b.date.localeCompare(a.date)),
|
|
222
|
+
);
|
|
223
|
+
const loading = ref(true);
|
|
224
|
+
const loadFailed = ref(false);
|
|
225
|
+
const uploading = ref(false);
|
|
226
|
+
const refusal = ref("");
|
|
227
|
+
const input = ref<HTMLInputElement | null>(null);
|
|
228
|
+
|
|
229
|
+
const previewing = ref(false);
|
|
230
|
+
const previewPending = ref(false);
|
|
231
|
+
const preview = ref<any>(null);
|
|
232
|
+
const previewFailed = ref(false);
|
|
233
|
+
const mode = ref<"file" | "text">("text");
|
|
234
|
+
const fileUrl = ref("");
|
|
235
|
+
const filePending = ref(false);
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Le navigateur n'affiche lui-meme que le PDF et le texte brut : un CSV ou un
|
|
239
|
+
* Markdown servi tel quel partirait en telechargement au lieu de s'afficher.
|
|
240
|
+
* Pour ceux-la, seul le texte extrait se lit dans le tiroir.
|
|
241
|
+
*/
|
|
242
|
+
const INLINE_TYPES = ["application/pdf", "text/plain"];
|
|
243
|
+
const viewable = computed(() => INLINE_TYPES.includes(opened.value?.mimeType ?? ""));
|
|
244
|
+
|
|
245
|
+
const modeOptions = computed(() => [
|
|
246
|
+
{ value: "file", label: locale.value === "en" ? "Document" : "Document" },
|
|
247
|
+
{
|
|
248
|
+
value: "text",
|
|
249
|
+
label: locale.value === "en" ? "Extracted text" : "Texte extrait",
|
|
250
|
+
},
|
|
251
|
+
]);
|
|
252
|
+
|
|
253
|
+
// Chaque vue se charge a la premiere demande : un lien signe ne vit qu'une
|
|
254
|
+
// heure, inutile d'en demander un pour qui ne lit que le texte.
|
|
255
|
+
watch(mode, (value) => {
|
|
256
|
+
if (!opened.value) return;
|
|
257
|
+
if (value === "file" && !fileUrl.value && !filePending.value) loadFile(opened.value);
|
|
258
|
+
if (value === "text" && !preview.value && !previewPending.value && !previewFailed.value) {
|
|
259
|
+
loadText(opened.value);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
const opened = ref<UploadedDocument | null>(null);
|
|
263
|
+
const deleting = ref(false);
|
|
264
|
+
const confirming = ref(false);
|
|
265
|
+
|
|
266
|
+
const refusalTitle = computed(() =>
|
|
267
|
+
locale.value === "en" ? "Upload refused" : "Dépôt refusé",
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
onMounted(() => {
|
|
271
|
+
load();
|
|
272
|
+
loadShared();
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
async function loadShared() {
|
|
276
|
+
try {
|
|
277
|
+
shared.value = (await api.projectDocuments.shared(props.projectId))?.items ?? [];
|
|
278
|
+
} catch (error) {
|
|
279
|
+
// Service a part : sa panne ne doit pas masquer les documents deposes.
|
|
280
|
+
shared.value = [];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Le livrable s'ouvre dans le portail share-platform, sous l'espace de
|
|
286
|
+
* travail : `/w/<slug>/r/<id>`. Le portail derive le slug du nom de l'espace
|
|
287
|
+
* (meme recette que son `slugify`) ; sans nom connu, `/r/<id>` le retrouve.
|
|
288
|
+
*/
|
|
289
|
+
function openShared(artifact: SharedArtifact) {
|
|
290
|
+
const portal = String(useRuntimeConfig().public.sharingPortalUrl).replace(/\/$/, "");
|
|
291
|
+
let name = "";
|
|
292
|
+
try {
|
|
293
|
+
name = localStorage.getItem("currentWorkspaceName") ?? "";
|
|
294
|
+
} catch {}
|
|
295
|
+
const slug = name
|
|
296
|
+
.toLowerCase()
|
|
297
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
298
|
+
.replace(/^-+|-+$/g, "")
|
|
299
|
+
.slice(0, 60);
|
|
300
|
+
const url = slug ? `${portal}/w/${slug}/r/${artifact.id}` : `${portal}/r/${artifact.id}`;
|
|
301
|
+
window.open(url, "_blank", "noopener");
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function load() {
|
|
305
|
+
loading.value = true;
|
|
306
|
+
loadFailed.value = false;
|
|
307
|
+
try {
|
|
308
|
+
const response = await api.projectDocuments.list(props.projectId);
|
|
309
|
+
documents.value = response?.documents ?? [];
|
|
310
|
+
} catch (error) {
|
|
311
|
+
// Une liste vide dirait « aucun document » alors qu'on n'en sait rien.
|
|
312
|
+
documents.value = [];
|
|
313
|
+
loadFailed.value = true;
|
|
314
|
+
} finally {
|
|
315
|
+
loading.value = false;
|
|
316
|
+
}
|
|
317
|
+
openRequested();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Le document demande par l'Inbox, une fois la liste connue. */
|
|
321
|
+
function openRequested() {
|
|
322
|
+
const wanted = documents.value.find((document) => document.id === props.openId);
|
|
323
|
+
if (wanted && opened.value?.id !== wanted.id) openPreview(wanted);
|
|
324
|
+
}
|
|
325
|
+
watch(() => props.openId, openRequested);
|
|
326
|
+
|
|
327
|
+
function pick() {
|
|
328
|
+
refusal.value = "";
|
|
329
|
+
input.value?.click();
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
async function onPick(event: Event) {
|
|
333
|
+
const file = (event.target as HTMLInputElement).files?.[0];
|
|
334
|
+
if (!file) return;
|
|
335
|
+
uploading.value = true;
|
|
336
|
+
try {
|
|
337
|
+
const response = await api.projectDocuments.upload(props.projectId, file);
|
|
338
|
+
await load();
|
|
339
|
+
emit("changed");
|
|
340
|
+
// L'API reconnait un fichier deja depose (meme contenu) et rend l'existant :
|
|
341
|
+
// annoncer un ajout ferait chercher un second exemplaire dans la liste.
|
|
342
|
+
if (response?.duplicate) {
|
|
343
|
+
toast(
|
|
344
|
+
locale.value === "en"
|
|
345
|
+
? `${file.name} is already in the project`
|
|
346
|
+
: `${file.name} est déjà dans le projet`,
|
|
347
|
+
);
|
|
348
|
+
} else {
|
|
349
|
+
toast(
|
|
350
|
+
locale.value === "en"
|
|
351
|
+
? `${file.name} added to the project`
|
|
352
|
+
: `${file.name} ajouté au projet`,
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
} catch (error: any) {
|
|
356
|
+
// Le refus pour donnees personnelles porte sa raison dans le corps, pas
|
|
357
|
+
// dans le statut : c'est elle qu'il faut montrer.
|
|
358
|
+
refusal.value =
|
|
359
|
+
error?.data?.error ||
|
|
360
|
+
error?.message ||
|
|
361
|
+
(locale.value === "en" ? "Upload failed" : "Le dépôt a échoué");
|
|
362
|
+
} finally {
|
|
363
|
+
uploading.value = false;
|
|
364
|
+
if (input.value) input.value.value = "";
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async function openPreview(document: UploadedDocument) {
|
|
369
|
+
emit("opened", document.id);
|
|
370
|
+
opened.value = document;
|
|
371
|
+
preview.value = null;
|
|
372
|
+
previewFailed.value = false;
|
|
373
|
+
fileUrl.value = "";
|
|
374
|
+
confirming.value = false;
|
|
375
|
+
previewing.value = true;
|
|
376
|
+
if (viewable.value) {
|
|
377
|
+
mode.value = "file";
|
|
378
|
+
await loadFile(document);
|
|
379
|
+
} else {
|
|
380
|
+
mode.value = "text";
|
|
381
|
+
await loadText(document);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
async function loadFile(document: UploadedDocument) {
|
|
386
|
+
filePending.value = true;
|
|
387
|
+
try {
|
|
388
|
+
const response = await api.projectDocuments.downloadUrl(document.id);
|
|
389
|
+
if (opened.value?.id === document.id) fileUrl.value = response?.url ?? "";
|
|
390
|
+
} catch (error) {
|
|
391
|
+
fileUrl.value = "";
|
|
392
|
+
} finally {
|
|
393
|
+
filePending.value = false;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async function loadText(document: UploadedDocument) {
|
|
398
|
+
previewPending.value = true;
|
|
399
|
+
try {
|
|
400
|
+
preview.value = await api.projectDocuments.text(document.id);
|
|
401
|
+
} catch (error) {
|
|
402
|
+
preview.value = null;
|
|
403
|
+
previewFailed.value = true;
|
|
404
|
+
} finally {
|
|
405
|
+
previewPending.value = false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async function download() {
|
|
410
|
+
if (!opened.value) return;
|
|
411
|
+
try {
|
|
412
|
+
const response = await api.projectDocuments.downloadUrl(opened.value.id);
|
|
413
|
+
if (response?.url) {
|
|
414
|
+
window.open(response.url, "_blank", "noopener");
|
|
415
|
+
oipTrack(
|
|
416
|
+
"download",
|
|
417
|
+
getExportPosthogProps("Project - document", {
|
|
418
|
+
projectId: props.projectId,
|
|
419
|
+
fileName: opened.value.fileName,
|
|
420
|
+
format: opened.value.mimeType,
|
|
421
|
+
}),
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
} catch (error: any) {
|
|
425
|
+
toast(
|
|
426
|
+
failure(error, locale.value === "en" ? "Download failed" : "Le téléchargement a échoué"),
|
|
427
|
+
false,
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Deux temps : le premier clic demande, le second supprime. */
|
|
433
|
+
async function remove() {
|
|
434
|
+
if (!opened.value) return;
|
|
435
|
+
if (!confirming.value) {
|
|
436
|
+
confirming.value = true;
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
deleting.value = true;
|
|
440
|
+
try {
|
|
441
|
+
await api.projectDocuments.delete(opened.value.id);
|
|
442
|
+
previewing.value = false;
|
|
443
|
+
await load();
|
|
444
|
+
emit("changed");
|
|
445
|
+
toast(locale.value === "en" ? "Document removed" : "Document supprimé");
|
|
446
|
+
} catch (error: any) {
|
|
447
|
+
toast(
|
|
448
|
+
failure(error, locale.value === "en" ? "Removal failed" : "La suppression a échoué"),
|
|
449
|
+
false,
|
|
450
|
+
);
|
|
451
|
+
} finally {
|
|
452
|
+
deleting.value = false;
|
|
453
|
+
confirming.value = false;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Le meme bandeau que les ajouts de fiches : un depot qui aboutit doit se
|
|
459
|
+
* dire, la liste seule ne suffit pas quand le fichier part en bas de page.
|
|
460
|
+
* Le refus de depot, lui, reste dans l'encart : il a une raison a lire, pas
|
|
461
|
+
* une ligne. Les echecs du tiroir (telechargement, suppression) passent par le
|
|
462
|
+
* bandeau, l'encart etant cache sous le tiroir.
|
|
463
|
+
*/
|
|
464
|
+
function toast(text: string, ok = true) {
|
|
465
|
+
oipSnackbar([
|
|
466
|
+
{ attribute: "isVisible", value: true },
|
|
467
|
+
{ attribute: "text", value: text },
|
|
468
|
+
{ attribute: "loader", value: false },
|
|
469
|
+
{ attribute: "prefixIcon", value: ok ? "Check" : "WarningCircle" },
|
|
470
|
+
{
|
|
471
|
+
attribute: "prefixIconColor",
|
|
472
|
+
value: ok ? "var(--color-success)" : "var(--color-danger)",
|
|
473
|
+
},
|
|
474
|
+
{ attribute: "hasTimeOut", value: true },
|
|
475
|
+
]);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** La raison rendue par l'API si elle en donne une, sinon la phrase generique. */
|
|
479
|
+
function failure(error: any, fallback: string) {
|
|
480
|
+
const reason = error?.data?.error;
|
|
481
|
+
return reason ? `${fallback} (${reason})` : fallback;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function fileSize(document: UploadedDocument) {
|
|
485
|
+
return formatBytes(document.sizeBytes ?? 0);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function formatBytes(bytes: number) {
|
|
489
|
+
if (bytes < 1024) return `${bytes} o`;
|
|
490
|
+
if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} ko`;
|
|
491
|
+
return `${(bytes / (1024 * 1024)).toFixed(1).replace(".", locale.value === "en" ? "." : ",")} Mo`;
|
|
492
|
+
}
|
|
493
|
+
</script>
|
|
494
|
+
|
|
495
|
+
<style scoped>
|
|
496
|
+
.project_pd {
|
|
497
|
+
display: flex;
|
|
498
|
+
flex-direction: column;
|
|
499
|
+
gap: 16px;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.project_pd_head {
|
|
503
|
+
display: flex;
|
|
504
|
+
align-items: center;
|
|
505
|
+
justify-content: space-between;
|
|
506
|
+
gap: 12px;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.project_pd_count {
|
|
510
|
+
margin: 0;
|
|
511
|
+
color: var(--rm-shell-text-muted);
|
|
512
|
+
font-size: 13px;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.project_pd_input {
|
|
516
|
+
display: none;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.project_pd_refusal_title {
|
|
520
|
+
margin: 0 0 2px;
|
|
521
|
+
font-size: 14px;
|
|
522
|
+
font-weight: 600;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.project_pd_refusal_text {
|
|
526
|
+
margin: 0;
|
|
527
|
+
font-size: 13px;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.project_pd_list {
|
|
531
|
+
display: flex;
|
|
532
|
+
flex-direction: column;
|
|
533
|
+
gap: 2px;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.project_pd_row {
|
|
537
|
+
display: flex;
|
|
538
|
+
align-items: center;
|
|
539
|
+
gap: 8px;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.project_pd_flag {
|
|
543
|
+
color: var(--rm-shell-text-muted);
|
|
544
|
+
font-size: 12px;
|
|
545
|
+
white-space: nowrap;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.project_pd_tag {
|
|
549
|
+
flex-shrink: 0;
|
|
550
|
+
white-space: nowrap;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.project_pd_preview {
|
|
554
|
+
display: flex;
|
|
555
|
+
flex-direction: column;
|
|
556
|
+
gap: 16px;
|
|
557
|
+
padding: 20px;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
.project_pd_preview_head {
|
|
561
|
+
display: flex;
|
|
562
|
+
align-items: center;
|
|
563
|
+
justify-content: space-between;
|
|
564
|
+
gap: 12px;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
.project_pd_preview_title {
|
|
568
|
+
margin: 0;
|
|
569
|
+
font-size: 15px;
|
|
570
|
+
font-weight: 600;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.project_pd_preview_actions {
|
|
574
|
+
display: flex;
|
|
575
|
+
gap: 8px;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.project_pd_mode {
|
|
579
|
+
align-self: flex-start;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.project_pd_frame {
|
|
583
|
+
width: 100%;
|
|
584
|
+
height: calc(100vh - 180px);
|
|
585
|
+
min-height: 480px;
|
|
586
|
+
border: 1px solid var(--rm-shell-border);
|
|
587
|
+
border-radius: 8px;
|
|
588
|
+
background: var(--rm-shell-surface);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
.project_pd_sections {
|
|
592
|
+
display: flex;
|
|
593
|
+
flex-direction: column;
|
|
594
|
+
gap: 20px;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
.project_pd_section_name {
|
|
598
|
+
margin: 0 0 4px;
|
|
599
|
+
color: var(--rm-shell-text-muted);
|
|
600
|
+
font-size: 12px;
|
|
601
|
+
font-weight: 600;
|
|
602
|
+
text-transform: uppercase;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.project_pd_section_text {
|
|
606
|
+
margin: 0;
|
|
607
|
+
font-size: 14px;
|
|
608
|
+
line-height: 1.6;
|
|
609
|
+
white-space: pre-wrap;
|
|
610
|
+
}
|
|
611
|
+
</style>
|