@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,820 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
La page d'un projet : ce que l'utilisateur y a range, par famille. Servie
|
|
3
|
+
par le layer OIP (page /projects/<id>, cf. pages/projects), reprise d'OIP
|
|
4
|
+
Case Atlas et de France Augmented Science (meme page que fr_drugs_app),
|
|
5
|
+
avec les composants RmProject* de Romulus.
|
|
6
|
+
|
|
7
|
+
L'API ne garde de chaque element que sa paire (resourceId, resourceType) :
|
|
8
|
+
la page relit les documents par le proxy du layer, un appel par famille
|
|
9
|
+
(cf. useOipProjectKinds). Un element dont le document a disparu reste liste
|
|
10
|
+
sous son identifiant, pour pouvoir le retirer.
|
|
11
|
+
|
|
12
|
+
Un projet est commun a tout le portail : chaque famille que le layer decrit
|
|
13
|
+
s'affiche ici et s'ouvre avec la vue de son app d'origine
|
|
14
|
+
(OipResourceDrawer) ; les autres restent dans le projet, cachees.
|
|
15
|
+
|
|
16
|
+
Les onglets, dans le meme ordre partout : Vue d'ensemble, Tableau de bord,
|
|
17
|
+
Ressources, Documents, Notes, Agent IA (grise, pas encore branche) et
|
|
18
|
+
Inbox. En tete, le suivi du projet (une alerte sur ses fiches, quand l'app
|
|
19
|
+
en declare) ; la page declare l'inventaire du projet a la tuile Export,
|
|
20
|
+
sauf sur le tableau de bord, qui declare le sien.
|
|
21
|
+
|
|
22
|
+
Ce qui est propre a l'app vient de #oip-app/projects : acces (licence),
|
|
23
|
+
cadrage, fiches liees de l'Inbox, suivi, mots.
|
|
24
|
+
-->
|
|
25
|
+
<template>
|
|
26
|
+
<div class="arg_page_layout">
|
|
27
|
+
<RmPageHeader
|
|
28
|
+
:title="licensed ? project?.title || (en ? 'Project' : 'Projet') : en ? 'Project' : 'Projet'"
|
|
29
|
+
have-return
|
|
30
|
+
:back-to="localePath(PROJECTS_PATH)"
|
|
31
|
+
:tabs="licensed ? headerTabs : []"
|
|
32
|
+
:tabs-label="en ? 'Project sections' : 'Sections du projet'"
|
|
33
|
+
@tab="setTab"
|
|
34
|
+
>
|
|
35
|
+
<template v-if="licensed" #actions>
|
|
36
|
+
<RmTag v-if="isActive" variant="teal">{{ en ? "Active" : "Actif" }}</RmTag>
|
|
37
|
+
<ProjectWatch v-if="project && WATCHABLE_PROJECT_TYPES.length" :project-id="projectId" :project-title="project.title" :items="items" />
|
|
38
|
+
<RmButton v-if="isOwner" variant="tertiary" prefix-icon="ShareNetwork" @click="sharing = true">
|
|
39
|
+
{{ en ? "Share" : "Partager" }}
|
|
40
|
+
</RmButton>
|
|
41
|
+
<RmButton v-if="project" variant="tertiary" prefix-icon="PencilSimple" @click="openRename">
|
|
42
|
+
{{ en ? "Rename" : "Renommer" }}
|
|
43
|
+
</RmButton>
|
|
44
|
+
<!-- L'API ne laisse supprimer que le proprietaire. -->
|
|
45
|
+
<RmButton v-if="isOwner" variant="text-danger" prefix-icon="Trash" @click="openDelete">
|
|
46
|
+
{{ en ? "Delete" : "Supprimer" }}
|
|
47
|
+
</RmButton>
|
|
48
|
+
</template>
|
|
49
|
+
</RmPageHeader>
|
|
50
|
+
|
|
51
|
+
<template v-if="!licensed">
|
|
52
|
+
<component :is="PROJECTS_UPSELL" v-if="PROJECTS_UPSELL" :feature="PROJECTS" />
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<template v-else>
|
|
56
|
+
<RmProjectOverview
|
|
57
|
+
v-if="tab === 'overview'"
|
|
58
|
+
:project="overviewProject"
|
|
59
|
+
:rows="rows"
|
|
60
|
+
:shared-count="sharedCount"
|
|
61
|
+
:scope-rows="scopeRows"
|
|
62
|
+
:documents-count="documentsCount"
|
|
63
|
+
:steps="steps"
|
|
64
|
+
:loading="loading"
|
|
65
|
+
:saving="describing"
|
|
66
|
+
:save-error="describeError"
|
|
67
|
+
:lang="lang"
|
|
68
|
+
@tab="setTab"
|
|
69
|
+
@describe="describe"
|
|
70
|
+
@open="showDetail"
|
|
71
|
+
/>
|
|
72
|
+
|
|
73
|
+
<RmProjectResources
|
|
74
|
+
v-else-if="tab === 'resources'"
|
|
75
|
+
:rows="rows"
|
|
76
|
+
:loading="loading"
|
|
77
|
+
:failed="failed"
|
|
78
|
+
:removing="removing"
|
|
79
|
+
:lang="lang"
|
|
80
|
+
@open="showDetail"
|
|
81
|
+
@comment="openComments"
|
|
82
|
+
@remove="removeRow"
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<ProjectDashboard
|
|
86
|
+
v-else-if="tab === 'dashboard' && !failed && project"
|
|
87
|
+
:project-id="projectId"
|
|
88
|
+
:project-title="project.title"
|
|
89
|
+
:groups="dashboardGroups"
|
|
90
|
+
:docs="dashboardDocs"
|
|
91
|
+
:lang="lang"
|
|
92
|
+
/>
|
|
93
|
+
|
|
94
|
+
<ProjectDocuments
|
|
95
|
+
v-else-if="tab === 'documents'"
|
|
96
|
+
:project-id="projectId"
|
|
97
|
+
:open-id="documentToOpen"
|
|
98
|
+
@changed="loadDocumentsCount"
|
|
99
|
+
@opened="documentToOpen = ''"
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
<ProjectNotes
|
|
103
|
+
v-else-if="tab === 'notes'"
|
|
104
|
+
:project-id="projectId"
|
|
105
|
+
:users="projectUsers"
|
|
106
|
+
:resources="citableResources"
|
|
107
|
+
@open-resource="openInboxResource"
|
|
108
|
+
/>
|
|
109
|
+
|
|
110
|
+
<ProjectInbox
|
|
111
|
+
v-else-if="tab === 'inbox'"
|
|
112
|
+
:project-id="projectId"
|
|
113
|
+
:items="inboxItems"
|
|
114
|
+
:loading="inboxLoading"
|
|
115
|
+
:describe="describeResource"
|
|
116
|
+
@changed="onSuggestionDecided"
|
|
117
|
+
@open="openInboxItem"
|
|
118
|
+
@unread="unreadInboxItem"
|
|
119
|
+
@tab="setTab"
|
|
120
|
+
@pin="pinInboxItem"
|
|
121
|
+
@remove="removeInboxItem"
|
|
122
|
+
@open-resource="openInboxResource"
|
|
123
|
+
@open-change="openChange"
|
|
124
|
+
@open-note="openNote"
|
|
125
|
+
@local-suggestion="onLocalSuggestion"
|
|
126
|
+
/>
|
|
127
|
+
|
|
128
|
+
<RmProjectRenameDialog
|
|
129
|
+
v-model="renaming"
|
|
130
|
+
:title="project?.title ?? ''"
|
|
131
|
+
:loading="renameBusy"
|
|
132
|
+
:error="renameError"
|
|
133
|
+
:lang="lang"
|
|
134
|
+
@save="saveRename"
|
|
135
|
+
/>
|
|
136
|
+
|
|
137
|
+
<RmProjectDeleteDialog
|
|
138
|
+
v-model="deleting"
|
|
139
|
+
:title="project?.title ?? ''"
|
|
140
|
+
:loading="deleteBusy"
|
|
141
|
+
:error="deleteError"
|
|
142
|
+
:lang="lang"
|
|
143
|
+
@confirm="confirmDelete"
|
|
144
|
+
/>
|
|
145
|
+
|
|
146
|
+
<RmProjectComments
|
|
147
|
+
v-model="commenting"
|
|
148
|
+
:title="commented?.title || commented?.id || ''"
|
|
149
|
+
:entries="commentEntries"
|
|
150
|
+
:loading="commentsLoading"
|
|
151
|
+
:sending="commentSending"
|
|
152
|
+
:error="commentError"
|
|
153
|
+
:lang="lang"
|
|
154
|
+
@send="sendComment"
|
|
155
|
+
/>
|
|
156
|
+
|
|
157
|
+
<project-share
|
|
158
|
+
v-if="isOwner && project"
|
|
159
|
+
v-model="sharing"
|
|
160
|
+
:project-id="projectId"
|
|
161
|
+
:title="project.title"
|
|
162
|
+
:is-shared="!!project.isShared"
|
|
163
|
+
:owner-id="project.owner?.userId ?? ''"
|
|
164
|
+
:users="projectUsers"
|
|
165
|
+
@saved="onShared"
|
|
166
|
+
/>
|
|
167
|
+
|
|
168
|
+
<!-- Chaque famille : la vue de son app d'origine, partagee par tout le portail. -->
|
|
169
|
+
<OipResourceDrawer
|
|
170
|
+
v-model="detailing"
|
|
171
|
+
:type="detailed.type"
|
|
172
|
+
:id="detailed.id"
|
|
173
|
+
:title="detailed.title"
|
|
174
|
+
:lang="lang"
|
|
175
|
+
/>
|
|
176
|
+
|
|
177
|
+
<!-- Le tableau de bord declare son propre export tant qu'il est ouvert. -->
|
|
178
|
+
<project-export v-if="tab !== 'dashboard'" :project-id="projectId" :project="project" :rows="rows" :users="projectUsers" />
|
|
179
|
+
</template>
|
|
180
|
+
</div>
|
|
181
|
+
</template>
|
|
182
|
+
|
|
183
|
+
<script setup lang="ts">
|
|
184
|
+
import {
|
|
185
|
+
rmProjectRows,
|
|
186
|
+
type RmProjectCommentEntry,
|
|
187
|
+
type RmProjectDocuments,
|
|
188
|
+
type RmProjectResource,
|
|
189
|
+
type RmProjectStep,
|
|
190
|
+
} from "@tekkare/romulus/utils/projects";
|
|
191
|
+
import { useOipApi } from "#oip-app/api";
|
|
192
|
+
import {
|
|
193
|
+
PROJECTS_PATH,
|
|
194
|
+
PROJECTS_UPSELL,
|
|
195
|
+
PROJECT_WORDING,
|
|
196
|
+
WATCHABLE_PROJECT_TYPES,
|
|
197
|
+
useProjectScopeRows,
|
|
198
|
+
useProjectSuggestions,
|
|
199
|
+
useProjectsAccess,
|
|
200
|
+
} from "#oip-projects";
|
|
201
|
+
import type { ProjectItem } from "../../composables/useProjects";
|
|
202
|
+
import { oipProjectHydrate, useOipProjectKinds } from "../../composables/useOipProjectKinds";
|
|
203
|
+
import type {
|
|
204
|
+
ProjectInboxChange,
|
|
205
|
+
ProjectInboxItem,
|
|
206
|
+
ProjectOwner,
|
|
207
|
+
ProjectSuggestion,
|
|
208
|
+
ProjectUser,
|
|
209
|
+
} from "../../types/projects";
|
|
210
|
+
|
|
211
|
+
const props = defineProps<{ projectId: string }>();
|
|
212
|
+
|
|
213
|
+
const { locale } = useI18n();
|
|
214
|
+
const en = computed(() => locale.value === "en");
|
|
215
|
+
const lang = computed<"fr" | "en">(() => (en.value ? "en" : "fr"));
|
|
216
|
+
const localePath = useLocalePath();
|
|
217
|
+
const route = useRoute();
|
|
218
|
+
const router = useRouter();
|
|
219
|
+
const projects = useProjects();
|
|
220
|
+
const kinds = useOipProjectKinds();
|
|
221
|
+
const licensed = useProjectsAccess();
|
|
222
|
+
const { data: session } = useAuth();
|
|
223
|
+
|
|
224
|
+
const PROJECTS = { fr: "Projets", en: "Projects" };
|
|
225
|
+
|
|
226
|
+
const projectId = props.projectId;
|
|
227
|
+
|
|
228
|
+
type ProjectDetail = {
|
|
229
|
+
title: string;
|
|
230
|
+
description: string;
|
|
231
|
+
createdAt?: string;
|
|
232
|
+
isShared?: boolean;
|
|
233
|
+
owner?: ProjectOwner;
|
|
234
|
+
/** Cadrage structure pose par une creation assistee (cf. useProjectScopeRows de l'app). */
|
|
235
|
+
scope?: any;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const project = ref<ProjectDetail | null>(null);
|
|
239
|
+
const items = ref<ProjectItem[]>([]);
|
|
240
|
+
const documents = ref<RmProjectDocuments>({});
|
|
241
|
+
const loading = ref(true);
|
|
242
|
+
const failed = ref(false);
|
|
243
|
+
const removing = ref("");
|
|
244
|
+
|
|
245
|
+
const isActive = computed(() => projects.activeId.value === projectId);
|
|
246
|
+
|
|
247
|
+
const isOwner = computed(() => {
|
|
248
|
+
const email = String((session.value as any)?.user?.email ?? "").toLowerCase();
|
|
249
|
+
return !!email && email === String(project.value?.owner?.email ?? "").toLowerCase();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Les lignes du projet, relues et pretes a afficher. Le lien porte la langue ;
|
|
254
|
+
* celui d'un type du layer, deja absolu, mene a son app d'origine.
|
|
255
|
+
*/
|
|
256
|
+
const rows = computed<RmProjectResource[]>(() =>
|
|
257
|
+
rmProjectRows(items.value, documents.value, kinds, lang.value).map((row) => ({
|
|
258
|
+
...row,
|
|
259
|
+
path: row.path?.startsWith("/") ? localePath(row.path) : (row.path ?? ""),
|
|
260
|
+
})),
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
/** Le cadrage de la vue d'ensemble, propre a l'app. */
|
|
264
|
+
const scopeRows = useProjectScopeRows(project, rows, lang);
|
|
265
|
+
|
|
266
|
+
// ----------------------------------------------------------- fil d'Ariane
|
|
267
|
+
|
|
268
|
+
const crumbLabel = useOipCrumbLabel();
|
|
269
|
+
const crumb = () => project.value?.title || (en.value ? "Project" : "Projet");
|
|
270
|
+
watchEffect(() => {
|
|
271
|
+
crumbLabel.value = crumb();
|
|
272
|
+
});
|
|
273
|
+
// Ne rend le maillon que s'il est encore le sien : la page suivante a pu
|
|
274
|
+
// poser le sien avant que celle-ci ne soit demontee.
|
|
275
|
+
onUnmounted(() => {
|
|
276
|
+
if (crumbLabel.value === crumb()) crumbLabel.value = null;
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// ------------------------------------------------------------- les onglets
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Les sections, dans le meme ordre d'une app a l'autre. L'agent n'y
|
|
283
|
+
* est pas encore branche : il est grise plutot que cache, le projet se lit de
|
|
284
|
+
* la meme facon d'une app a l'autre.
|
|
285
|
+
*/
|
|
286
|
+
type ProjectTab = "overview" | "dashboard" | "resources" | "documents" | "notes" | "inbox";
|
|
287
|
+
const TAB_KEYS: ProjectTab[] = ["overview", "dashboard", "resources", "documents", "notes", "inbox"];
|
|
288
|
+
const tab = ref<ProjectTab>("overview");
|
|
289
|
+
|
|
290
|
+
const headerTabs = computed(() => [
|
|
291
|
+
{ key: "overview", label: en.value ? "Overview" : "Vue d'ensemble", active: tab.value === "overview" },
|
|
292
|
+
{ key: "dashboard", label: en.value ? "Dashboard" : "Tableau de bord", active: tab.value === "dashboard" },
|
|
293
|
+
{
|
|
294
|
+
key: "resources",
|
|
295
|
+
label: en.value ? "Resources" : "Ressources",
|
|
296
|
+
active: tab.value === "resources",
|
|
297
|
+
count: rows.value.length || undefined,
|
|
298
|
+
},
|
|
299
|
+
{ key: "documents", label: "Documents", active: tab.value === "documents" },
|
|
300
|
+
{ key: "notes", label: "Notes", active: tab.value === "notes" },
|
|
301
|
+
{ key: "agent", label: en.value ? "AI agent" : "Agent IA", disabled: true, tag: en.value ? "Coming soon" : "Bientôt" },
|
|
302
|
+
{
|
|
303
|
+
key: "inbox",
|
|
304
|
+
label: "Inbox",
|
|
305
|
+
active: tab.value === "inbox",
|
|
306
|
+
count: inboxItems.value.filter((item) => !item.readAt).length || undefined,
|
|
307
|
+
},
|
|
308
|
+
]);
|
|
309
|
+
|
|
310
|
+
/** Les documents deposes : `null` tant qu'on ne sait pas, ou si l'appel echoue (la tuile n'est pas montree). */
|
|
311
|
+
const documentsCount = ref<number | null>(null);
|
|
312
|
+
|
|
313
|
+
async function loadDocumentsCount() {
|
|
314
|
+
try {
|
|
315
|
+
const response = await useOipApi().projectDocuments.list(projectId);
|
|
316
|
+
documentsCount.value = response?.documents?.length ?? 0;
|
|
317
|
+
} catch {
|
|
318
|
+
documentsCount.value = null;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Les trois facons d'avancer, une par onglet. L'agent n'est pas encore branche. */
|
|
323
|
+
const steps = computed<RmProjectStep[]>(() => [
|
|
324
|
+
{
|
|
325
|
+
tab: "resources",
|
|
326
|
+
icon: "Files",
|
|
327
|
+
title: en.value ? "Browse the resources" : "Consulter les ressources",
|
|
328
|
+
text: PROJECT_WORDING.resources[lang.value],
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
tab: "documents",
|
|
332
|
+
icon: "UploadSimple",
|
|
333
|
+
title: en.value ? "Add documents" : "Déposer des documents",
|
|
334
|
+
text: PROJECT_WORDING.documents[lang.value],
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
tab: "agent",
|
|
338
|
+
icon: "Sparkle",
|
|
339
|
+
title: en.value ? "Ask the AI agent" : "Interroger l'agent IA",
|
|
340
|
+
text: en.value
|
|
341
|
+
? "An agent will read the project and answer your questions."
|
|
342
|
+
: "Un agent lira le projet et répondra à vos questions.",
|
|
343
|
+
disabled: true,
|
|
344
|
+
tag: en.value ? "Coming soon" : "Bientôt",
|
|
345
|
+
},
|
|
346
|
+
]);
|
|
347
|
+
|
|
348
|
+
/** La section ouverte vit dans l'URL : un lien vers les ressources s'envoie. */
|
|
349
|
+
function setTab(value: string) {
|
|
350
|
+
if (!TAB_KEYS.includes(value as ProjectTab)) return;
|
|
351
|
+
tab.value = value as ProjectTab;
|
|
352
|
+
router.replace({ query: { ...route.query, tab: value } });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
onMounted(() => {
|
|
356
|
+
const wanted = String(route.query.tab ?? "");
|
|
357
|
+
if (TAB_KEYS.includes(wanted as ProjectTab)) tab.value = wanted as ProjectTab;
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// --------------------------------------------------------------- le partage
|
|
361
|
+
|
|
362
|
+
const sharing = ref(false);
|
|
363
|
+
const projectUsers = ref<ProjectUser[]>([]);
|
|
364
|
+
const sharedCount = computed(
|
|
365
|
+
() => projectUsers.value.filter((user) => user.userId && user.userId !== project.value?.owner?.userId).length,
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
const overviewProject = computed(() =>
|
|
369
|
+
project.value
|
|
370
|
+
? {
|
|
371
|
+
title: project.value.title,
|
|
372
|
+
description: project.value.description,
|
|
373
|
+
createdAt: project.value.createdAt,
|
|
374
|
+
ownerName: project.value.owner?.displayName || project.value.owner?.email || "",
|
|
375
|
+
shared: project.value.isShared,
|
|
376
|
+
}
|
|
377
|
+
: null,
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
function onShared(value: { isShared: boolean; users: ProjectUser[] }) {
|
|
381
|
+
if (project.value) project.value = { ...project.value, isShared: value.isShared };
|
|
382
|
+
projectUsers.value = value.users;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
async function loadUsers() {
|
|
386
|
+
try {
|
|
387
|
+
const response = await useOipApi().projects.getUsers(projectId);
|
|
388
|
+
projectUsers.value = response?.users ?? [];
|
|
389
|
+
} catch {
|
|
390
|
+
projectUsers.value = [];
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// -------------------------------------------------------- la description
|
|
395
|
+
|
|
396
|
+
const describing = ref(false);
|
|
397
|
+
const describeError = ref("");
|
|
398
|
+
|
|
399
|
+
async function describe(description: string) {
|
|
400
|
+
describing.value = true;
|
|
401
|
+
describeError.value = "";
|
|
402
|
+
try {
|
|
403
|
+
const saved = await projects.update(projectId, { description });
|
|
404
|
+
if (project.value) project.value = { ...project.value, description: saved?.description ?? description };
|
|
405
|
+
} catch (error: any) {
|
|
406
|
+
describeError.value =
|
|
407
|
+
error?.data?.error ||
|
|
408
|
+
error?.data?.message ||
|
|
409
|
+
(en.value ? "The description could not be saved" : "La description n'a pas pu être enregistrée");
|
|
410
|
+
} finally {
|
|
411
|
+
describing.value = false;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// ------------------------------------------------- renommer et supprimer
|
|
416
|
+
|
|
417
|
+
const renaming = ref(false);
|
|
418
|
+
const renameBusy = ref(false);
|
|
419
|
+
const renameError = ref("");
|
|
420
|
+
|
|
421
|
+
function openRename() {
|
|
422
|
+
renameError.value = "";
|
|
423
|
+
renaming.value = true;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
async function saveRename(title: string) {
|
|
427
|
+
renameBusy.value = true;
|
|
428
|
+
renameError.value = "";
|
|
429
|
+
try {
|
|
430
|
+
const saved = await projects.update(projectId, { title });
|
|
431
|
+
if (project.value) project.value = { ...project.value, title: saved?.title ?? title };
|
|
432
|
+
renaming.value = false;
|
|
433
|
+
} catch (error: any) {
|
|
434
|
+
renameError.value =
|
|
435
|
+
error?.data?.error || error?.data?.message || (en.value ? "Rename failed" : "Le renommage a échoué");
|
|
436
|
+
} finally {
|
|
437
|
+
renameBusy.value = false;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const deleting = ref(false);
|
|
442
|
+
const deleteBusy = ref(false);
|
|
443
|
+
const deleteError = ref("");
|
|
444
|
+
|
|
445
|
+
function openDelete() {
|
|
446
|
+
deleteError.value = "";
|
|
447
|
+
deleting.value = true;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
async function confirmDelete() {
|
|
451
|
+
if (deleteBusy.value) return;
|
|
452
|
+
deleteBusy.value = true;
|
|
453
|
+
deleteError.value = "";
|
|
454
|
+
try {
|
|
455
|
+
await projects.destroy(projectId);
|
|
456
|
+
deleting.value = false;
|
|
457
|
+
router.replace(localePath(PROJECTS_PATH));
|
|
458
|
+
} catch (error: any) {
|
|
459
|
+
deleteError.value =
|
|
460
|
+
error?.data?.error ||
|
|
461
|
+
error?.data?.message ||
|
|
462
|
+
(en.value ? "The project could not be deleted" : "Le projet n'a pas pu être supprimé");
|
|
463
|
+
} finally {
|
|
464
|
+
deleteBusy.value = false;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// ------------------------------------------------------- l'apercu
|
|
469
|
+
|
|
470
|
+
const detailing = ref(false);
|
|
471
|
+
const detailed = ref({ type: "", id: "", title: "", path: "" });
|
|
472
|
+
|
|
473
|
+
function showDetail(row: RmProjectResource) {
|
|
474
|
+
detailed.value = { type: row.type, id: row.id, title: row.title || row.id, path: row.path ?? "" };
|
|
475
|
+
detailing.value = true;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// -------------------------------------------------------- les commentaires
|
|
479
|
+
|
|
480
|
+
const commenting = ref(false);
|
|
481
|
+
const commented = ref<RmProjectResource | null>(null);
|
|
482
|
+
const commentEntries = ref<RmProjectCommentEntry[]>([]);
|
|
483
|
+
const commentsLoading = ref(false);
|
|
484
|
+
const commentSending = ref(false);
|
|
485
|
+
const commentError = ref("");
|
|
486
|
+
|
|
487
|
+
function setCommentCount(row: RmProjectResource, count: number) {
|
|
488
|
+
items.value = items.value.map((item) =>
|
|
489
|
+
item.resourceId === row.id && item.resourceType === row.type ? { ...item, commentsCount: count } : item,
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
async function loadComments(row: RmProjectResource) {
|
|
494
|
+
commentsLoading.value = true;
|
|
495
|
+
commentError.value = "";
|
|
496
|
+
try {
|
|
497
|
+
const response = await useOipApi().comments.getResourceComments(projectId, row.id, {
|
|
498
|
+
sortBy: "createdAt",
|
|
499
|
+
order: "asc",
|
|
500
|
+
});
|
|
501
|
+
commentEntries.value = (response?.data ?? []).map((comment) => ({
|
|
502
|
+
id: comment.id,
|
|
503
|
+
author: [comment.userFirstName, comment.userLastName].filter(Boolean).join(" ") || comment.userEmail,
|
|
504
|
+
date: comment.createdAt,
|
|
505
|
+
text: comment.text,
|
|
506
|
+
}));
|
|
507
|
+
setCommentCount(row, response?.totalCount ?? commentEntries.value.length);
|
|
508
|
+
} catch (error: any) {
|
|
509
|
+
commentEntries.value = [];
|
|
510
|
+
commentError.value = error?.data?.message || error?.message || "";
|
|
511
|
+
} finally {
|
|
512
|
+
commentsLoading.value = false;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function openComments(row: RmProjectResource) {
|
|
517
|
+
commented.value = row;
|
|
518
|
+
commentEntries.value = [];
|
|
519
|
+
commenting.value = true;
|
|
520
|
+
loadComments(row);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
async function sendComment(text: string) {
|
|
524
|
+
const row = commented.value;
|
|
525
|
+
if (!row) return;
|
|
526
|
+
commentSending.value = true;
|
|
527
|
+
commentError.value = "";
|
|
528
|
+
try {
|
|
529
|
+
const user = (session.value as any)?.user ?? {};
|
|
530
|
+
await useOipApi().comments.create({
|
|
531
|
+
projectId,
|
|
532
|
+
userId: user.sub || user.id || user.email,
|
|
533
|
+
userEmail: user.email,
|
|
534
|
+
userFirstName: user.firstName || user.given_name || "",
|
|
535
|
+
userLastName: user.lastName || user.family_name || "",
|
|
536
|
+
text,
|
|
537
|
+
commentedResourceId: row.id,
|
|
538
|
+
resourceType: row.type,
|
|
539
|
+
commentType: "ResourceComment",
|
|
540
|
+
});
|
|
541
|
+
await loadComments(row);
|
|
542
|
+
} catch (error: any) {
|
|
543
|
+
commentError.value =
|
|
544
|
+
error?.data?.error || error?.message || (en.value ? "The comment was not posted" : "Le commentaire n'est pas parti");
|
|
545
|
+
} finally {
|
|
546
|
+
commentSending.value = false;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// ---------------------------------------------------------- les ressources
|
|
551
|
+
|
|
552
|
+
async function removeRow(row: RmProjectResource) {
|
|
553
|
+
removing.value = `${row.type}-${row.id}`;
|
|
554
|
+
try {
|
|
555
|
+
await projects.remove(row.id, row.type, projectId);
|
|
556
|
+
items.value = items.value.filter((item) => !(item.resourceId === row.id && item.resourceType === row.type));
|
|
557
|
+
} finally {
|
|
558
|
+
removing.value = "";
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// ---------------------------------------------------------- le tableau de bord
|
|
563
|
+
|
|
564
|
+
/** Ce que le projet range, par famille : le widget « Contenu du projet ». */
|
|
565
|
+
const dashboardGroups = computed(() => {
|
|
566
|
+
const counts = new Map<string, number>();
|
|
567
|
+
for (const row of rows.value) if (row.known) counts.set(row.family, (counts.get(row.family) ?? 0) + 1);
|
|
568
|
+
return [...counts].map(([label, count]) => ({ label, count }));
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
/** Les documents deja relus : les widgets du projet les comptent sans requete de plus. */
|
|
572
|
+
const dashboardDocs = computed(() =>
|
|
573
|
+
rows.value.filter((row) => row.known && row.source).map((row) => ({ type: row.type, source: row.source as Record<string, any> })),
|
|
574
|
+
);
|
|
575
|
+
|
|
576
|
+
// ----------------------------------------------------------------- l'Inbox
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* L'Inbox : l'historique du lecteur dans le projet, que l'API ecrit a chaque
|
|
580
|
+
* ouverture et garde jusqu'a ce qu'il supprime un message. Un echec laisse
|
|
581
|
+
* l'onglet vide : il ne doit pas faire tomber la page du projet.
|
|
582
|
+
*/
|
|
583
|
+
const inbox = ref<{ items: ProjectInboxItem[]; lastRunAt: string | null }>({ items: [], lastRunAt: null });
|
|
584
|
+
const inboxLoading = ref(false);
|
|
585
|
+
|
|
586
|
+
/** L'API n'a pas repondu : l'historique manque, la bienvenue non. */
|
|
587
|
+
const inboxUnavailable = ref(false);
|
|
588
|
+
|
|
589
|
+
async function loadInbox() {
|
|
590
|
+
inboxLoading.value = true;
|
|
591
|
+
try {
|
|
592
|
+
const response = await useOipApi().projectInbox.list(projectId);
|
|
593
|
+
inbox.value = { items: response?.items ?? [], lastRunAt: response?.lastRunAt ?? null };
|
|
594
|
+
inboxUnavailable.value = false;
|
|
595
|
+
} catch {
|
|
596
|
+
inbox.value = { items: [], lastRunAt: inbox.value.lastRunAt };
|
|
597
|
+
inboxUnavailable.value = true;
|
|
598
|
+
} finally {
|
|
599
|
+
inboxLoading.value = false;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Les fiches liees que l'app cherche elle-meme (useProjectSuggestions de
|
|
605
|
+
* #oip-app/projects, aucune par defaut) : un message de plus, ecrit ici, qui ne
|
|
606
|
+
* s'epingle ni ne se supprime faute d'historique ou le ranger. Cherches une
|
|
607
|
+
* fois, quand le projet est relu : la liste reste stable pendant qu'on la trie.
|
|
608
|
+
*/
|
|
609
|
+
const related = useProjectSuggestions(projectId, rows, lang);
|
|
610
|
+
const LOCAL_SUGGESTIONS = "local-suggestions";
|
|
611
|
+
const relatedRead = ref<string | null>(null);
|
|
612
|
+
const relatedAt = new Date().toISOString();
|
|
613
|
+
let relatedLoaded = false;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Les messages de l'onglet. Sans reponse de l'API, la bienvenue s'ecrit ici,
|
|
617
|
+
* a la date du projet : elle ne s'epingle ni ne se supprime, faute
|
|
618
|
+
* d'historique ou la ranger.
|
|
619
|
+
*/
|
|
620
|
+
const LOCAL_WELCOME = "local-welcome";
|
|
621
|
+
const localWelcomeRead = ref<string | null>(null);
|
|
622
|
+
const inboxItems = computed<ProjectInboxItem[]>(() => {
|
|
623
|
+
const local = (id: string, kind: ProjectInboxItem["kind"], occurredAt: string, readAt: string | null) => ({
|
|
624
|
+
id,
|
|
625
|
+
kind,
|
|
626
|
+
actorName: null,
|
|
627
|
+
payload: null,
|
|
628
|
+
occurredAt,
|
|
629
|
+
readAt,
|
|
630
|
+
pinnedAt: null,
|
|
631
|
+
});
|
|
632
|
+
return [
|
|
633
|
+
...(related.suggestions.value.length
|
|
634
|
+
? [{ ...local(LOCAL_SUGGESTIONS, "suggestions", relatedAt, relatedRead.value), suggestions: related.suggestions.value }]
|
|
635
|
+
: []),
|
|
636
|
+
...inbox.value.items,
|
|
637
|
+
...(inboxUnavailable.value && !inbox.value.items.some((item) => item.kind === "welcome")
|
|
638
|
+
? [local(LOCAL_WELCOME, "welcome", project.value?.createdAt ?? new Date().toISOString(), localWelcomeRead.value)]
|
|
639
|
+
: []),
|
|
640
|
+
];
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
const isLocal = (item: ProjectInboxItem) => item.id === LOCAL_WELCOME || item.id === LOCAL_SUGGESTIONS;
|
|
644
|
+
|
|
645
|
+
function patchInboxItem(id: string, change: Partial<ProjectInboxItem>) {
|
|
646
|
+
inbox.value = {
|
|
647
|
+
...inbox.value,
|
|
648
|
+
items: inbox.value.items.map((item) => (item.id === id ? { ...item, ...change } : item)),
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/** Ouvrir un message le marque lu ; il reste dans l'historique. */
|
|
653
|
+
function openInboxItem(item: ProjectInboxItem) {
|
|
654
|
+
if (item.readAt) return;
|
|
655
|
+
const now = new Date().toISOString();
|
|
656
|
+
if (item.id === LOCAL_WELCOME) localWelcomeRead.value = now;
|
|
657
|
+
else if (item.id === LOCAL_SUGGESTIONS) relatedRead.value = now;
|
|
658
|
+
else {
|
|
659
|
+
patchInboxItem(item.id, { readAt: now });
|
|
660
|
+
useOipApi().projectInbox.update(projectId, item.id, { read: true }).catch(() => loadInbox());
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/** « Marquer comme non lu » : le message reste ouvert, sa pastille revient. */
|
|
665
|
+
function unreadInboxItem(item: ProjectInboxItem) {
|
|
666
|
+
if (item.id === LOCAL_WELCOME) localWelcomeRead.value = null;
|
|
667
|
+
else if (item.id === LOCAL_SUGGESTIONS) relatedRead.value = null;
|
|
668
|
+
else {
|
|
669
|
+
patchInboxItem(item.id, { readAt: null });
|
|
670
|
+
useOipApi().projectInbox.update(projectId, item.id, { read: false }).catch(() => loadInbox());
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/** Les epingles montent en tete ; l'ordre se relit dans l'API. */
|
|
675
|
+
async function pinInboxItem(item: ProjectInboxItem) {
|
|
676
|
+
if (isLocal(item)) return;
|
|
677
|
+
const pinned = !item.pinnedAt;
|
|
678
|
+
patchInboxItem(item.id, { pinnedAt: pinned ? new Date().toISOString() : null });
|
|
679
|
+
try {
|
|
680
|
+
await useOipApi().projectInbox.update(projectId, item.id, { pinned });
|
|
681
|
+
} finally {
|
|
682
|
+
loadInbox();
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/** Supprimer est le seul geste qui retire un message : il ne reviendra pas. */
|
|
687
|
+
function removeInboxItem(item: ProjectInboxItem) {
|
|
688
|
+
if (isLocal(item)) return;
|
|
689
|
+
inbox.value = { ...inbox.value, items: inbox.value.items.filter((entry) => entry.id !== item.id) };
|
|
690
|
+
useOipApi().projectInbox.remove(projectId, item.id).catch(() => loadInbox());
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/** Une fiche d'un message, nommee comme dans l'onglet Ressources. */
|
|
694
|
+
function describeResource(type: string, id: string, title?: string | null) {
|
|
695
|
+
if (type === "UploadedDocument") {
|
|
696
|
+
return { label: title || "Document", subtitle: "", path: "", icon: "FileText", family: "Documents", filed: true };
|
|
697
|
+
}
|
|
698
|
+
// Un livrable share-platform rattache au projet : il se lit dans l'onglet Documents.
|
|
699
|
+
if (type === "SharedArtifact") {
|
|
700
|
+
return { label: title || "Document", subtitle: "", path: "", icon: "ShareNetwork", family: en.value ? "Shared" : "Partagés", filed: true };
|
|
701
|
+
}
|
|
702
|
+
const row = rows.value.find((r) => r.type === type && r.id === id);
|
|
703
|
+
const kind = kinds.find((k) => k.type === type);
|
|
704
|
+
return {
|
|
705
|
+
label:
|
|
706
|
+
row?.title ||
|
|
707
|
+
title ||
|
|
708
|
+
(en.value ? `Record no longer in the project (id ${id})` : `Fiche qui n'est plus dans le projet (id ${id})`),
|
|
709
|
+
subtitle: row?.subtitle ?? "",
|
|
710
|
+
path: row?.path ?? "",
|
|
711
|
+
icon: row?.icon ?? kind?.icon ?? "File",
|
|
712
|
+
family: row?.family ?? (kind ? kind.label[lang.value] : type),
|
|
713
|
+
// Retiree depuis : elle se lit dans le message, elle ne s'ouvre plus.
|
|
714
|
+
filed: !!row,
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const documentToOpen = ref("");
|
|
719
|
+
|
|
720
|
+
function openInboxResource(target: { type: string; id: string; label: string; path: string }) {
|
|
721
|
+
if (target.type === "UploadedDocument") {
|
|
722
|
+
documentToOpen.value = target.id;
|
|
723
|
+
setTab("documents");
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
if (target.type === "SharedArtifact") {
|
|
727
|
+
setTab("documents");
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
const row = rows.value.find((r) => r.type === target.type && r.id === target.id);
|
|
731
|
+
if (row) showDetail(row);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/** Une mention dans l'Inbox ouvre la page des notes ou l'on a ete cite. */
|
|
735
|
+
function openNote(noteId: string) {
|
|
736
|
+
tab.value = "notes";
|
|
737
|
+
router.replace({ query: { ...route.query, tab: "notes", note: noteId } });
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/** Les fiches rangees que les notes peuvent citer par `@`. */
|
|
741
|
+
const citableResources = computed(() =>
|
|
742
|
+
rows.value
|
|
743
|
+
.filter((row) => row.known && row.title)
|
|
744
|
+
.map((row) => ({ type: row.type, id: row.id, label: row.title, family: row.family, path: row.path ?? "" })),
|
|
745
|
+
);
|
|
746
|
+
|
|
747
|
+
/** Un changement se lit sur sa fiche : `docId` vaut `<index>:<_id>`. */
|
|
748
|
+
function openChange(change: ProjectInboxChange) {
|
|
749
|
+
const cut = change.docId.indexOf(":");
|
|
750
|
+
const index = change.docId.slice(0, cut);
|
|
751
|
+
const id = change.docId.slice(cut + 1);
|
|
752
|
+
const types = new Set(kinds.filter((k) => k.index === index).map((k) => k.type));
|
|
753
|
+
const row = rows.value.find((r) => types.has(r.type) && r.id === id);
|
|
754
|
+
if (row) showDetail(row);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/** Des fiches entrees au projet : la liste se relit, le bouton Projet des cartes aussi. */
|
|
758
|
+
function onSuggestionDecided(added: boolean) {
|
|
759
|
+
if (!added) return loadInbox();
|
|
760
|
+
if (isActive.value) projects.loadItems(true);
|
|
761
|
+
load();
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/** Une fiche liee triee dans l'Inbox : rangee dans le projet, ou ecartee pour de bon. */
|
|
765
|
+
async function onLocalSuggestion(action: "accept" | "dismiss", item: ProjectSuggestion) {
|
|
766
|
+
if (action === "dismiss") return related.dismiss(item);
|
|
767
|
+
if (await related.accept(item)) load();
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// ------------------------------------------------------------ le chargement
|
|
771
|
+
|
|
772
|
+
async function load() {
|
|
773
|
+
loading.value = true;
|
|
774
|
+
failed.value = false;
|
|
775
|
+
try {
|
|
776
|
+
const [detail, list] = await Promise.all([useOipApi().projects.get(projectId), projects.fetchItems(projectId)]);
|
|
777
|
+
project.value = {
|
|
778
|
+
title: detail?.title ?? "",
|
|
779
|
+
description: detail?.description ?? "",
|
|
780
|
+
createdAt: detail?.createdAt,
|
|
781
|
+
isShared: detail?.isShared,
|
|
782
|
+
owner: detail?.owner,
|
|
783
|
+
scope: (detail as any)?.scope ?? null,
|
|
784
|
+
};
|
|
785
|
+
items.value = list;
|
|
786
|
+
documents.value = await oipProjectHydrate(list, kinds);
|
|
787
|
+
loadUsers();
|
|
788
|
+
loadInbox();
|
|
789
|
+
loadDocumentsCount();
|
|
790
|
+
if (!relatedLoaded) {
|
|
791
|
+
relatedLoaded = true;
|
|
792
|
+
related.load();
|
|
793
|
+
}
|
|
794
|
+
} catch {
|
|
795
|
+
failed.value = true;
|
|
796
|
+
} finally {
|
|
797
|
+
loading.value = false;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// L'acces (une licence) peut arriver apres le montage : rien ne part tant qu'il n'est pas su.
|
|
802
|
+
watch(
|
|
803
|
+
licensed,
|
|
804
|
+
(on) => {
|
|
805
|
+
if (!on) return;
|
|
806
|
+
projects.restoreActive();
|
|
807
|
+
projects.load();
|
|
808
|
+
load();
|
|
809
|
+
},
|
|
810
|
+
{ immediate: true },
|
|
811
|
+
);
|
|
812
|
+
</script>
|
|
813
|
+
|
|
814
|
+
<style scoped>
|
|
815
|
+
/* arg_page_layout centre ses enfants (align-items: center) : chaque onglet se
|
|
816
|
+
reduisait a la largeur de son contenu au lieu de remplir la colonne. */
|
|
817
|
+
.arg_page_layout > * {
|
|
818
|
+
align-self: stretch;
|
|
819
|
+
}
|
|
820
|
+
</style>
|