@tekkare/romulus 0.1.304 → 0.1.306
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
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
des espaces au lieu des personnes. Une liste d'espaces vide vaut « tous »,
|
|
15
15
|
pour la meme raison que « tout l'espace » n'est pas deplie en noms.
|
|
16
16
|
|
|
17
|
+
Un modele peut aussi viser des personnes nommees, quel que soit leur espace.
|
|
18
|
+
Ce n'est pas la portee « des personnes choisies » : la vue reste un modele,
|
|
19
|
+
rangee dans le catalogue, pas dans leurs vues partagees. Espaces et
|
|
20
|
+
personnes se cumulent ; « tous » ne vaut que si les deux listes sont vides.
|
|
21
|
+
|
|
17
22
|
La liste des noms reste montee quand la portee change : on revient de
|
|
18
23
|
« tout l'espace » a « des personnes » sans avoir reperdu sa selection.
|
|
19
24
|
|
|
@@ -63,8 +68,13 @@ const props = withDefaults(
|
|
|
63
68
|
canTemplate?: boolean
|
|
64
69
|
/** La vue est deja publiee comme modele. */
|
|
65
70
|
isTemplate?: boolean
|
|
66
|
-
/** Espaces deja vises. Vide vaut « tous ». */
|
|
71
|
+
/** Espaces deja vises. Vide, sans personne visee, vaut « tous ». */
|
|
67
72
|
targetWorkspaces?: string[]
|
|
73
|
+
/**
|
|
74
|
+
* Personnes deja visees par le modele, avec leur nom : elles viennent
|
|
75
|
+
* souvent d'autres espaces, que la liste `members` ne connait pas.
|
|
76
|
+
*/
|
|
77
|
+
targetUsers?: RmShareMember[]
|
|
68
78
|
/** Espaces proposes. L'appelant les charge quand le dialogue s'ouvre. */
|
|
69
79
|
workspaces?: RmShareWorkspace[]
|
|
70
80
|
/**
|
|
@@ -88,6 +98,7 @@ const props = withDefaults(
|
|
|
88
98
|
canTemplate: false,
|
|
89
99
|
isTemplate: false,
|
|
90
100
|
targetWorkspaces: () => [],
|
|
101
|
+
targetUsers: () => [],
|
|
91
102
|
workspaces: () => [],
|
|
92
103
|
templateNote: '',
|
|
93
104
|
texts: () => ({}),
|
|
@@ -112,6 +123,7 @@ const emit = defineEmits<{
|
|
|
112
123
|
/** Absents quand l'appelant n'a pas le droit de publier. */
|
|
113
124
|
isTemplate?: boolean
|
|
114
125
|
targetWorkspaces?: string[]
|
|
126
|
+
targetUsers?: string[]
|
|
115
127
|
},
|
|
116
128
|
]
|
|
117
129
|
}>()
|
|
@@ -145,15 +157,36 @@ const T = computed(() => ({
|
|
|
145
157
|
templateHint: en.value
|
|
146
158
|
? 'Offered as a starting point on this page, without being shared.'
|
|
147
159
|
: 'Offert comme point de depart sur cette page, sans etre partage.',
|
|
148
|
-
workspaceSearch: en.value ? 'Search for a workspace' : 'Chercher un espace',
|
|
149
160
|
noWorkspace: en.value ? 'No workspace to offer it to.' : 'Aucun espace a qui l\'offrir.',
|
|
161
|
+
templateSearch: en.value
|
|
162
|
+
? 'Search for a workspace or a person'
|
|
163
|
+
: 'Chercher un espace ou une personne',
|
|
164
|
+
templateHintTargets: en.value
|
|
165
|
+
? 'A person sees it whatever their workspace. It stays a template, not a shared view.'
|
|
166
|
+
: 'Une personne le voit quel que soit son espace. Il reste un template, pas une vue partagee.',
|
|
167
|
+
templatePicked: en.value ? 'Picked' : 'Retenus',
|
|
168
|
+
kindWorkspace: en.value ? 'Workspace' : 'Espace',
|
|
169
|
+
kindPerson: en.value ? 'Person' : 'Personne',
|
|
150
170
|
allWorkspaces: en.value
|
|
151
|
-
? 'No workspace picked: every workspace is offered the template.'
|
|
152
|
-
: 'Aucun espace
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
171
|
+
? 'No workspace or person picked: every workspace is offered the template.'
|
|
172
|
+
: 'Aucun espace ni personne retenus : le template est offert a tous les espaces.',
|
|
173
|
+
templateCount: (ws: number, people: number) => {
|
|
174
|
+
const parts = [
|
|
175
|
+
ws
|
|
176
|
+
? en.value
|
|
177
|
+
? `${ws} ${ws > 1 ? 'workspaces' : 'workspace'}`
|
|
178
|
+
: `${ws} espace${ws > 1 ? 's' : ''}`
|
|
179
|
+
: '',
|
|
180
|
+
people
|
|
181
|
+
? en.value
|
|
182
|
+
? `${people} ${people > 1 ? 'people' : 'person'}`
|
|
183
|
+
: `${people} personne${people > 1 ? 's' : ''}`
|
|
184
|
+
: '',
|
|
185
|
+
].filter(Boolean)
|
|
186
|
+
return en.value
|
|
187
|
+
? `Offered only to: ${parts.join(' and ')}.`
|
|
188
|
+
: `Offert uniquement a : ${parts.join(' et ')}.`
|
|
189
|
+
},
|
|
157
190
|
...props.texts,
|
|
158
191
|
}))
|
|
159
192
|
|
|
@@ -161,7 +194,10 @@ const scope = ref<RmShareScope>('private')
|
|
|
161
194
|
const picked = ref<string[]>([])
|
|
162
195
|
const search = ref('')
|
|
163
196
|
const pickedWorkspaces = ref<string[]>([])
|
|
164
|
-
|
|
197
|
+
/** Personnes visees par le modele, gardees avec leur nom pour les etiquettes. */
|
|
198
|
+
const pickedPeople = ref<RmShareMember[]>([])
|
|
199
|
+
/** Une seule recherche pour le modele : espaces et personnes, dans une liste. */
|
|
200
|
+
const templateSearch = ref('')
|
|
165
201
|
|
|
166
202
|
/**
|
|
167
203
|
* L'etat ouvert fait foi : le dialogue se recharge a chaque ouverture, jamais
|
|
@@ -173,6 +209,7 @@ watch(
|
|
|
173
209
|
if (!open) return
|
|
174
210
|
picked.value = [...props.sharedWith]
|
|
175
211
|
pickedWorkspaces.value = [...props.targetWorkspaces]
|
|
212
|
+
pickedPeople.value = [...props.targetUsers]
|
|
176
213
|
scope.value = props.isTemplate
|
|
177
214
|
? 'template'
|
|
178
215
|
: props.visibility === 'workspace'
|
|
@@ -181,12 +218,14 @@ watch(
|
|
|
181
218
|
? 'people'
|
|
182
219
|
: 'private'
|
|
183
220
|
search.value = ''
|
|
184
|
-
|
|
221
|
+
templateSearch.value = ''
|
|
185
222
|
},
|
|
186
223
|
{ immediate: true },
|
|
187
224
|
)
|
|
188
225
|
|
|
189
226
|
watch(search, value => emit('search', value.trim()))
|
|
227
|
+
// Meme recherche cote appelant : il complete `members` avec la plateforme.
|
|
228
|
+
watch(templateSearch, value => emit('search', value.trim()))
|
|
190
229
|
|
|
191
230
|
const matches = computed(() => {
|
|
192
231
|
const q = search.value.trim().toLowerCase()
|
|
@@ -205,11 +244,6 @@ function toggle(userId: string) {
|
|
|
205
244
|
picked.value = [...next]
|
|
206
245
|
}
|
|
207
246
|
|
|
208
|
-
const workspaceMatches = computed(() => {
|
|
209
|
-
const q = workspaceSearch.value.trim().toLowerCase()
|
|
210
|
-
if (!q) return props.workspaces
|
|
211
|
-
return props.workspaces.filter(ws => ws.name.toLowerCase().includes(q))
|
|
212
|
-
})
|
|
213
247
|
|
|
214
248
|
function toggleWorkspace(workspaceId: string) {
|
|
215
249
|
const next = new Set(pickedWorkspaces.value)
|
|
@@ -218,6 +252,72 @@ function toggleWorkspace(workspaceId: string) {
|
|
|
218
252
|
pickedWorkspaces.value = [...next]
|
|
219
253
|
}
|
|
220
254
|
|
|
255
|
+
type TemplateRow = {
|
|
256
|
+
key: string
|
|
257
|
+
label: string
|
|
258
|
+
description: string
|
|
259
|
+
checked: boolean
|
|
260
|
+
toggle: () => void
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* La liste unique du modele : les espaces d'abord, puis les personnes.
|
|
265
|
+
*
|
|
266
|
+
* Sans recherche, seuls les espaces s'affichent : ils tiennent dans une
|
|
267
|
+
* liste, la plateforme entiere non, et les membres de l'espace de
|
|
268
|
+
* l'administrateur n'ont rien a faire la par defaut. Chaque ligne dit ce
|
|
269
|
+
* qu'elle est (« Espace » ou « Personne ») : une case ne le dit pas seule.
|
|
270
|
+
*/
|
|
271
|
+
const templateRows = computed<TemplateRow[]>(() => {
|
|
272
|
+
const q = templateSearch.value.trim().toLowerCase()
|
|
273
|
+
const workspaces = (q
|
|
274
|
+
? props.workspaces.filter(ws => ws.name.toLowerCase().includes(q))
|
|
275
|
+
: props.workspaces
|
|
276
|
+
).map(ws => ({
|
|
277
|
+
key: `ws:${ws.workspaceId}`,
|
|
278
|
+
label: ws.name,
|
|
279
|
+
description: [T.value.kindWorkspace, ws.tier].filter(Boolean).join(' · '),
|
|
280
|
+
checked: pickedWorkspaces.value.includes(ws.workspaceId),
|
|
281
|
+
toggle: () => toggleWorkspace(ws.workspaceId),
|
|
282
|
+
}))
|
|
283
|
+
const people = (q
|
|
284
|
+
? props.members.filter(
|
|
285
|
+
m => m.name.toLowerCase().includes(q) || (m.email ?? '').toLowerCase().includes(q),
|
|
286
|
+
)
|
|
287
|
+
: []
|
|
288
|
+
).map(m => ({
|
|
289
|
+
key: `user:${m.userId}`,
|
|
290
|
+
label: m.name,
|
|
291
|
+
description: [T.value.kindPerson, m.email, m.hint].filter(Boolean).join(' · '),
|
|
292
|
+
checked: pickedPeople.value.some(p => p.userId === m.userId),
|
|
293
|
+
toggle: () => togglePerson(m),
|
|
294
|
+
}))
|
|
295
|
+
return [...workspaces, ...people]
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
/** Ce qui est retenu, en etiquettes : les personnes trouvees par recherche
|
|
299
|
+
* sortent de la liste des que la recherche change. */
|
|
300
|
+
const templateTags = computed(() => [
|
|
301
|
+
...pickedWorkspaces.value.map(id => ({
|
|
302
|
+
key: `ws:${id}`,
|
|
303
|
+
icon: 'Buildings',
|
|
304
|
+
label: props.workspaces.find(ws => ws.workspaceId === id)?.name ?? id,
|
|
305
|
+
remove: () => toggleWorkspace(id),
|
|
306
|
+
})),
|
|
307
|
+
...pickedPeople.value.map(person => ({
|
|
308
|
+
key: `user:${person.userId}`,
|
|
309
|
+
icon: 'User',
|
|
310
|
+
label: person.name,
|
|
311
|
+
remove: () => togglePerson(person),
|
|
312
|
+
})),
|
|
313
|
+
])
|
|
314
|
+
|
|
315
|
+
function togglePerson(member: RmShareMember) {
|
|
316
|
+
pickedPeople.value = pickedPeople.value.some(p => p.userId === member.userId)
|
|
317
|
+
? pickedPeople.value.filter(p => p.userId !== member.userId)
|
|
318
|
+
: [...pickedPeople.value, member]
|
|
319
|
+
}
|
|
320
|
+
|
|
221
321
|
function close() {
|
|
222
322
|
emit('update:modelValue', false)
|
|
223
323
|
}
|
|
@@ -236,6 +336,7 @@ function save() {
|
|
|
236
336
|
...(props.canTemplate && {
|
|
237
337
|
isTemplate: scope.value === 'template',
|
|
238
338
|
targetWorkspaces: scope.value === 'template' ? pickedWorkspaces.value : [],
|
|
339
|
+
targetUsers: scope.value === 'template' ? pickedPeople.value.map(p => p.userId) : [],
|
|
239
340
|
}),
|
|
240
341
|
})
|
|
241
342
|
}
|
|
@@ -344,39 +445,55 @@ const scopes = computed<Array<{ key: RmShareScope; icon: string; label: string;
|
|
|
344
445
|
|
|
345
446
|
<!--
|
|
346
447
|
Meme forme que la liste des personnes : une recherche, des cases, un
|
|
347
|
-
compte.
|
|
348
|
-
|
|
349
|
-
|
|
448
|
+
compte. Espaces et personnes partagent la recherche et la liste ; ce
|
|
449
|
+
qui est retenu reste visible en etiquettes au-dessus. Aucun choix ne
|
|
450
|
+
veut pas dire « personne » mais « tous », et c'est dit a l'ecran.
|
|
350
451
|
-->
|
|
351
452
|
<div v-show="scope === 'template'" class="rm-share__people">
|
|
352
453
|
<p v-if="templateNote" class="rm-share__note">{{ templateNote }}</p>
|
|
454
|
+
<p class="rm-share__scope-hint">{{ T.templateHintTargets }}</p>
|
|
455
|
+
|
|
456
|
+
<ul v-if="templateTags.length" class="rm-share__tags" :aria-label="T.templatePicked">
|
|
457
|
+
<li v-for="tag in templateTags" :key="tag.key">
|
|
458
|
+
<RmTag variant="gray" closable @close="tag.remove()">
|
|
459
|
+
<RmIcon :name="tag.icon" :size="12" />
|
|
460
|
+
{{ tag.label }}
|
|
461
|
+
</RmTag>
|
|
462
|
+
</li>
|
|
463
|
+
</ul>
|
|
353
464
|
|
|
354
465
|
<label class="rm-share__search">
|
|
355
466
|
<RmIcon name="MagnifyingGlass" :size="16" />
|
|
356
467
|
<input
|
|
357
|
-
v-model="
|
|
468
|
+
v-model="templateSearch"
|
|
358
469
|
type="search"
|
|
359
|
-
:placeholder="T.
|
|
360
|
-
:aria-label="T.
|
|
470
|
+
:placeholder="T.templateSearch"
|
|
471
|
+
:aria-label="T.templateSearch"
|
|
361
472
|
>
|
|
362
473
|
</label>
|
|
363
474
|
|
|
364
|
-
<p v-if="!workspaces.length" class="rm-share__empty">
|
|
365
|
-
|
|
475
|
+
<p v-if="!templateSearch.trim() && !workspaces.length" class="rm-share__empty">
|
|
476
|
+
{{ T.noWorkspace }}
|
|
477
|
+
</p>
|
|
478
|
+
<p v-else-if="!templateRows.length" class="rm-share__empty">{{ T.noMatch }}</p>
|
|
366
479
|
|
|
367
480
|
<ul v-else class="rm-share__list">
|
|
368
|
-
<li v-for="
|
|
481
|
+
<li v-for="row in templateRows" :key="row.key">
|
|
369
482
|
<RmCheckbox
|
|
370
|
-
:model-value="
|
|
371
|
-
:label="
|
|
372
|
-
:description="
|
|
373
|
-
@update:model-value="
|
|
483
|
+
:model-value="row.checked"
|
|
484
|
+
:label="row.label"
|
|
485
|
+
:description="row.description"
|
|
486
|
+
@update:model-value="row.toggle()"
|
|
374
487
|
/>
|
|
375
488
|
</li>
|
|
376
489
|
</ul>
|
|
377
490
|
|
|
378
491
|
<p class="rm-share__count">
|
|
379
|
-
{{
|
|
492
|
+
{{
|
|
493
|
+
pickedWorkspaces.length || pickedPeople.length
|
|
494
|
+
? T.templateCount(pickedWorkspaces.length, pickedPeople.length)
|
|
495
|
+
: T.allWorkspaces
|
|
496
|
+
}}
|
|
380
497
|
</p>
|
|
381
498
|
</div>
|
|
382
499
|
</div>
|
|
@@ -395,5 +512,5 @@ const scopes = computed<Array<{ key: RmShareScope; icon: string; label: string;
|
|
|
395
512
|
</template>
|
|
396
513
|
|
|
397
514
|
<style scoped>
|
|
398
|
-
.rm-share,.rm-share :where(*){box-sizing:border-box}.rm-share{display:flex;flex-direction:column;gap:var(--space-16)}.rm-share__note{background:var(--bg-surface-2);border:1px solid var(--border-soft);border-radius:var(--radius-md);color:var(--text-secondary);font-size:var(--font-12);padding:var(--space-8) var(--space-10)}.rm-share__head{display:flex;flex-direction:column;gap:var(--space-4)}.rm-share__title{color:var(--text-primary);font-size:var(--font-16);font-weight:var(--weight-bold)}.rm-share__subject{color:var(--text-secondary);font-size:var(--font-13)}.rm-share__scopes{display:flex;flex-direction:column;gap:var(--space-8);list-style:none;margin:0;padding:0}.rm-share__scope{align-items:flex-start;background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-lg);color:var(--text-primary);cursor:pointer;display:flex;gap:var(--space-10);padding:var(--space-10) var(--space-12);text-align:left;width:100%}.rm-share__scope:hover{background:var(--bg-hover)}.rm-share__radio{border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);white-space:nowrap}.rm-share__scope:has(.rm-share__radio:focus-visible){outline:2px solid var(--color-secondary);outline-offset:2px}.rm-share__scope.is-on{background:var(--bg-hover);border-color:var(--color-secondary)}.rm-share__scope-text{display:flex;flex:1;flex-direction:column;gap:2px}.rm-share__scope-label{font-size:var(--font-13);font-weight:var(--weight-medium)}.rm-share__scope-hint{color:var(--text-secondary);font-size:var(--font-12)}.rm-share__scope-mark{color:var(--color-secondary)}.rm-share__people{display:flex;flex-direction:column;gap:var(--space-8)}.rm-share__search{align-items:center;background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-pill);color:var(--text-muted);display:flex;gap:var(--space-8);padding:var(--space-6) var(--space-10)}.rm-share__search input{background:none;border:none;color:var(--text-primary);flex:1;font-size:var(--font-13);outline:none}.rm-share__list{
|
|
515
|
+
.rm-share,.rm-share :where(*){box-sizing:border-box}.rm-share{display:flex;flex-direction:column;gap:var(--space-16)}.rm-share__note{background:var(--bg-surface-2);border:1px solid var(--border-soft);border-radius:var(--radius-md);color:var(--text-secondary);font-size:var(--font-12);padding:var(--space-8) var(--space-10)}.rm-share__head{display:flex;flex-direction:column;gap:var(--space-4)}.rm-share__title{color:var(--text-primary);font-size:var(--font-16);font-weight:var(--weight-bold)}.rm-share__subject{color:var(--text-secondary);font-size:var(--font-13)}.rm-share__scopes{display:flex;flex-direction:column;gap:var(--space-8);list-style:none;margin:0;padding:0}.rm-share__scope{align-items:flex-start;background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-lg);color:var(--text-primary);cursor:pointer;display:flex;gap:var(--space-10);padding:var(--space-10) var(--space-12);text-align:left;width:100%}.rm-share__scope:hover{background:var(--bg-hover)}.rm-share__radio{border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);white-space:nowrap}.rm-share__scope:has(.rm-share__radio:focus-visible){outline:2px solid var(--color-secondary);outline-offset:2px}.rm-share__scope.is-on{background:var(--bg-hover);border-color:var(--color-secondary)}.rm-share__scope-text{display:flex;flex:1;flex-direction:column;gap:2px}.rm-share__scope-label{font-size:var(--font-13);font-weight:var(--weight-medium)}.rm-share__scope-hint{color:var(--text-secondary);font-size:var(--font-12)}.rm-share__scope-mark{color:var(--color-secondary)}.rm-share__people{display:flex;flex-direction:column;gap:var(--space-8)}.rm-share__search{align-items:center;background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-pill);color:var(--text-muted);display:flex;gap:var(--space-8);padding:var(--space-6) var(--space-10)}.rm-share__search input{background:none;border:none;color:var(--text-primary);flex:1;font-size:var(--font-13);outline:none}.rm-share__list{flex-direction:column;gap:2px}.rm-share__list,.rm-share__tags{display:flex;list-style:none;margin:0;padding:0}.rm-share__tags{flex-wrap:wrap;gap:var(--space-6)}.rm-share__count,.rm-share__empty{color:var(--text-secondary);font-size:var(--font-12)}.rm-share__foot{display:flex;gap:var(--space-8);justify-content:flex-end}
|
|
399
516
|
</style>
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
Tout template se gere ici, quel que soit qui l'a publie : changer les
|
|
10
10
|
espaces qui le recoivent, ou le retirer. Retirer ne supprime rien : la vue
|
|
11
|
-
revient dans « Mes vues » de son proprietaire. L'acces d'un template
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
revient dans « Mes vues » de son proprietaire. L'acces d'un template passe
|
|
12
|
+
par ses espaces cibles et par des personnes nommees (`targetUsers`), jamais
|
|
13
|
+
par le partage nominatif d'une vue, que l'API ignore sur un template.
|
|
14
14
|
-->
|
|
15
15
|
<script setup lang="ts">
|
|
16
16
|
import { useOipApi } from "#oip-app/api";
|
|
@@ -29,6 +29,17 @@ const { cardOf, start } = useViewTemplates(() => page.value);
|
|
|
29
29
|
|
|
30
30
|
type Row = Awaited<ReturnType<typeof elysia.admin.viewTemplates>>["data"][number];
|
|
31
31
|
|
|
32
|
+
/** Personne visee par un template, telle que l'inventaire la renvoie. */
|
|
33
|
+
type Person = { userId: string; name: string; email?: string };
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Lu hors du type de l'app : le client API de chaque app ne declare
|
|
37
|
+
* `targetUsers` qu'une fois remonte, et le layer ne doit pas casser avant.
|
|
38
|
+
*/
|
|
39
|
+
function peopleOf(row: Row | null | undefined): Person[] {
|
|
40
|
+
return (row as { targetUsers?: Person[] } | null | undefined)?.targetUsers ?? [];
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
const rows = ref<Row[]>([]);
|
|
33
44
|
const loading = ref(false);
|
|
34
45
|
|
|
@@ -68,7 +79,8 @@ function workspaceName(id: string) {
|
|
|
68
79
|
/** Qui a acces : tous les espaces quand aucune cible n'est posee. */
|
|
69
80
|
function accessRow(row: Row) {
|
|
70
81
|
const targets = row.targetWorkspaces ?? [];
|
|
71
|
-
|
|
82
|
+
const people = peopleOf(row);
|
|
83
|
+
if (!targets.length && !people.length) {
|
|
72
84
|
return {
|
|
73
85
|
icon: "Globe",
|
|
74
86
|
key: en.value ? "Access" : "Accès",
|
|
@@ -76,9 +88,12 @@ function accessRow(row: Row) {
|
|
|
76
88
|
};
|
|
77
89
|
}
|
|
78
90
|
return {
|
|
79
|
-
icon: "Buildings",
|
|
80
|
-
key: `${en.value ? "Access" : "Accès"} (${targets.length})`,
|
|
81
|
-
pills:
|
|
91
|
+
icon: targets.length ? "Buildings" : "UserPlus",
|
|
92
|
+
key: `${en.value ? "Access" : "Accès"} (${targets.length + people.length})`,
|
|
93
|
+
pills: [
|
|
94
|
+
...targets.map((id) => ({ k: en.value ? "Workspace" : "Espace", v: workspaceName(id) })),
|
|
95
|
+
...people.map((person) => ({ k: en.value ? "Person" : "Personne", v: person.name })),
|
|
96
|
+
],
|
|
82
97
|
};
|
|
83
98
|
}
|
|
84
99
|
|
|
@@ -147,7 +162,10 @@ function notify(text: string) {
|
|
|
147
162
|
]);
|
|
148
163
|
}
|
|
149
164
|
|
|
150
|
-
async function update(
|
|
165
|
+
async function update(
|
|
166
|
+
id: string,
|
|
167
|
+
body: { isTemplate?: boolean; targetWorkspaces?: string[]; targetUsers?: string[] },
|
|
168
|
+
) {
|
|
151
169
|
try {
|
|
152
170
|
await elysia.admin.updateViewTemplate(id, body);
|
|
153
171
|
return true;
|
|
@@ -160,6 +178,37 @@ async function update(id: string, body: { isTemplate?: boolean; targetWorkspaces
|
|
|
160
178
|
}
|
|
161
179
|
}
|
|
162
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Personnes trouvees par la recherche du dialogue, sur toute la plateforme :
|
|
183
|
+
* un template vise surtout des gens d'espaces clients. Deux lettres au moins,
|
|
184
|
+
* une requete par pause de frappe, comme le partage depuis « Mes vues ».
|
|
185
|
+
*/
|
|
186
|
+
const people = ref<Person[]>([]);
|
|
187
|
+
let peopleSearch: ReturnType<typeof setTimeout> | null = null;
|
|
188
|
+
|
|
189
|
+
function onPeopleSearch(query: string) {
|
|
190
|
+
if (peopleSearch) clearTimeout(peopleSearch);
|
|
191
|
+
if (query.length < 2) {
|
|
192
|
+
people.value = [];
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
peopleSearch = setTimeout(async () => {
|
|
196
|
+
try {
|
|
197
|
+
const response = await elysia.admin.users({ search: query, limit: 20 });
|
|
198
|
+
people.value = (response.users ?? []).map((user) => ({
|
|
199
|
+
userId: user.userId,
|
|
200
|
+
name:
|
|
201
|
+
user.displayName ||
|
|
202
|
+
[user.firstName, user.lastName].filter(Boolean).join(" ") ||
|
|
203
|
+
user.email,
|
|
204
|
+
email: user.email,
|
|
205
|
+
}));
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.error("[adminTemplates] Recherche de personnes indisponible:", error);
|
|
208
|
+
}
|
|
209
|
+
}, 250);
|
|
210
|
+
}
|
|
211
|
+
|
|
163
212
|
/** Template dont on regle l'acces, ou null. */
|
|
164
213
|
const editingId = ref<string | null>(null);
|
|
165
214
|
const editing = computed(() => rows.value.find((row) => row.id === editingId.value) ?? null);
|
|
@@ -170,12 +219,18 @@ const dialogOpen = computed({
|
|
|
170
219
|
},
|
|
171
220
|
});
|
|
172
221
|
|
|
222
|
+
watch(editingId, () => (people.value = []));
|
|
223
|
+
|
|
173
224
|
/**
|
|
174
225
|
* Le dialogue rend toute la portee ; seuls le drapeau et les espaces comptent
|
|
175
226
|
* ici. Choisir autre chose que « template » revient a le retirer : la
|
|
176
227
|
* visibilite et les destinataires restent l'affaire du proprietaire.
|
|
177
228
|
*/
|
|
178
|
-
async function confirmAccess(share: {
|
|
229
|
+
async function confirmAccess(share: {
|
|
230
|
+
isTemplate?: boolean;
|
|
231
|
+
targetWorkspaces?: string[];
|
|
232
|
+
targetUsers?: string[];
|
|
233
|
+
}) {
|
|
179
234
|
const row = editing.value;
|
|
180
235
|
editingId.value = null;
|
|
181
236
|
if (!row) return;
|
|
@@ -186,12 +241,27 @@ async function confirmAccess(share: { isTemplate?: boolean; targetWorkspaces?: s
|
|
|
186
241
|
return;
|
|
187
242
|
}
|
|
188
243
|
const targets = share.targetWorkspaces ?? [];
|
|
189
|
-
|
|
190
|
-
|
|
244
|
+
const named = share.targetUsers ?? [];
|
|
245
|
+
if (await update(row.id, { targetWorkspaces: targets, targetUsers: named })) {
|
|
246
|
+
const audience = [
|
|
191
247
|
targets.length
|
|
192
248
|
? en.value
|
|
193
|
-
?
|
|
194
|
-
:
|
|
249
|
+
? `${targets.length} workspace${targets.length > 1 ? "s" : ""}`
|
|
250
|
+
: `${targets.length} espace${targets.length > 1 ? "s" : ""}`
|
|
251
|
+
: "",
|
|
252
|
+
named.length
|
|
253
|
+
? en.value
|
|
254
|
+
? `${named.length} ${named.length > 1 ? "people" : "person"}`
|
|
255
|
+
: `${named.length} personne${named.length > 1 ? "s" : ""}`
|
|
256
|
+
: "",
|
|
257
|
+
]
|
|
258
|
+
.filter(Boolean)
|
|
259
|
+
.join(en.value ? " and " : " et ");
|
|
260
|
+
notify(
|
|
261
|
+
audience
|
|
262
|
+
? en.value
|
|
263
|
+
? `Template offered to ${audience}.`
|
|
264
|
+
: `Template proposé à ${audience}.`
|
|
195
265
|
: en.value
|
|
196
266
|
? "Template offered to every workspace."
|
|
197
267
|
: "Template proposé à tous les espaces.",
|
|
@@ -242,12 +312,14 @@ async function onAction(key: string, id: string) {
|
|
|
242
312
|
<RmShareDialog
|
|
243
313
|
v-model="dialogOpen"
|
|
244
314
|
:title="editing?.title ?? ''"
|
|
245
|
-
:members="
|
|
315
|
+
:members="people"
|
|
246
316
|
can-template
|
|
247
317
|
is-template
|
|
248
318
|
:target-workspaces="editing?.targetWorkspaces ?? []"
|
|
319
|
+
:target-users="peopleOf(editing)"
|
|
249
320
|
:workspaces="workspaces"
|
|
250
321
|
:lang="en ? 'en' : 'fr'"
|
|
322
|
+
@search="onPeopleSearch"
|
|
251
323
|
@save="confirmAccess"
|
|
252
324
|
/>
|
|
253
325
|
</div>
|
|
@@ -322,17 +322,32 @@ function notify(text: string) {
|
|
|
322
322
|
function shareOutcome(
|
|
323
323
|
share: { visibility: string; sharedWith: string[]; isTemplate?: boolean },
|
|
324
324
|
targets: number,
|
|
325
|
+
people = 0,
|
|
325
326
|
): string {
|
|
326
327
|
const en = locale.value === "en";
|
|
327
328
|
if (share.isTemplate) {
|
|
328
|
-
if (targets === 0) {
|
|
329
|
+
if (targets === 0 && people === 0) {
|
|
329
330
|
return en
|
|
330
331
|
? "View published as a Tekkare template, offered to every workspace."
|
|
331
332
|
: "Vue publiée comme template Tekkare, offerte à tous les espaces.";
|
|
332
333
|
}
|
|
334
|
+
const audience = [
|
|
335
|
+
targets
|
|
336
|
+
? en
|
|
337
|
+
? `${targets} workspace${targets > 1 ? "s" : ""}`
|
|
338
|
+
: `${targets} espace${targets > 1 ? "s" : ""}`
|
|
339
|
+
: "",
|
|
340
|
+
people
|
|
341
|
+
? en
|
|
342
|
+
? `${people} ${people > 1 ? "people" : "person"}`
|
|
343
|
+
: `${people} personne${people > 1 ? "s" : ""}`
|
|
344
|
+
: "",
|
|
345
|
+
]
|
|
346
|
+
.filter(Boolean)
|
|
347
|
+
.join(en ? " and " : " et ");
|
|
333
348
|
return en
|
|
334
|
-
? `View published as a Tekkare template for ${
|
|
335
|
-
: `Vue publiée comme template Tekkare pour ${
|
|
349
|
+
? `View published as a Tekkare template for ${audience}.`
|
|
350
|
+
: `Vue publiée comme template Tekkare pour ${audience}.`;
|
|
336
351
|
}
|
|
337
352
|
if (share.visibility === "workspace") {
|
|
338
353
|
return en ? "View shared with the whole workspace." : "Vue partagée à tout l'espace.";
|
|
@@ -351,6 +366,7 @@ async function confirmShare(share: {
|
|
|
351
366
|
sharedWith: string[];
|
|
352
367
|
isTemplate?: boolean;
|
|
353
368
|
targetWorkspaces?: string[];
|
|
369
|
+
targetUsers?: string[];
|
|
354
370
|
}) {
|
|
355
371
|
const id = sharingId.value;
|
|
356
372
|
const target = shareTarget.value;
|
|
@@ -365,7 +381,9 @@ async function confirmShare(share: {
|
|
|
365
381
|
});
|
|
366
382
|
|
|
367
383
|
if (ok) {
|
|
368
|
-
notify(
|
|
384
|
+
notify(
|
|
385
|
+
shareOutcome(share, share.targetWorkspaces?.length ?? 0, share.targetUsers?.length ?? 0),
|
|
386
|
+
);
|
|
369
387
|
return;
|
|
370
388
|
}
|
|
371
389
|
|
|
@@ -280,6 +280,8 @@ export function createOipScopes(scopeStore: ReturnType<typeof defineOipScopeStor
|
|
|
280
280
|
*/
|
|
281
281
|
isTemplate?: boolean;
|
|
282
282
|
targetWorkspaces?: string[];
|
|
283
|
+
/** Personnes visees par le template, quel que soit leur espace. */
|
|
284
|
+
targetUsers?: string[];
|
|
283
285
|
templateCriteria?: any;
|
|
284
286
|
},
|
|
285
287
|
) {
|