@tekkare/romulus 0.1.260 → 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/oip-science/clinical-trials/Cards.vue +2 -0
- package/layer/app/components/oip-science/clinical-trials/CardsGlobal.vue +2 -0
- package/layer/app/components/oip-science/clinical-trials/LinkedList.vue +66 -35
- package/layer/app/components/oip-science/hcps/Pubmed.vue +48 -28
- package/layer/app/components/oip-science/pubmed/Cards.vue +2 -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
package/dist/module.json
CHANGED
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
<RmCopyCode :value="linkedNct.nct_id" :lang="lang" />
|
|
21
21
|
<OipScienceClinicalTrialsPairBadge />
|
|
22
22
|
</template>
|
|
23
|
+
<!-- Etiquette posee par la liste a cote des numeros (essai prioritaire). -->
|
|
24
|
+
<slot name="code-extra" />
|
|
23
25
|
</template>
|
|
24
26
|
|
|
25
27
|
<template #title>
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
<RmCopyCode label="EUCT" :value="linkedEuct.euct_number" :lang="lang" />
|
|
21
21
|
<OipScienceClinicalTrialsPairBadge />
|
|
22
22
|
</template>
|
|
23
|
+
<!-- Etiquette posee par la liste a cote des numeros (essai prioritaire). -->
|
|
24
|
+
<slot name="code-extra" />
|
|
23
25
|
</template>
|
|
24
26
|
|
|
25
27
|
<template #title>
|
|
@@ -81,8 +81,10 @@
|
|
|
81
81
|
:highlight="highlight"
|
|
82
82
|
:class="{ linked_priority: isPriority(row) }"
|
|
83
83
|
>
|
|
84
|
-
<template #extra>
|
|
84
|
+
<template #code-extra>
|
|
85
85
|
<RmTag v-if="isPriority(row)" variant="indigo">{{ priority?.label }}</RmTag>
|
|
86
|
+
</template>
|
|
87
|
+
<template #extra>
|
|
86
88
|
<RmTag v-if="row.extra?.role" variant="gray">{{ row.extra.role }}</RmTag>
|
|
87
89
|
<OipScienceCommonScoreBadge :score="row.extra?.score" />
|
|
88
90
|
</template>
|
|
@@ -94,8 +96,10 @@
|
|
|
94
96
|
:highlight="highlight"
|
|
95
97
|
:class="{ linked_priority: isPriority(row) }"
|
|
96
98
|
>
|
|
97
|
-
<template #extra>
|
|
99
|
+
<template #code-extra>
|
|
98
100
|
<RmTag v-if="isPriority(row)" variant="indigo">{{ priority?.label }}</RmTag>
|
|
101
|
+
</template>
|
|
102
|
+
<template #extra>
|
|
99
103
|
<RmTag v-if="row.extra?.role" variant="gray">{{ row.extra.role }}</RmTag>
|
|
100
104
|
<OipScienceCommonScoreBadge :score="row.extra?.score" />
|
|
101
105
|
</template>
|
|
@@ -103,7 +107,8 @@
|
|
|
103
107
|
</template>
|
|
104
108
|
</div>
|
|
105
109
|
|
|
106
|
-
<
|
|
110
|
+
<RmLoadingState v-if="isLoadingRest" :lines="2" />
|
|
111
|
+
<RmEmptyState v-else-if="!filtered.length" :title="$t('oipScience.common.noMatchingResult')" />
|
|
107
112
|
<RmButton
|
|
108
113
|
v-if="visible.length < filtered.length"
|
|
109
114
|
variant="secondary"
|
|
@@ -170,47 +175,73 @@ const { linked: linkedNct, load: loadLinkedNct } = useLinkedTrials('nct');
|
|
|
170
175
|
const nctDocs = ref<any[]>([]);
|
|
171
176
|
const euctDocs = ref<any[]>([]);
|
|
172
177
|
const isLoadingDocs = ref(false);
|
|
178
|
+
/** Les essais prioritaires sont affiches, la suite se charge. */
|
|
179
|
+
const isLoadingRest = ref(false);
|
|
180
|
+
let loadCall = 0;
|
|
181
|
+
|
|
182
|
+
/** Les essais d'une partie des numeros, et leurs jumeaux. */
|
|
183
|
+
async function fetchDocs(nctIds: string[], euctIds: string[]) {
|
|
184
|
+
const [nctRes, euctRes] = await Promise.all([
|
|
185
|
+
nctIds.length
|
|
186
|
+
? queryCustomElastic({
|
|
187
|
+
index: indexConfig.globalCT.index,
|
|
188
|
+
cluster: indexConfig.globalCT.cluster,
|
|
189
|
+
customQuery: { size: nctIds.length, query: { ids: { values: nctIds } } },
|
|
190
|
+
})
|
|
191
|
+
: Promise.resolve({ results: [] }),
|
|
192
|
+
euctIds.length
|
|
193
|
+
? queryCustomElastic({
|
|
194
|
+
index: indexConfig.euct.index,
|
|
195
|
+
cluster: indexConfig.euct.cluster,
|
|
196
|
+
customQuery: {
|
|
197
|
+
size: euctIds.length,
|
|
198
|
+
query: { terms: { 'euct_number.keyword': euctIds } },
|
|
199
|
+
},
|
|
200
|
+
})
|
|
201
|
+
: Promise.resolve({ results: [] }),
|
|
202
|
+
]);
|
|
203
|
+
const nct: any[] = nctRes?.results || [];
|
|
204
|
+
const euct: any[] = euctRes?.results || [];
|
|
205
|
+
// Jumeaux hors de la liste, comme sur les pages de recherche.
|
|
206
|
+
await Promise.all([
|
|
207
|
+
loadLinkedEuct(nct.map((d) => d.nct_id)),
|
|
208
|
+
loadLinkedNct(euct.map((d) => d.nct_number)),
|
|
209
|
+
]);
|
|
210
|
+
return { nct, euct };
|
|
211
|
+
}
|
|
173
212
|
|
|
174
213
|
async function loadDocs() {
|
|
214
|
+
const call = ++loadCall;
|
|
175
215
|
const nctIds = [...new Set(props.nctIds.filter(Boolean))];
|
|
176
216
|
const euctIds = [...new Set(props.euctIds.filter(Boolean))];
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
217
|
+
nctDocs.value = [];
|
|
218
|
+
euctDocs.value = [];
|
|
219
|
+
if (!nctIds.length && !euctIds.length) return;
|
|
220
|
+
// Les essais prioritaires d'abord : la liste s'affiche des qu'ils sont la,
|
|
221
|
+
// le reste suit. Une fiche a plusieurs centaines d'essais attend sinon tout.
|
|
222
|
+
const first = (ids: string[]) => ids.filter((id) => priorityIds.value.has(id));
|
|
223
|
+
const rest = (ids: string[]) => ids.filter((id) => !priorityIds.value.has(id));
|
|
224
|
+
const parts = priorityIds.value.size
|
|
225
|
+
? [[first(nctIds), first(euctIds)], [rest(nctIds), rest(euctIds)]]
|
|
226
|
+
: [[nctIds, euctIds]];
|
|
182
227
|
isLoadingDocs.value = true;
|
|
183
228
|
try {
|
|
184
|
-
const [
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
? queryCustomElastic({
|
|
194
|
-
index: indexConfig.euct.index,
|
|
195
|
-
cluster: indexConfig.euct.cluster,
|
|
196
|
-
customQuery: {
|
|
197
|
-
size: euctIds.length,
|
|
198
|
-
query: { terms: { 'euct_number.keyword': euctIds } },
|
|
199
|
-
},
|
|
200
|
-
})
|
|
201
|
-
: Promise.resolve({ results: [] }),
|
|
202
|
-
]);
|
|
203
|
-
nctDocs.value = nctRes?.results || [];
|
|
204
|
-
euctDocs.value = euctRes?.results || [];
|
|
205
|
-
// Jumeaux hors de la liste, comme sur les pages de recherche.
|
|
206
|
-
await Promise.all([
|
|
207
|
-
loadLinkedEuct(nctDocs.value.map((d) => d.nct_id)),
|
|
208
|
-
loadLinkedNct(euctDocs.value.map((d) => d.nct_number)),
|
|
209
|
-
]);
|
|
229
|
+
for (const [nct, euct] of parts) {
|
|
230
|
+
if (!nct!.length && !euct!.length) continue;
|
|
231
|
+
if (!isLoadingDocs.value) isLoadingRest.value = true;
|
|
232
|
+
const docs = await fetchDocs(nct!, euct!);
|
|
233
|
+
if (call !== loadCall) return;
|
|
234
|
+
nctDocs.value = [...nctDocs.value, ...docs.nct];
|
|
235
|
+
euctDocs.value = [...euctDocs.value, ...docs.euct];
|
|
236
|
+
isLoadingDocs.value = false;
|
|
237
|
+
}
|
|
210
238
|
} catch (e) {
|
|
211
239
|
console.error(e);
|
|
212
240
|
} finally {
|
|
213
|
-
|
|
241
|
+
if (call === loadCall) {
|
|
242
|
+
isLoadingDocs.value = false;
|
|
243
|
+
isLoadingRest.value = false;
|
|
244
|
+
}
|
|
214
245
|
}
|
|
215
246
|
}
|
|
216
247
|
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
:highlight="highlight"
|
|
16
16
|
:class="{ linked_priority: isPriority(res) }"
|
|
17
17
|
>
|
|
18
|
-
<template #extra>
|
|
18
|
+
<template #code-extra>
|
|
19
19
|
<RmTag v-if="isPriority(res)" variant="indigo">{{ priority?.label }}</RmTag>
|
|
20
20
|
</template>
|
|
21
21
|
</OipSciencePubmedCards>
|
|
22
22
|
</div>
|
|
23
23
|
</div>
|
|
24
24
|
<RmLoadingState v-if="isLoading" :lines="3" :chart-height="240" />
|
|
25
|
+
<RmLoadingState v-else-if="isLoadingRest" :lines="2" />
|
|
25
26
|
<RmEmptyState
|
|
26
27
|
v-if="!isLoading && !pubmedResults.length"
|
|
27
28
|
:title="$t('oipScience.common.noDataTitle')"
|
|
@@ -52,11 +53,22 @@ const props = withDefaults(
|
|
|
52
53
|
const { queryCustomElastic, queryOneElastic } = useOipElastic();
|
|
53
54
|
|
|
54
55
|
const isLoading = ref(true);
|
|
56
|
+
/** Les publications prioritaires sont affichees, la suite se charge. */
|
|
57
|
+
const isLoadingRest = ref(false);
|
|
58
|
+
let loadCall = 0;
|
|
55
59
|
const pubmedResults = ref<any[]>([]);
|
|
56
60
|
const scoreByPmid = ref<Record<string, number | null>>({});
|
|
57
61
|
const methodByPmid = ref<Record<string, string | null>>({});
|
|
58
62
|
|
|
63
|
+
const priorityIds = computed(() => new Set(props.priority?.ids ?? []));
|
|
64
|
+
const isPriority = (res: any) => priorityIds.value.has(String(res?.PubMed_ID));
|
|
65
|
+
/** Les publications prioritaires d'abord, chaque groupe gardant l'ordre par date. */
|
|
66
|
+
const ordered = computed(() =>
|
|
67
|
+
[...pubmedResults.value].sort((a, b) => Number(isPriority(b)) - Number(isPriority(a))),
|
|
68
|
+
);
|
|
69
|
+
|
|
59
70
|
async function load(urlId: string) {
|
|
71
|
+
const call = ++loadCall;
|
|
60
72
|
isLoading.value = true;
|
|
61
73
|
pubmedResults.value = [];
|
|
62
74
|
scoreByPmid.value = {};
|
|
@@ -80,8 +92,9 @@ async function load(urlId: string) {
|
|
|
80
92
|
|
|
81
93
|
if (pubmedIds.length === 0) return;
|
|
82
94
|
|
|
83
|
-
// Fetch per-paper match scores for this HCP from the per-trial hcpPubmed index
|
|
84
|
-
|
|
95
|
+
// Fetch per-paper match scores for this HCP from the per-trial hcpPubmed index,
|
|
96
|
+
// sans attendre : les cartes s'affichent, les scores les rejoignent.
|
|
97
|
+
const scores = queryCustomElastic({
|
|
85
98
|
index: indexConfig.hcpPubmed.index,
|
|
86
99
|
cluster: indexConfig.hcpPubmed.cluster,
|
|
87
100
|
customQuery: {
|
|
@@ -101,25 +114,33 @@ async function load(urlId: string) {
|
|
|
101
114
|
},
|
|
102
115
|
},
|
|
103
116
|
},
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
}).then((scoresRes) => {
|
|
118
|
+
const scoreMap: Record<string, number | null> = {};
|
|
119
|
+
const methodMap: Record<string, string | null> = {};
|
|
120
|
+
for (const doc of scoresRes?.results || []) {
|
|
121
|
+
if (!doc?.PubMed_ID) continue;
|
|
122
|
+
const matched = (doc?.hcp || []).find((h: any) => h?.hcp_code === urlId);
|
|
123
|
+
if (matched) {
|
|
124
|
+
scoreMap[doc.PubMed_ID] = typeof matched.score === 'number' ? matched.score : null;
|
|
125
|
+
methodMap[doc.PubMed_ID] = matched.match_method || null;
|
|
126
|
+
}
|
|
114
127
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
if (call !== loadCall) return;
|
|
129
|
+
scoreByPmid.value = scoreMap;
|
|
130
|
+
methodByPmid.value = methodMap;
|
|
131
|
+
});
|
|
118
132
|
|
|
133
|
+
// Les publications prioritaires d'abord : la liste s'affiche des
|
|
134
|
+
// qu'elles sont la, le reste suit, par paquets dates.
|
|
135
|
+
const first = pubmedIds.filter((pmid) => priorityIds.value.has(pmid));
|
|
136
|
+
const pmids = [...first, ...pubmedIds.filter((pmid) => !priorityIds.value.has(pmid))];
|
|
137
|
+
const batches: string[][] = [];
|
|
119
138
|
const batchSize = 1000;
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
139
|
+
for (const [from, to] of [[0, first.length], [first.length, pmids.length]]) {
|
|
140
|
+
for (let i = from!; i < to!; i += batchSize) batches.push(pmids.slice(i, Math.min(i + batchSize, to!)));
|
|
141
|
+
}
|
|
142
|
+
for (const batch of batches) {
|
|
143
|
+
if (!isLoading.value) isLoadingRest.value = true;
|
|
123
144
|
const res = await queryCustomElastic({
|
|
124
145
|
index: indexConfig.pubmed.index,
|
|
125
146
|
cluster: indexConfig.pubmed.cluster,
|
|
@@ -129,24 +150,23 @@ async function load(urlId: string) {
|
|
|
129
150
|
sort: [{ article_date: { order: 'desc' } }],
|
|
130
151
|
},
|
|
131
152
|
});
|
|
132
|
-
|
|
153
|
+
if (call !== loadCall) return;
|
|
154
|
+
pubmedResults.value = [...pubmedResults.value, ...(res?.results || [])];
|
|
155
|
+
isLoading.value = false;
|
|
133
156
|
}
|
|
134
|
-
|
|
157
|
+
await scores;
|
|
135
158
|
} catch (e) {
|
|
136
159
|
console.error(e);
|
|
137
160
|
} finally {
|
|
138
|
-
|
|
161
|
+
if (call === loadCall) {
|
|
162
|
+
isLoading.value = false;
|
|
163
|
+
isLoadingRest.value = false;
|
|
164
|
+
}
|
|
139
165
|
}
|
|
140
166
|
}
|
|
141
167
|
|
|
142
168
|
watch(() => props.id, (id) => { if (id) load(id); }, { immediate: true });
|
|
143
169
|
|
|
144
|
-
const priorityIds = computed(() => new Set(props.priority?.ids ?? []));
|
|
145
|
-
const isPriority = (res: any) => priorityIds.value.has(String(res?.PubMed_ID));
|
|
146
|
-
/** Les publications prioritaires d'abord, chaque groupe gardant l'ordre par date. */
|
|
147
|
-
const ordered = computed(() =>
|
|
148
|
-
[...pubmedResults.value].sort((a, b) => Number(isPriority(b)) - Number(isPriority(a))),
|
|
149
|
-
);
|
|
150
170
|
</script>
|
|
151
171
|
|
|
152
172
|
<style scoped>
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
>
|
|
26
26
|
{{ $t('oipScience.cards.readAbstract') }}
|
|
27
27
|
</RmButton>
|
|
28
|
+
<!-- Etiquette posee par la liste a cote des numeros (essai prioritaire). -->
|
|
29
|
+
<slot name="code-extra" />
|
|
28
30
|
</template>
|
|
29
31
|
|
|
30
32
|
<template #title>
|
|
@@ -53,7 +55,6 @@
|
|
|
53
55
|
:class="matchScore >= 0.85 ? 'score-high' : 'score-low'"
|
|
54
56
|
:data-tooltip="$t('oipScience.common.matchingScoreTooltip')"
|
|
55
57
|
>{{ $t('oipScience.cards.matchingScore') }} : {{ Math.round(matchScore * 100) }}%</span>
|
|
56
|
-
<slot name="extra" />
|
|
57
58
|
</template>
|
|
58
59
|
|
|
59
60
|
<RmDrawer v-model="showModal" size="md" :label="$t('oipScience.cards.pubmedAbstract')">
|
|
@@ -6,41 +6,50 @@
|
|
|
6
6
|
devient l'actif sans quitter la page. Renommer et supprimer restent sur la
|
|
7
7
|
page du projet.
|
|
8
8
|
|
|
9
|
-
Les projets vivent dans la Virtual Lab API
|
|
10
|
-
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
Les projets vivent dans la Virtual Lab API. Par defaut le panneau se
|
|
10
|
+
branche seul sur les projets du layer (useProjects, ProjectNewButton,
|
|
11
|
+
`PROJECTS_PATH`) : l'app n'a rien a lui passer. Une app qui tient ses
|
|
12
|
+
projets elle-meme passe la liste et les gestes par `panelProps.Projects`
|
|
13
|
+
(cf. les props ci-dessous ; `projects` present = branchement de l'app), et
|
|
14
|
+
son bouton de creation assistee par `newButton` (un composant qui emet
|
|
15
|
+
`free` pour ouvrir le formulaire simple).
|
|
16
|
+
|
|
17
|
+
Sans acces aux projets (`useProjectsAccess` de #oip-app/projects) : le
|
|
18
|
+
panneau `PROJECTS_UPSELL`.
|
|
14
19
|
-->
|
|
15
20
|
<template>
|
|
21
|
+
<component :is="PROJECTS_UPSELL" v-if="wired && !allowed && PROJECTS_UPSELL" :feature="FEATURE" />
|
|
16
22
|
<RmProjectPanel
|
|
17
|
-
|
|
18
|
-
:
|
|
19
|
-
:active-
|
|
20
|
-
:
|
|
21
|
-
:
|
|
23
|
+
v-else-if="!wired || allowed"
|
|
24
|
+
:projects="list"
|
|
25
|
+
:active-id="active"
|
|
26
|
+
:active-count="count"
|
|
27
|
+
:loading="isLoading"
|
|
28
|
+
:failed="hasFailed"
|
|
22
29
|
:creating="creating"
|
|
23
|
-
:all-to="
|
|
30
|
+
:all-to="allLink"
|
|
24
31
|
:lang="locale === 'en' ? 'en' : 'fr'"
|
|
25
32
|
@activate="activate"
|
|
26
|
-
@open="
|
|
27
|
-
@pin="
|
|
33
|
+
@open="open"
|
|
34
|
+
@pin="pin"
|
|
28
35
|
@create="onCreate"
|
|
29
36
|
>
|
|
30
|
-
<template v-if="
|
|
31
|
-
<component :is="
|
|
37
|
+
<template v-if="button" #new="{ openForm }">
|
|
38
|
+
<component :is="button" size="sm" @free="openForm" />
|
|
32
39
|
</template>
|
|
33
40
|
</RmProjectPanel>
|
|
34
41
|
</template>
|
|
35
42
|
|
|
36
43
|
<script setup lang="ts">
|
|
37
|
-
import type
|
|
44
|
+
import { resolveComponent, type Component } from "vue";
|
|
38
45
|
import type { RmProject } from "@tekkare/romulus/utils/projects";
|
|
46
|
+
import { PROJECTS_PATH, PROJECTS_UPSELL, useProjectsAccess } from "#oip-projects";
|
|
39
47
|
|
|
40
48
|
const props = withDefaults(
|
|
41
49
|
defineProps<{
|
|
42
50
|
appKey?: string;
|
|
43
51
|
superAdmin?: boolean;
|
|
52
|
+
/** Liste de l'app. Absente : les projets du layer (useProjects). */
|
|
44
53
|
projects?: RmProject[];
|
|
45
54
|
activeId?: string | null;
|
|
46
55
|
/** Elements du projet actif. */
|
|
@@ -58,7 +67,7 @@ const props = withDefaults(
|
|
|
58
67
|
newButton?: Component | null;
|
|
59
68
|
}>(),
|
|
60
69
|
{
|
|
61
|
-
projects:
|
|
70
|
+
projects: undefined,
|
|
62
71
|
activeId: null,
|
|
63
72
|
activeCount: 0,
|
|
64
73
|
loading: false,
|
|
@@ -79,23 +88,63 @@ const emit = defineEmits<{
|
|
|
79
88
|
close: [];
|
|
80
89
|
}>();
|
|
81
90
|
|
|
91
|
+
const FEATURE = { fr: "Projets", en: "Projects" };
|
|
92
|
+
|
|
82
93
|
const { locale } = useI18n();
|
|
94
|
+
const router = useRouter();
|
|
95
|
+
const localePath = useLocalePath();
|
|
83
96
|
const creating = ref(false);
|
|
84
97
|
|
|
98
|
+
/** Branche sur les projets du layer quand l'app ne passe pas les siens. */
|
|
99
|
+
const wired = props.projects === undefined;
|
|
100
|
+
const own = wired ? useProjects() : null;
|
|
101
|
+
const allowed = useProjectsAccess();
|
|
102
|
+
const newProjectButton = resolveComponent("ProjectNewButton");
|
|
103
|
+
|
|
104
|
+
const list = computed(() => (own ? own.rmProjects.value : props.projects ?? []));
|
|
105
|
+
const active = computed(() => (own ? own.activeId.value : props.activeId));
|
|
106
|
+
const count = computed(() => (own ? own.items.value.length : props.activeCount));
|
|
107
|
+
const isLoading = computed(() => (own ? own.pending.value : props.loading));
|
|
108
|
+
const hasFailed = computed(() => (own ? !!own.failure.value : props.failed));
|
|
109
|
+
const allLink = computed(() => (own ? localePath(PROJECTS_PATH) : props.allTo));
|
|
110
|
+
const button = computed(() => (own ? newProjectButton : props.newButton));
|
|
111
|
+
|
|
85
112
|
async function onCreate(title: string) {
|
|
86
|
-
|
|
113
|
+
const create = own
|
|
114
|
+
? async (name: string) => {
|
|
115
|
+
const project = await own.create(name);
|
|
116
|
+
own.setActive(project.id);
|
|
117
|
+
}
|
|
118
|
+
: props.create;
|
|
119
|
+
if (!create) return;
|
|
87
120
|
creating.value = true;
|
|
88
121
|
try {
|
|
89
|
-
await
|
|
122
|
+
await create(title);
|
|
90
123
|
} finally {
|
|
91
124
|
creating.value = false;
|
|
92
125
|
}
|
|
93
126
|
}
|
|
94
127
|
|
|
95
128
|
function activate(id: string) {
|
|
96
|
-
|
|
129
|
+
if (own) own.setActive(id);
|
|
130
|
+
else emit("activate", id);
|
|
97
131
|
emit("close");
|
|
98
132
|
}
|
|
99
133
|
|
|
100
|
-
|
|
134
|
+
function open(id: string) {
|
|
135
|
+
if (own) router.push(own.pathOf(id));
|
|
136
|
+
else emit("open", id);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function pin(id: string) {
|
|
140
|
+
if (own) own.togglePin(id);
|
|
141
|
+
else emit("pin", id);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
onMounted(() => {
|
|
145
|
+
if (own) own.restoreActive();
|
|
146
|
+
emit("mounted");
|
|
147
|
+
});
|
|
148
|
+
// L'acces (une licence) peut arriver apres le montage : la liste se charge quand il est su.
|
|
149
|
+
if (own) watch(allowed, (on) => on && own.load(), { immediate: true });
|
|
101
150
|
</script>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Bouton « Projet » d'une carte ou d'un en-tete : RmProjectAddButton branche
|
|
3
|
+
sur le projet actif (cf. useProjects).
|
|
4
|
+
|
|
5
|
+
Il se pose dans le slot `#actions` d'une RmResultCard. La carte s'inscrit
|
|
6
|
+
aupres du cadre tant qu'elle est a l'ecran : c'est ce qui permet au bandeau
|
|
7
|
+
de proposer « Ajouter la page » sans que chaque page declare ce qu'elle
|
|
8
|
+
affiche.
|
|
9
|
+
-->
|
|
10
|
+
<template>
|
|
11
|
+
<RmProjectAddButton
|
|
12
|
+
v-if="ids.length"
|
|
13
|
+
v-model:archived="archived"
|
|
14
|
+
:in-project="inProject"
|
|
15
|
+
:needs-project="!projects.activeId.value"
|
|
16
|
+
:compact="compact"
|
|
17
|
+
:loading="busy"
|
|
18
|
+
:error="error"
|
|
19
|
+
:projects="projects.rmProjects.value"
|
|
20
|
+
:projects-loading="projects.pending.value"
|
|
21
|
+
:projects-failed="!!projects.failure.value"
|
|
22
|
+
:creating="creating"
|
|
23
|
+
:lang="projects.lang.value"
|
|
24
|
+
@toggle="toggle"
|
|
25
|
+
@pick="projects.load()"
|
|
26
|
+
@choose="chooseAndAdd"
|
|
27
|
+
@create="createAndAdd"
|
|
28
|
+
@unarchive="confirmUnarchive"
|
|
29
|
+
/>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script setup lang="ts">
|
|
33
|
+
import type { ProjectResourceId } from "../../composables/useProjects";
|
|
34
|
+
|
|
35
|
+
const props = defineProps<{
|
|
36
|
+
/** `_id` Elasticsearch du document, cf. useOipProjectKinds. Une liste quand la carte en porte plusieurs. */
|
|
37
|
+
resourceId: ProjectResourceId | null | undefined;
|
|
38
|
+
/** Le `resourceType` de l'API, cle de OIP_RESOURCE_SPECS. */
|
|
39
|
+
type: string;
|
|
40
|
+
/** Icone seule : la carte de resultat porte deja ses autres actions en icones. */
|
|
41
|
+
compact?: boolean;
|
|
42
|
+
/** Titre de la carte : ce que le bandeau nomme quand une fiche est archivee. */
|
|
43
|
+
label?: string;
|
|
44
|
+
}>();
|
|
45
|
+
|
|
46
|
+
const projects = useProjects();
|
|
47
|
+
|
|
48
|
+
const busy = ref(false);
|
|
49
|
+
const creating = ref(false);
|
|
50
|
+
const archived = ref(false);
|
|
51
|
+
const error = ref("");
|
|
52
|
+
|
|
53
|
+
const ids = computed(() => {
|
|
54
|
+
const raw = Array.isArray(props.resourceId) ? props.resourceId : [props.resourceId];
|
|
55
|
+
return raw.filter((value) => value != null && value !== "").map(String);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const inProject = computed(() => projects.has(ids.value, props.type));
|
|
59
|
+
|
|
60
|
+
const registryKey = computed(() => `${props.type}:${ids.value.join(",")}`);
|
|
61
|
+
|
|
62
|
+
onMounted(() => projects.restoreActive());
|
|
63
|
+
|
|
64
|
+
watch(
|
|
65
|
+
[registryKey, () => props.label],
|
|
66
|
+
([key, label], [previous]) => {
|
|
67
|
+
if (previous && previous !== key) projects.unregisterAddable(previous);
|
|
68
|
+
if (!ids.value.length) return;
|
|
69
|
+
projects.registerAddable(key, { ids: ids.value, resourceType: props.type, label: label ?? "" });
|
|
70
|
+
},
|
|
71
|
+
{ immediate: true },
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
onBeforeUnmount(() => projects.unregisterAddable(registryKey.value));
|
|
75
|
+
|
|
76
|
+
function reason(err: any) {
|
|
77
|
+
return err?.data?.message || err?.message || "";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function run(task: () => Promise<unknown>) {
|
|
81
|
+
busy.value = true;
|
|
82
|
+
error.value = "";
|
|
83
|
+
try {
|
|
84
|
+
await task();
|
|
85
|
+
} catch (err) {
|
|
86
|
+
error.value = reason(err);
|
|
87
|
+
} finally {
|
|
88
|
+
busy.value = false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function toggle() {
|
|
93
|
+
return run(async () => {
|
|
94
|
+
if (inProject.value) return projects.remove(ids.value, props.type);
|
|
95
|
+
const response = await projects.add(ids.value, props.type);
|
|
96
|
+
// Refusee parce qu'archivee : la question se pose, elle ne se tranche pas.
|
|
97
|
+
if (projects.archivedOf(response).length) archived.value = true;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function chooseAndAdd(projectId: string) {
|
|
102
|
+
projects.setActive(projectId);
|
|
103
|
+
return run(async () => {
|
|
104
|
+
const response = await projects.add(ids.value, props.type, projectId);
|
|
105
|
+
if (projects.archivedOf(response).length) archived.value = true;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function createAndAdd(title: string) {
|
|
110
|
+
creating.value = true;
|
|
111
|
+
try {
|
|
112
|
+
const project = await projects.create(title);
|
|
113
|
+
await chooseAndAdd(project.id);
|
|
114
|
+
} catch (err) {
|
|
115
|
+
error.value = reason(err);
|
|
116
|
+
} finally {
|
|
117
|
+
creating.value = false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function confirmUnarchive() {
|
|
122
|
+
return run(async () => {
|
|
123
|
+
await projects.unarchive(ids.value, props.type);
|
|
124
|
+
archived.value = false;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
</script>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Bandeau du projet actif : RmProjectBanner branche sur useProjects.
|
|
3
|
+
|
|
4
|
+
Servi par le layer OIP : l'app le pose une fois dans son cadre
|
|
5
|
+
(layout/shell.vue, slot `header-after` d'OipShell), sur toutes les pages.
|
|
6
|
+
C'est lui qui restaure le projet actif au chargement, et la liste des
|
|
7
|
+
projets (le bandeau nomme le projet, seul le nom vient de la liste). Sur la
|
|
8
|
+
page d'un projet, il redirait ce que la page affiche : seul le rendu se
|
|
9
|
+
coupe.
|
|
10
|
+
-->
|
|
11
|
+
<template>
|
|
12
|
+
<RmProjectBanner
|
|
13
|
+
v-if="projects.active.value && !onProjectPage"
|
|
14
|
+
:title="projects.active.value.title"
|
|
15
|
+
:to="projects.pathOf(projects.active.value.id)"
|
|
16
|
+
:count="projects.items.value.length"
|
|
17
|
+
:addable="projects.pageAddable.value.length"
|
|
18
|
+
:adding="adding"
|
|
19
|
+
:archived="archived"
|
|
20
|
+
:unarchiving="unarchiving"
|
|
21
|
+
:lang="projects.lang.value"
|
|
22
|
+
@add-page="addPage"
|
|
23
|
+
@open="router.push(projects.pathOf(projects.activeId.value!))"
|
|
24
|
+
@leave="projects.setActive(null)"
|
|
25
|
+
@unarchive="confirmUnarchive"
|
|
26
|
+
@dismiss-archived="archived = []"
|
|
27
|
+
/>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
import type { RmProjectArchivedEntry } from "@tekkare/romulus/utils/projects";
|
|
32
|
+
import { PROJECTS_PATH } from "#oip-projects";
|
|
33
|
+
|
|
34
|
+
const projects = useProjects();
|
|
35
|
+
const router = useRouter();
|
|
36
|
+
const route = useRoute();
|
|
37
|
+
|
|
38
|
+
const onProjectPage = computed(() => route.path.includes(`${PROJECTS_PATH}/`));
|
|
39
|
+
|
|
40
|
+
onMounted(() => {
|
|
41
|
+
projects.restoreActive();
|
|
42
|
+
if (projects.activeId.value) projects.load();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const adding = ref(false);
|
|
46
|
+
const archived = ref<RmProjectArchivedEntry[]>([]);
|
|
47
|
+
const unarchiving = ref(false);
|
|
48
|
+
|
|
49
|
+
async function addPage() {
|
|
50
|
+
if (adding.value) return;
|
|
51
|
+
adding.value = true;
|
|
52
|
+
try {
|
|
53
|
+
archived.value = await projects.addPage();
|
|
54
|
+
} finally {
|
|
55
|
+
adding.value = false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function confirmUnarchive() {
|
|
60
|
+
unarchiving.value = true;
|
|
61
|
+
try {
|
|
62
|
+
await projects.unarchiveEntries(archived.value);
|
|
63
|
+
archived.value = [];
|
|
64
|
+
} finally {
|
|
65
|
+
unarchiving.value = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
</script>
|