odant-work 1.0.74 → 1.0.76
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/#system/package-manifest.json +18 -18
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/system.js +26 -4
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/agent.js +511 -73
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/staff.js +851 -435
- package/package.json +1 -1
- package/sources/client/folder.js +2 -0
- package/sources/modules/agent/index.js +1 -1
- package/sources/modules/agent/node-rules.js +403 -20
- package/sources/modules/agent/scheduler.js +135 -4
- package/sources/modules/agent/triggers.js +38 -7
- package/sources/modules/agent/twin-bus.js +66 -5
- package/sources/server/access/gateway.js +2 -0
- package/sources/server/access/links.js +16 -6
- package/sources/server/access/workplaces.js +35 -2
- package/sources/server/class/feed.js +36 -0
- package/sources/server/class/security.js +40 -6
|
@@ -1,343 +1,702 @@
|
|
|
1
|
+
function parseDroppedItem(e) {
|
|
2
|
+
const dt = e?.dataTransfer;
|
|
3
|
+
if (!dt)
|
|
4
|
+
return null;
|
|
5
|
+
const rawJson = dt.getData('data') || dt.getData('application/json') || dt.getData('application/oda.work.shortcut');
|
|
6
|
+
if (rawJson) {
|
|
7
|
+
try {
|
|
8
|
+
const parsed = JSON.parse(rawJson);
|
|
9
|
+
if (parsed && typeof parsed === 'object') {
|
|
10
|
+
const p = String(parsed.path || parsed.short || '').replace(/\/+$/, '');
|
|
11
|
+
return {
|
|
12
|
+
id: parsed.id || p.split('/').pop() || '',
|
|
13
|
+
path: p,
|
|
14
|
+
type: parsed.type || '',
|
|
15
|
+
label: parsed.label || parsed.DATA?.label || parsed.id || p,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch { /* ignore */ }
|
|
20
|
+
}
|
|
21
|
+
const text = String(dt.getData('text/plain') || '').trim().replace(/\/+$/, '');
|
|
22
|
+
if (!text.startsWith('/'))
|
|
23
|
+
return null;
|
|
24
|
+
return { id: text.split('/').pop() || '', path: text, type: '', label: text.split('/').pop() || text };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function isDroppedUser(info) {
|
|
28
|
+
if (!info)
|
|
29
|
+
return false;
|
|
30
|
+
return info.type === '$user' || /^\/users\/[^/]+$/i.test(info.path || '');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isDroppedStructure(info) {
|
|
34
|
+
if (!info)
|
|
35
|
+
return false;
|
|
36
|
+
if (['$structure', '$base', '$project', '$server'].includes(info.type))
|
|
37
|
+
return true;
|
|
38
|
+
return /^\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+(?:\/[^/]+)*$/.test(info.path || '')
|
|
39
|
+
&& !String(info.path || '').includes('/MODULES/');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isDroppedClass(info) {
|
|
43
|
+
if (!info)
|
|
44
|
+
return false;
|
|
45
|
+
if (['$catalog', '$virtual', '$operation', '$register', '$account', '$struct', '$module'].includes(info.type))
|
|
46
|
+
return true;
|
|
47
|
+
return String(info.path || '').includes('/MODULES/');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function splitClassTitle(rawPath, mapEntry) {
|
|
51
|
+
if (mapEntry && typeof mapEntry === 'object')
|
|
52
|
+
return mapEntry;
|
|
53
|
+
const clean = String(rawPath || '')
|
|
54
|
+
.replace(/^\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+\/MODULES\//, '')
|
|
55
|
+
.replace(/^\/MODULES\//, '');
|
|
56
|
+
const parts = clean.split('/').filter(Boolean);
|
|
57
|
+
const title = parts.length ? parts[parts.length - 1] : clean;
|
|
58
|
+
const section = parts.length > 1 ? parts.slice(0, -1).join(' / ') : '';
|
|
59
|
+
return { title, section, icon: 'odant:class' };
|
|
60
|
+
}
|
|
61
|
+
|
|
1
62
|
export default {
|
|
2
|
-
imports: 'oda//icon, oda//button
|
|
63
|
+
imports: 'oda//icon, oda//button',
|
|
3
64
|
template: /*html*/`
|
|
4
65
|
<style>
|
|
5
66
|
:host {
|
|
6
67
|
@apply --vertical;
|
|
7
68
|
@apply --flex;
|
|
8
|
-
padding:
|
|
9
|
-
gap:
|
|
69
|
+
padding: 14px 18px;
|
|
70
|
+
gap: 10px;
|
|
10
71
|
overflow-y: auto;
|
|
11
72
|
background: var(--content-background);
|
|
12
73
|
color: var(--content-color);
|
|
74
|
+
font-size: 13px;
|
|
13
75
|
}
|
|
14
|
-
.
|
|
15
|
-
@apply --vertical;
|
|
16
|
-
gap: 10px;
|
|
17
|
-
padding: 14px 16px;
|
|
18
|
-
border: 1px solid var(--subtle-border);
|
|
19
|
-
border-radius: 8px;
|
|
20
|
-
background: var(--subtle-background);
|
|
21
|
-
}
|
|
22
|
-
.place-card {
|
|
76
|
+
.tree-box {
|
|
23
77
|
@apply --vertical;
|
|
24
|
-
gap: 10px;
|
|
25
|
-
padding: 12px 14px;
|
|
26
78
|
border: 1px solid var(--subtle-border);
|
|
27
|
-
border-radius:
|
|
79
|
+
border-radius: 10px;
|
|
28
80
|
background: var(--content-background);
|
|
81
|
+
overflow: hidden;
|
|
29
82
|
}
|
|
30
|
-
.
|
|
31
|
-
border-color: var(--accent-color);
|
|
32
|
-
box-shadow: 0 0 0 2px var(--accent-soft);
|
|
33
|
-
}
|
|
34
|
-
.card-header {
|
|
83
|
+
.root-row {
|
|
35
84
|
@apply --horizontal;
|
|
36
85
|
align-items: center;
|
|
37
86
|
gap: 8px;
|
|
87
|
+
padding: 10px 14px;
|
|
88
|
+
background: var(--subtle-background);
|
|
89
|
+
border-bottom: 1px solid var(--subtle-border);
|
|
90
|
+
flex-wrap: wrap;
|
|
91
|
+
transition: background .15s;
|
|
92
|
+
}
|
|
93
|
+
.root-row.drop-hover, .tree-row.drop-hover {
|
|
94
|
+
background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background));
|
|
95
|
+
outline: 1px dashed var(--accent-color, #2563eb);
|
|
96
|
+
outline-offset: -2px;
|
|
97
|
+
}
|
|
98
|
+
.root-title {
|
|
38
99
|
font-weight: 700;
|
|
39
|
-
font-size:
|
|
100
|
+
font-size: 14px;
|
|
101
|
+
margin-right: 4px;
|
|
40
102
|
}
|
|
41
|
-
.
|
|
103
|
+
.boss-label {
|
|
104
|
+
font-size: 12px;
|
|
105
|
+
color: var(--muted-color);
|
|
106
|
+
}
|
|
107
|
+
.tree-row {
|
|
42
108
|
@apply --horizontal;
|
|
43
109
|
align-items: center;
|
|
110
|
+
gap: 6px;
|
|
111
|
+
padding: 6px 12px;
|
|
112
|
+
min-height: 34px;
|
|
113
|
+
border-bottom: 1px solid color-mix(in srgb, var(--subtle-border) 55%, transparent);
|
|
44
114
|
flex-wrap: wrap;
|
|
45
|
-
gap: 8px;
|
|
46
115
|
}
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
116
|
+
.tree-row:last-child {
|
|
117
|
+
border-bottom: none;
|
|
118
|
+
}
|
|
119
|
+
.tree-row.role-row {
|
|
120
|
+
background: var(--content-background);
|
|
121
|
+
}
|
|
122
|
+
.tree-row.role-row:hover {
|
|
123
|
+
background: color-mix(in srgb, var(--subtle-background) 65%, transparent);
|
|
124
|
+
}
|
|
125
|
+
.tree-row.class-row {
|
|
126
|
+
min-height: 30px;
|
|
127
|
+
padding-top: 4px;
|
|
128
|
+
padding-bottom: 4px;
|
|
129
|
+
background: color-mix(in srgb, var(--subtle-background) 35%, var(--content-background));
|
|
130
|
+
}
|
|
131
|
+
.tree-row.class-row:hover {
|
|
132
|
+
background: var(--subtle-background);
|
|
133
|
+
}
|
|
134
|
+
.expander {
|
|
135
|
+
width: 18px;
|
|
136
|
+
height: 18px;
|
|
137
|
+
display: inline-flex;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
cursor: pointer;
|
|
50
141
|
color: var(--muted-color);
|
|
142
|
+
user-select: none;
|
|
143
|
+
border-radius: 4px;
|
|
144
|
+
}
|
|
145
|
+
.expander:hover {
|
|
146
|
+
background: var(--subtle-background);
|
|
147
|
+
color: var(--content-color);
|
|
148
|
+
}
|
|
149
|
+
.role-name {
|
|
150
|
+
font-weight: 600;
|
|
151
|
+
font-size: 13.5px;
|
|
152
|
+
}
|
|
153
|
+
.members-wrap {
|
|
154
|
+
@apply --horizontal;
|
|
155
|
+
align-items: center;
|
|
156
|
+
gap: 5px;
|
|
157
|
+
flex-wrap: wrap;
|
|
158
|
+
flex: 1;
|
|
51
159
|
min-width: 140px;
|
|
52
160
|
}
|
|
53
|
-
.
|
|
161
|
+
.chip {
|
|
54
162
|
@apply --horizontal;
|
|
55
163
|
align-items: center;
|
|
56
|
-
gap:
|
|
57
|
-
padding:
|
|
164
|
+
gap: 5px;
|
|
165
|
+
padding: 2px 8px 2px 4px;
|
|
58
166
|
border-radius: 14px;
|
|
59
167
|
background: var(--accent-soft);
|
|
60
168
|
color: var(--content-color);
|
|
61
|
-
font-size:
|
|
62
|
-
}
|
|
63
|
-
.user-chip.clickable {
|
|
169
|
+
font-size: 12.5px;
|
|
64
170
|
cursor: pointer;
|
|
65
171
|
}
|
|
66
|
-
.
|
|
172
|
+
.chip.inherited {
|
|
173
|
+
opacity: .75;
|
|
174
|
+
}
|
|
175
|
+
.chip.node-chip {
|
|
176
|
+
background: color-mix(in srgb, #0284c7 13%, var(--content-background));
|
|
177
|
+
border: 1px solid color-mix(in srgb, #0284c7 28%, transparent);
|
|
178
|
+
}
|
|
179
|
+
.chip:hover {
|
|
67
180
|
filter: brightness(0.95);
|
|
68
181
|
}
|
|
182
|
+
.chip .rm {
|
|
183
|
+
font-weight: 700;
|
|
184
|
+
opacity: .6;
|
|
185
|
+
padding: 0 2px;
|
|
186
|
+
cursor: pointer;
|
|
187
|
+
}
|
|
188
|
+
.chip .rm:hover {
|
|
189
|
+
opacity: 1;
|
|
190
|
+
color: var(--error-color, #dc2626);
|
|
191
|
+
}
|
|
69
192
|
.badge {
|
|
70
193
|
font-size: 11px;
|
|
71
194
|
font-weight: 600;
|
|
72
|
-
padding:
|
|
73
|
-
border-radius:
|
|
195
|
+
padding: 1px 6px;
|
|
196
|
+
border-radius: 8px;
|
|
74
197
|
background: var(--accent-soft);
|
|
75
198
|
color: var(--accent-color);
|
|
76
199
|
}
|
|
77
|
-
.badge.
|
|
200
|
+
.badge.ext {
|
|
78
201
|
background: light-dark(#fef3c7, #422006);
|
|
79
202
|
color: light-dark(#92400e, #fcd34d);
|
|
80
203
|
}
|
|
81
|
-
.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
gap: 5px;
|
|
85
|
-
font-size: 12px;
|
|
204
|
+
.icon-btn {
|
|
205
|
+
border: 1px solid transparent;
|
|
206
|
+
background: transparent;
|
|
86
207
|
color: var(--muted-color);
|
|
208
|
+
border-radius: 6px;
|
|
209
|
+
padding: 3px 7px;
|
|
210
|
+
font: inherit;
|
|
211
|
+
font-size: 12px;
|
|
87
212
|
cursor: pointer;
|
|
88
|
-
|
|
213
|
+
display: inline-flex;
|
|
214
|
+
align-items: center;
|
|
215
|
+
gap: 4px;
|
|
89
216
|
}
|
|
90
|
-
.
|
|
91
|
-
|
|
217
|
+
.icon-btn:hover {
|
|
218
|
+
background: var(--subtle-background);
|
|
219
|
+
border-color: var(--subtle-border);
|
|
220
|
+
color: var(--content-color);
|
|
221
|
+
}
|
|
222
|
+
.icon-btn.active {
|
|
223
|
+
background: var(--accent-soft);
|
|
224
|
+
color: var(--accent-color);
|
|
225
|
+
border-color: color-mix(in srgb, var(--accent-color) 35%, transparent);
|
|
226
|
+
}
|
|
227
|
+
.icon-btn.danger:hover {
|
|
228
|
+
color: var(--error-color, #dc2626);
|
|
229
|
+
}
|
|
230
|
+
.row-actions {
|
|
231
|
+
@apply --horizontal;
|
|
232
|
+
align-items: center;
|
|
233
|
+
gap: 2px;
|
|
234
|
+
margin-left: auto;
|
|
235
|
+
}
|
|
236
|
+
.class-title {
|
|
92
237
|
font-weight: 500;
|
|
93
238
|
cursor: pointer;
|
|
94
239
|
}
|
|
95
|
-
.
|
|
240
|
+
.class-title:hover {
|
|
96
241
|
color: var(--accent-color);
|
|
97
242
|
text-decoration: underline;
|
|
98
243
|
}
|
|
99
|
-
.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
opacity: .65;
|
|
103
|
-
padding: 0 2px;
|
|
244
|
+
.class-section {
|
|
245
|
+
font-size: 11.5px;
|
|
246
|
+
color: var(--muted-color);
|
|
104
247
|
}
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
|
|
248
|
+
.write-check {
|
|
249
|
+
@apply --horizontal;
|
|
250
|
+
align-items: center;
|
|
251
|
+
gap: 5px;
|
|
252
|
+
font-size: 12.5px;
|
|
253
|
+
cursor: pointer;
|
|
254
|
+
user-select: none;
|
|
255
|
+
margin-left: auto;
|
|
256
|
+
padding-right: 6px;
|
|
108
257
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
background: var(--control-background);
|
|
116
|
-
color: var(--control-color);
|
|
258
|
+
.inline-panel {
|
|
259
|
+
@apply --vertical;
|
|
260
|
+
gap: 8px;
|
|
261
|
+
padding: 10px 14px;
|
|
262
|
+
background: var(--subtle-background);
|
|
263
|
+
border-bottom: 1px solid var(--subtle-border);
|
|
117
264
|
}
|
|
118
|
-
.
|
|
265
|
+
.panel-list {
|
|
119
266
|
@apply --vertical;
|
|
120
|
-
gap:
|
|
121
|
-
|
|
122
|
-
|
|
267
|
+
gap: 2px;
|
|
268
|
+
max-height: 220px;
|
|
269
|
+
overflow-y: auto;
|
|
270
|
+
border: 1px solid var(--subtle-border);
|
|
271
|
+
border-radius: 6px;
|
|
272
|
+
padding: 4px;
|
|
273
|
+
background: var(--content-background);
|
|
123
274
|
}
|
|
124
|
-
.
|
|
275
|
+
.panel-item {
|
|
125
276
|
@apply --horizontal;
|
|
126
277
|
align-items: center;
|
|
127
278
|
gap: 8px;
|
|
279
|
+
padding: 5px 8px;
|
|
280
|
+
border-radius: 5px;
|
|
281
|
+
cursor: pointer;
|
|
128
282
|
font-size: 13px;
|
|
129
|
-
|
|
283
|
+
}
|
|
284
|
+
.panel-item:hover {
|
|
130
285
|
background: var(--subtle-background);
|
|
286
|
+
}
|
|
287
|
+
input[type="text"] {
|
|
288
|
+
padding: 5px 8px;
|
|
289
|
+
border: 1px solid var(--control-border-color, var(--subtle-border));
|
|
131
290
|
border-radius: 6px;
|
|
291
|
+
font: inherit;
|
|
292
|
+
font-size: 13px;
|
|
293
|
+
background: var(--content-background);
|
|
294
|
+
color: var(--control-color, inherit);
|
|
132
295
|
}
|
|
133
296
|
.muted {
|
|
134
297
|
color: var(--muted-color);
|
|
135
|
-
font-size:
|
|
298
|
+
font-size: 12px;
|
|
136
299
|
}
|
|
137
300
|
</style>
|
|
138
301
|
|
|
139
|
-
<div class="
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
302
|
+
<div class="tree-box">
|
|
303
|
+
<!-- Корень дерева: BOSS подразделения -->
|
|
304
|
+
<div class="root-row" ~class="{ 'drop-hover': bossDropHover }"
|
|
305
|
+
@dragover="onBossDragOver" @dragleave="bossDropHover = false" @drop="onBossDrop">
|
|
306
|
+
<oda-icon :icon="$item?.icon || 'odant:structure'" icon-size="20"></oda-icon>
|
|
307
|
+
<span class="root-title">{{$item?.label || $item?.id}}</span>
|
|
308
|
+
<span class="boss-label">Руководитель (BOSS):</span>
|
|
309
|
+
|
|
310
|
+
<div ~if="visibleCurrentBoss" class="chip" title="Открыть профиль" @tap="openUser(visibleCurrentBoss)">
|
|
311
|
+
<oda-icon round :icon="userIcon(visibleCurrentBoss)" :icon-color="userColor(visibleCurrentBoss)" icon-size="18"></oda-icon>
|
|
312
|
+
<span>{{userLabel(visibleCurrentBoss)}}</span>
|
|
313
|
+
<span ~if="canEdit" class="rm" title="Снять локального руководителя" @tap.stop="clearBoss()">×</span>
|
|
314
|
+
</div>
|
|
315
|
+
|
|
316
|
+
<div ~if="!visibleCurrentBoss && visibleInheritedBoss" class="chip inherited" title="Наследуется сверху" @tap="openUser(visibleInheritedBoss)">
|
|
317
|
+
<oda-icon round :icon="userIcon(visibleInheritedBoss)" :icon-color="userColor(visibleInheritedBoss)" icon-size="18"></oda-icon>
|
|
318
|
+
<span>{{userLabel(visibleInheritedBoss)}}</span>
|
|
319
|
+
<span class="muted">({{inheritedBossInfo.fromLabel}})</span>
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
<span ~if="!visibleCurrentBoss && !visibleInheritedBoss" class="muted">не назначен</span>
|
|
323
|
+
|
|
324
|
+
<div ~if="canEdit" class="row-actions">
|
|
325
|
+
<button type="button" class="icon-btn" @tap="toggleBossPicker()">
|
|
326
|
+
<oda-icon icon="editor:mode-edit" icon-size="14"></oda-icon>
|
|
327
|
+
<span>{{visibleCurrentBoss ? 'Сменить' : 'Назначить'}}</span>
|
|
328
|
+
</button>
|
|
329
|
+
<button type="button" class="icon-btn" @tap="openAddRole('')">
|
|
330
|
+
<oda-icon icon="icons:add" icon-size="15"></oda-icon>
|
|
331
|
+
<span>Роль</span>
|
|
332
|
+
</button>
|
|
333
|
+
</div>
|
|
143
334
|
</div>
|
|
144
335
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
<div class="
|
|
148
|
-
<
|
|
149
|
-
<
|
|
150
|
-
<
|
|
336
|
+
<!-- Выбор руководителя -->
|
|
337
|
+
<div ~if="canEdit && bossPickerOpen" class="inline-panel">
|
|
338
|
+
<div class="horizontal" style="gap:8px;align-items:center;">
|
|
339
|
+
<input type="text" placeholder="Поиск сотрудника…" ::value="bossSearch" style="flex:1;">
|
|
340
|
+
<oda-button ~if="currentBoss" @tap="clearBoss()">Наследовать сверху</oda-button>
|
|
341
|
+
<oda-button icon="icons:close" @tap="bossPickerOpen = false">Закрыть</oda-button>
|
|
151
342
|
</div>
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
343
|
+
<div class="panel-list">
|
|
344
|
+
<div ~if="!filteredBossUsers.length" class="muted" style="padding:6px;">Пользователи не найдены</div>
|
|
345
|
+
<div class="panel-item" ~for="filteredBossUsers" @tap="pickBoss($for.item.id)">
|
|
346
|
+
<oda-icon round :icon="userIcon($for.item.id)" :icon-color="userColor($for.item.id)" icon-size="18"></oda-icon>
|
|
347
|
+
<span>{{$for.item.label}}</span>
|
|
348
|
+
</div>
|
|
157
349
|
</div>
|
|
158
|
-
<select ~if="canEdit" @change="addRoleUser('BOSS', $event)">
|
|
159
|
-
<option value="">+ Назначить руководителя…</option>
|
|
160
|
-
<option ~for="allUsers" :value="$for.item.id">{{$for.item.label}} ({{$for.item.id}})</option>
|
|
161
|
-
</select>
|
|
162
350
|
</div>
|
|
163
|
-
</div>
|
|
164
351
|
|
|
165
|
-
|
|
166
|
-
<div class="
|
|
167
|
-
<
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
<
|
|
171
|
-
<input type="checkbox" :checked="newPlaceExternal" @change="newPlaceExternal = $event.target.checked">
|
|
172
|
-
<span>Клиент</span>
|
|
173
|
-
</label>
|
|
174
|
-
<input type="text" placeholder="Название нового рабочего места…" :value="newPlaceLabel" @input="newPlaceLabel = $event.target.value" style="width:220px;">
|
|
175
|
-
<oda-button icon="icons:add" @tap="addPlace('')">Добавить место</oda-button>
|
|
352
|
+
<!-- Добавление корневой роли -->
|
|
353
|
+
<div ~if="canEdit && addingRoleParent === ''" class="inline-panel">
|
|
354
|
+
<div class="horizontal" style="gap:8px;align-items:center;">
|
|
355
|
+
<input type="text" placeholder="Название новой роли…" ::value="newRoleLabel" style="flex:1;" @keydown="onNewRoleKey($event)">
|
|
356
|
+
<oda-button icon="icons:check" info-invert @tap="confirmAddRole()">Добавить</oda-button>
|
|
357
|
+
<oda-button icon="icons:close" @tap="cancelAddRole()">Отмена</oda-button>
|
|
176
358
|
</div>
|
|
177
359
|
</div>
|
|
178
360
|
|
|
179
|
-
<div ~if="!
|
|
361
|
+
<div ~if="!treeRows.length" class="muted" style="padding:16px;">Ролей пока нет</div>
|
|
362
|
+
|
|
363
|
+
<!-- Единое дерево ролей и классов -->
|
|
364
|
+
<div ~for="treeRows" style="display:contents;">
|
|
365
|
+
<!-- Строка роли -->
|
|
366
|
+
<div ~if="$for.item.kind === 'role'" class="tree-row role-row"
|
|
367
|
+
~class="{ 'drop-hover': dropHoverTrail === $for.item.trail }"
|
|
368
|
+
:style="'padding-left:' + (12 + $for.item.depth * 24) + 'px'"
|
|
369
|
+
@dragover="onRoleDragOver($event, $for.item.trail)"
|
|
370
|
+
@dragleave="onRoleDragLeave($for.item.trail)"
|
|
371
|
+
@drop="onRoleDrop($event, $for.item.trail)">
|
|
180
372
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
<
|
|
185
|
-
<span class="
|
|
186
|
-
<span ~if="$for.item.
|
|
187
|
-
<span ~if="$for.item.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
373
|
+
<span class="expander" @tap="toggleRoleExpand($for.item.trail)">
|
|
374
|
+
{{$for.item.hasChildren ? ($for.item.expanded ? '▾' : '▸') : ''}}
|
|
375
|
+
</span>
|
|
376
|
+
<oda-icon :icon="$for.item.external ? 'icons:public' : 'fontawesome:s-user-tie'" icon-size="16"></oda-icon>
|
|
377
|
+
<span class="role-name">{{$for.item.label}}</span>
|
|
378
|
+
<span ~if="$for.item.external" class="badge ext">клиент</span>
|
|
379
|
+
<span ~if="$for.item.mine" class="badge">ваша роль</span>
|
|
380
|
+
|
|
381
|
+
<div class="members-wrap">
|
|
382
|
+
<div class="chip" ~for="$for.item.memberEntries"
|
|
383
|
+
~class="{ 'node-chip': $for.$for.item.isNode }"
|
|
384
|
+
@tap="openMember($for.$for.item)">
|
|
385
|
+
<oda-icon :round="!$for.$for.item.isNode && !$for.$for.item.isGroup" :icon="$for.$for.item.icon" :icon-color="$for.$for.item.iconColor" icon-size="16"></oda-icon>
|
|
386
|
+
<span>{{$for.$for.item.label}}</span>
|
|
387
|
+
<span ~if="canEdit" class="rm" title="Убрать из роли" @tap.stop="removeRoleMember($for.item.trail, $for.$for.item.id)">×</span>
|
|
388
|
+
</div>
|
|
389
|
+
<button ~if="canEdit" type="button" class="icon-btn" title="Добавить участника (человека или подразделение)" @tap="toggleMemberPicker($for.item.trail)">
|
|
390
|
+
<oda-icon icon="icons:add" icon-size="14"></oda-icon>
|
|
391
|
+
</button>
|
|
196
392
|
</div>
|
|
197
|
-
</div>
|
|
198
393
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
<
|
|
206
|
-
<
|
|
207
|
-
</
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
<
|
|
212
|
-
|
|
394
|
+
<div ~if="canEdit" class="row-actions">
|
|
395
|
+
<button type="button" class="icon-btn" title="Привязать классы" @tap="toggleClassPicker($for.item.trail)">
|
|
396
|
+
<oda-icon icon="icons:add" icon-size="14"></oda-icon>
|
|
397
|
+
<span>Класс</span>
|
|
398
|
+
</button>
|
|
399
|
+
<button type="button" class="icon-btn" title="Добавить дочернюю роль" @tap="openAddRole($for.item.trail)">
|
|
400
|
+
<oda-icon icon="icons:add" icon-size="14"></oda-icon>
|
|
401
|
+
<span>Подроль</span>
|
|
402
|
+
</button>
|
|
403
|
+
<button type="button" class="icon-btn" ~class="{ active: $for.item.external }" title="Режим внешнего клиента (CLIENT)" @tap="toggleRoleExternal($for.item.trail, !$for.item.external)">
|
|
404
|
+
<oda-icon icon="icons:public" icon-size="14"></oda-icon>
|
|
405
|
+
</button>
|
|
406
|
+
<button type="button" class="icon-btn danger" title="Удалить роль" @tap="removeRole($for.item.trail)">
|
|
407
|
+
<oda-icon icon="icons:delete" icon-size="14"></oda-icon>
|
|
408
|
+
</button>
|
|
213
409
|
</div>
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
410
|
+
</div>
|
|
411
|
+
|
|
412
|
+
<!-- Инлайн-добавление дочерней роли -->
|
|
413
|
+
<div ~if="$for.item.kind === 'role' && canEdit && addingRoleParent === $for.item.trail"
|
|
414
|
+
class="inline-panel" :style="'padding-left:' + (36 + $for.item.depth * 24) + 'px'">
|
|
415
|
+
<div class="horizontal" style="gap:8px;align-items:center;">
|
|
416
|
+
<input type="text" placeholder="Название дочерней роли…" ::value="newRoleLabel" style="flex:1;" @keydown="onNewRoleKey($event)">
|
|
417
|
+
<oda-button icon="icons:check" info-invert @tap="confirmAddRole()">Добавить</oda-button>
|
|
418
|
+
<oda-button icon="icons:close" @tap="cancelAddRole()">Отмена</oda-button>
|
|
220
419
|
</div>
|
|
221
420
|
</div>
|
|
222
421
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
<
|
|
228
|
-
<
|
|
422
|
+
<!-- Инлайн-выбор участника (сотрудники / подразделения) -->
|
|
423
|
+
<div ~if="$for.item.kind === 'role' && canEdit && memberPickerTrail === $for.item.trail"
|
|
424
|
+
class="inline-panel" :style="'padding-left:' + (36 + $for.item.depth * 24) + 'px'">
|
|
425
|
+
<div class="horizontal" style="gap:8px;align-items:center;">
|
|
426
|
+
<input type="text" placeholder="Поиск человека или подразделения…" ::value="memberSearch" style="flex:1;">
|
|
427
|
+
<oda-button icon="icons:close" @tap="closeMemberPicker()">Закрыть</oda-button>
|
|
428
|
+
</div>
|
|
429
|
+
<div class="panel-list">
|
|
430
|
+
<div class="panel-item" ~for="filteredUsers" @tap="pickMember($for.item.trail, $for.$for.item.id)">
|
|
431
|
+
<oda-icon round :icon="userIcon($for.$for.item.id)" :icon-color="userColor($for.$for.item.id)" icon-size="18"></oda-icon>
|
|
432
|
+
<span>{{$for.$for.item.label}}</span>
|
|
433
|
+
</div>
|
|
434
|
+
<div class="panel-item" ~for="filteredStructures" @tap="pickMember($for.item.trail, $for.$for.item.path)">
|
|
435
|
+
<oda-icon :icon="$for.$for.item.icon || 'odant:structure'" icon-size="18"></oda-icon>
|
|
436
|
+
<span>{{$for.$for.item.label}}</span>
|
|
437
|
+
<span class="muted">подразделение</span>
|
|
438
|
+
</div>
|
|
439
|
+
<div class="panel-item" @tap="pickMember($for.item.trail, 'USERS')">
|
|
440
|
+
<oda-icon icon="social:people" icon-size="18"></oda-icon>
|
|
441
|
+
<span>Все сотрудники</span>
|
|
442
|
+
</div>
|
|
443
|
+
<div class="panel-item" @tap="pickMember($for.item.trail, 'GUESTS')">
|
|
444
|
+
<oda-icon icon="icons:public" icon-size="18"></oda-icon>
|
|
445
|
+
<span>Все гости</span>
|
|
446
|
+
</div>
|
|
229
447
|
</div>
|
|
230
|
-
<span ~if="!$for.item.users.length" class="muted">сотрудники не назначены</span>
|
|
231
|
-
<select ~if="canEdit" @change="addPlaceUser($for.item.trail, $event)">
|
|
232
|
-
<option value="">+ Назначить сотрудника…</option>
|
|
233
|
-
<option value="USERS">👥 Все пользователи (USERS)</option>
|
|
234
|
-
<option value="GUESTS">🌐 Все гости (GUESTS)</option>
|
|
235
|
-
<option ~for="allUsers" :value="$for.$for.item.id">{{$for.$for.item.label}} ({{$for.$for.item.id}})</option>
|
|
236
|
-
</select>
|
|
237
448
|
</div>
|
|
238
449
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
450
|
+
<!-- Инлайн-дерево выбора классов -->
|
|
451
|
+
<div ~if="$for.item.kind === 'role' && canEdit && pickerTrail === $for.item.trail"
|
|
452
|
+
class="inline-panel" :style="'padding-left:' + (36 + $for.item.depth * 24) + 'px'">
|
|
453
|
+
<div class="horizontal" style="gap:8px;align-items:center;">
|
|
454
|
+
<input type="text" placeholder="Поиск класса…" ::value="classSearch" style="flex:1;">
|
|
455
|
+
<oda-button icon="icons:check" info-invert :disabled="!selectedPickerCount" @tap="applyClassPicker($for.item.trail)">
|
|
456
|
+
Добавить ({{selectedPickerCount}})
|
|
457
|
+
</oda-button>
|
|
458
|
+
<oda-button icon="icons:close" @tap="closeClassPicker()">Закрыть</oda-button>
|
|
246
459
|
</div>
|
|
247
|
-
<div class="
|
|
248
|
-
<
|
|
249
|
-
<
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
<
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
<option value="unit" :selected="$for.$for.item.scope === 'unit'">Подразделение (unit)</option>
|
|
259
|
-
<option value="all" :selected="$for.$for.item.scope === 'all'">Все (all)</option>
|
|
260
|
-
</select>
|
|
261
|
-
<span ~if="canEdit" style="cursor:pointer;color:#b91c1c;font-weight:bold;padding:0 4px;" title="Отвязать класс" @tap="removePlaceLink($for.item.trail, $for.$for.item.id)">×</span>
|
|
460
|
+
<div class="panel-list">
|
|
461
|
+
<div ~if="!visibleClassNodes.length" class="muted" style="padding:6px;">Классы не найдены</div>
|
|
462
|
+
<div class="panel-item" ~for="visibleClassNodes" :style="'padding-left:' + (6 + $for.$for.item.depth * 18) + 'px'">
|
|
463
|
+
<span ~if="$for.$for.item.hasChildren" style="width:14px;text-align:center;font-weight:700;" @tap.stop="toggleClassExpand($for.$for.item.path)">
|
|
464
|
+
{{$for.$for.item.expanded ? '▾' : '▸'}}
|
|
465
|
+
</span>
|
|
466
|
+
<span ~if="!$for.$for.item.hasChildren" style="width:14px;"></span>
|
|
467
|
+
<input ~if="$for.$for.item.selectable" type="checkbox" :checked="$for.$for.item.checked" @change="togglePickerCheck($for.$for.item.path, $event.target.checked)">
|
|
468
|
+
<oda-icon :icon="$for.$for.item.icon" icon-size="16"></oda-icon>
|
|
469
|
+
<span style="flex:1;" @tap="onPickerLabelTap($for.$for.item)">{{$for.$for.item.label}}</span>
|
|
470
|
+
</div>
|
|
262
471
|
</div>
|
|
263
472
|
</div>
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
<
|
|
473
|
+
|
|
474
|
+
<!-- Строка привязанного класса внутри роли -->
|
|
475
|
+
<div ~if="$for.item.kind === 'class'" class="tree-row class-row"
|
|
476
|
+
:style="'padding-left:' + (28 + $for.item.depth * 24) + 'px'">
|
|
477
|
+
<oda-icon :icon="$for.item.icon" icon-size="15"></oda-icon>
|
|
478
|
+
<span class="class-title" :title="$for.item.id" @tap="openClass($for.item.id)">{{$for.item.title}}</span>
|
|
479
|
+
<span ~if="$for.item.section" class="class-section">{{$for.item.section}}</span>
|
|
480
|
+
<label class="write-check" title="Разрешить создание и изменение записей">
|
|
481
|
+
<input type="checkbox" :checked="$for.item.isWrite" :disabled="!canEdit"
|
|
482
|
+
@change="updateRoleLinkAccess($for.item.trail, $for.item.id, $event.target.checked ? 'write' : 'read')">
|
|
483
|
+
<span>Изменение</span>
|
|
484
|
+
</label>
|
|
485
|
+
<button ~if="canEdit" type="button" class="icon-btn danger" title="Отвязать класс" @tap="removeRoleLink($for.item.trail, $for.item.id)">×</button>
|
|
277
486
|
</div>
|
|
278
487
|
</div>
|
|
279
488
|
</div>
|
|
280
|
-
|
|
281
|
-
<div ~if="error" style="color:var(--error-color, #
|
|
489
|
+
|
|
490
|
+
<div ~if="error" style="color:var(--error-color, #dc2626);font-size:12.5px;">{{error}}</div>
|
|
282
491
|
`,
|
|
492
|
+
$item: {
|
|
493
|
+
$def: null,
|
|
494
|
+
set(n) {
|
|
495
|
+
if (n)
|
|
496
|
+
this.reload();
|
|
497
|
+
}
|
|
498
|
+
},
|
|
283
499
|
security: null,
|
|
284
500
|
allUsers: [],
|
|
285
501
|
userMap: {},
|
|
286
502
|
userMetaMap: {},
|
|
503
|
+
availableStructures: [],
|
|
504
|
+
structureMap: {},
|
|
287
505
|
inheritedBossInfo: null,
|
|
288
|
-
|
|
506
|
+
classTreeRoots: [],
|
|
289
507
|
classMap: {},
|
|
290
508
|
canEdit: false,
|
|
291
509
|
focusedTrail: '',
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
510
|
+
expandedRoles: {},
|
|
511
|
+
bossPickerOpen: false,
|
|
512
|
+
bossSearch: '',
|
|
513
|
+
addingRoleParent: null,
|
|
514
|
+
newRoleLabel: '',
|
|
515
|
+
memberPickerTrail: '',
|
|
516
|
+
memberSearch: '',
|
|
517
|
+
pickerTrail: '',
|
|
518
|
+
classSearch: '',
|
|
519
|
+
expandedClassPaths: {},
|
|
520
|
+
pickerChecked: {},
|
|
521
|
+
bossDropHover: false,
|
|
522
|
+
dropHoverTrail: '',
|
|
301
523
|
error: '',
|
|
302
524
|
async attached() {
|
|
303
|
-
|
|
525
|
+
if (this.$item)
|
|
526
|
+
await this.reload();
|
|
304
527
|
},
|
|
305
528
|
async applyNav(nav = {}) {
|
|
306
529
|
if (nav.place)
|
|
307
530
|
this.focusedTrail = String(nav.place);
|
|
308
531
|
await this.reload();
|
|
309
532
|
},
|
|
310
|
-
get
|
|
311
|
-
|
|
533
|
+
get currentBoss() {
|
|
534
|
+
const list = Array.isArray(this.security?.BOSS) ? this.security.BOSS : [];
|
|
535
|
+
return list[0] || '';
|
|
312
536
|
},
|
|
313
|
-
get
|
|
314
|
-
const
|
|
537
|
+
get visibleCurrentBoss() {
|
|
538
|
+
const id = this.currentBoss;
|
|
539
|
+
if (!id)
|
|
540
|
+
return '';
|
|
541
|
+
return this.userMap?.[id] ? id : '';
|
|
542
|
+
},
|
|
543
|
+
get visibleInheritedBoss() {
|
|
544
|
+
const id = this.inheritedBossInfo?.users?.[0] || '';
|
|
545
|
+
if (!id)
|
|
546
|
+
return '';
|
|
547
|
+
return this.userMap?.[id] ? id : '';
|
|
548
|
+
},
|
|
549
|
+
get filteredBossUsers() {
|
|
550
|
+
const q = String(this.bossSearch || '').trim().toLowerCase();
|
|
551
|
+
return (this.allUsers || []).filter(u =>
|
|
552
|
+
!q || u.label.toLowerCase().includes(q)
|
|
553
|
+
);
|
|
554
|
+
},
|
|
555
|
+
get filteredUsers() {
|
|
556
|
+
const q = String(this.memberSearch || '').trim().toLowerCase();
|
|
557
|
+
if (!q)
|
|
558
|
+
return this.allUsers || [];
|
|
559
|
+
return (this.allUsers || []).filter(u => u.label.toLowerCase().includes(q));
|
|
560
|
+
},
|
|
561
|
+
get filteredStructures() {
|
|
562
|
+
const q = String(this.memberSearch || '').trim().toLowerCase();
|
|
563
|
+
if (!q)
|
|
564
|
+
return this.availableStructures || [];
|
|
565
|
+
return (this.availableStructures || []).filter(s => String(s.label || '').toLowerCase().includes(q));
|
|
566
|
+
},
|
|
567
|
+
get treeRows() {
|
|
568
|
+
const rows = [];
|
|
315
569
|
const walk = (roles, prefix = '', depth = 0) => {
|
|
316
570
|
for (const r of Array.isArray(roles) ? roles : []) {
|
|
317
571
|
if (!r?.id)
|
|
318
572
|
continue;
|
|
319
573
|
const trail = prefix ? `${prefix}/${r.id}` : r.id;
|
|
320
|
-
|
|
574
|
+
const links = Array.isArray(r.LINKS) ? r.LINKS : [];
|
|
575
|
+
const childRoles = Array.isArray(r.ROLES) ? r.ROLES : [];
|
|
576
|
+
const hasChildren = links.length > 0 || childRoles.length > 0;
|
|
577
|
+
const expanded = this.expandedRoles?.[trail] !== false;
|
|
578
|
+
|
|
579
|
+
const memberEntries = [];
|
|
580
|
+
for (const id of Array.isArray(r.USERS) ? r.USERS : []) {
|
|
581
|
+
if (typeof id === 'string' && id.startsWith('/')) {
|
|
582
|
+
const st = this.structureMap?.[id];
|
|
583
|
+
if (!st && !Object.keys(this.structureMap || {}).length) {
|
|
584
|
+
memberEntries.push({
|
|
585
|
+
id,
|
|
586
|
+
isNode: true,
|
|
587
|
+
isGroup: false,
|
|
588
|
+
label: id.split('/').pop() || id,
|
|
589
|
+
icon: 'odant:structure',
|
|
590
|
+
iconColor: '',
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
else if (st) {
|
|
594
|
+
memberEntries.push({
|
|
595
|
+
id,
|
|
596
|
+
isNode: true,
|
|
597
|
+
isGroup: false,
|
|
598
|
+
label: st.label || id.split('/').pop() || id,
|
|
599
|
+
icon: st.icon || 'odant:structure',
|
|
600
|
+
iconColor: '',
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
else if (id === 'USERS' || id === 'GUESTS' || id === 'GUEST') {
|
|
605
|
+
memberEntries.push({
|
|
606
|
+
id,
|
|
607
|
+
isNode: false,
|
|
608
|
+
isGroup: true,
|
|
609
|
+
label: id === 'USERS' ? 'Все сотрудники' : 'Все гости',
|
|
610
|
+
icon: id === 'USERS' ? 'social:people' : 'icons:public',
|
|
611
|
+
iconColor: '',
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
else if (this.userMap?.[id]) {
|
|
615
|
+
memberEntries.push({
|
|
616
|
+
id,
|
|
617
|
+
isNode: false,
|
|
618
|
+
isGroup: false,
|
|
619
|
+
label: this.userLabel(id),
|
|
620
|
+
icon: this.userIcon(id),
|
|
621
|
+
iconColor: this.userColor(id),
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
rows.push({
|
|
627
|
+
kind: 'role',
|
|
321
628
|
trail,
|
|
629
|
+
id: r.id,
|
|
630
|
+
label: r.label || r.id,
|
|
322
631
|
depth,
|
|
323
|
-
|
|
324
|
-
|
|
632
|
+
hasChildren,
|
|
633
|
+
expanded,
|
|
325
634
|
external: Boolean(r.external),
|
|
326
|
-
|
|
327
|
-
|
|
635
|
+
mine: Boolean(r.mine),
|
|
636
|
+
memberEntries,
|
|
328
637
|
});
|
|
329
|
-
|
|
330
|
-
|
|
638
|
+
|
|
639
|
+
if (expanded) {
|
|
640
|
+
for (const l of links) {
|
|
641
|
+
if (!l?.id)
|
|
642
|
+
continue;
|
|
643
|
+
const info = splitClassTitle(l.id, this.classMap?.[l.id]);
|
|
644
|
+
rows.push({
|
|
645
|
+
kind: 'class',
|
|
646
|
+
trail,
|
|
647
|
+
id: l.id,
|
|
648
|
+
depth,
|
|
649
|
+
title: info.title,
|
|
650
|
+
section: info.section,
|
|
651
|
+
icon: info.icon || 'odant:class',
|
|
652
|
+
isWrite: l.access === 'write',
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
if (childRoles.length)
|
|
656
|
+
walk(childRoles, trail, depth + 1);
|
|
657
|
+
}
|
|
331
658
|
}
|
|
332
659
|
};
|
|
333
|
-
walk(this.security?.ROLES || []);
|
|
660
|
+
walk(this.security?.ROLES || [], '', 0);
|
|
661
|
+
return rows;
|
|
662
|
+
},
|
|
663
|
+
get selectedPickerCount() {
|
|
664
|
+
return Object.keys(this.pickerChecked || {}).filter(k => this.pickerChecked[k]).length;
|
|
665
|
+
},
|
|
666
|
+
get visibleClassNodes() {
|
|
667
|
+
const q = String(this.classSearch || '').trim().toLowerCase();
|
|
668
|
+
const out = [];
|
|
669
|
+
const matchSubtree = (node) => {
|
|
670
|
+
const selfMatch = String(node.label || '').toLowerCase().includes(q);
|
|
671
|
+
const kids = Array.isArray(node.children) ? node.children : [];
|
|
672
|
+
if (!q)
|
|
673
|
+
return { match: true };
|
|
674
|
+
return { match: selfMatch || kids.some(k => matchSubtree(k).match) };
|
|
675
|
+
};
|
|
676
|
+
const walk = (nodes, depth = 0) => {
|
|
677
|
+
for (const n of Array.isArray(nodes) ? nodes : []) {
|
|
678
|
+
const kids = Array.isArray(n.children) ? n.children : [];
|
|
679
|
+
if (!matchSubtree(n).match)
|
|
680
|
+
continue;
|
|
681
|
+
const expanded = q ? true : Boolean(this.expandedClassPaths?.[n.path] ?? (depth === 0));
|
|
682
|
+
out.push({
|
|
683
|
+
path: n.path,
|
|
684
|
+
label: n.label,
|
|
685
|
+
depth,
|
|
686
|
+
icon: n.icon || 'odant:class',
|
|
687
|
+
selectable: Boolean(n.selectable),
|
|
688
|
+
hasChildren: kids.length > 0,
|
|
689
|
+
expanded,
|
|
690
|
+
checked: Boolean(this.pickerChecked?.[n.path]),
|
|
691
|
+
});
|
|
692
|
+
if (kids.length && expanded)
|
|
693
|
+
walk(kids, depth + 1);
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
walk(this.classTreeRoots || [], 0);
|
|
334
697
|
return out;
|
|
335
698
|
},
|
|
336
699
|
userLabel(uid) {
|
|
337
|
-
if (uid === 'USERS')
|
|
338
|
-
return '👥 Все пользователи (USERS)';
|
|
339
|
-
if (uid === 'GUESTS' || uid === 'GUEST')
|
|
340
|
-
return '🌐 Все гости (GUESTS)';
|
|
341
700
|
return this.userMap?.[uid] || uid;
|
|
342
701
|
},
|
|
343
702
|
userIcon(uid) {
|
|
@@ -355,19 +714,20 @@ export default {
|
|
|
355
714
|
return meta?.iconColor || '#3b82f6';
|
|
356
715
|
return '';
|
|
357
716
|
},
|
|
358
|
-
classTitle(path) {
|
|
359
|
-
return this.classMap?.[path] || String(path || '').replace(/^\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+\/MODULES\/[^/]+\//, '');
|
|
360
|
-
},
|
|
361
717
|
async reload() {
|
|
362
718
|
this.error = '';
|
|
363
719
|
if (!this.$item)
|
|
364
720
|
return;
|
|
365
721
|
try {
|
|
366
|
-
this.canEdit = !!(WORK?.DEV_MODE || await this.$item.isAdmin);
|
|
722
|
+
this.canEdit = !!(WORK?.DEV_MODE || await (this.$item.isBoss ?? this.$item.isAdmin));
|
|
367
723
|
if (this.canEdit) {
|
|
368
724
|
const body = await this.$item.body;
|
|
369
725
|
this.security = JSON.parse(JSON.stringify(body?.['#security'] || {}));
|
|
370
|
-
await Promise.all([
|
|
726
|
+
await Promise.all([
|
|
727
|
+
this.loadUsers(),
|
|
728
|
+
this.loadAvailableClasses(),
|
|
729
|
+
this.loadAvailableStructures(),
|
|
730
|
+
]);
|
|
371
731
|
}
|
|
372
732
|
else {
|
|
373
733
|
const [bossList, placesRes] = await Promise.all([
|
|
@@ -382,15 +742,15 @@ export default {
|
|
|
382
742
|
...(p.external ? { external: true } : {}),
|
|
383
743
|
...(p.mine ? { mine: true } : {}),
|
|
384
744
|
USERS: Array.isArray(p.users) ? p.users : [],
|
|
385
|
-
LINKS: Array.isArray(p.links) ? p.links.map(l => ({ id: l.id, access: l.access || 'read', scope: l.scope
|
|
745
|
+
LINKS: Array.isArray(p.links) ? p.links.map(l => ({ id: l.id, access: l.access || 'read', ...(l.scope ? { scope: l.scope } : {}) })) : [],
|
|
386
746
|
ROLES: toRoles(p.roles),
|
|
387
747
|
}));
|
|
388
748
|
this.security = {
|
|
389
|
-
BOSS: Array.isArray(bossList) ? bossList.map(u => u?.id || u).filter(Boolean) : [],
|
|
749
|
+
BOSS: Array.isArray(bossList) ? bossList.map(u => u?.id || u).filter(Boolean).slice(0, 1) : [],
|
|
390
750
|
ROLES: toRoles(placesRes?.places),
|
|
391
751
|
};
|
|
392
|
-
this.
|
|
393
|
-
this.
|
|
752
|
+
this.classTreeRoots = [];
|
|
753
|
+
this.availableStructures = [];
|
|
394
754
|
}
|
|
395
755
|
await this.loadInheritedBoss();
|
|
396
756
|
}
|
|
@@ -398,22 +758,6 @@ export default {
|
|
|
398
758
|
this.error = String(e?.message || e);
|
|
399
759
|
}
|
|
400
760
|
},
|
|
401
|
-
async openUser(uid) {
|
|
402
|
-
if (!uid || uid === 'USERS' || uid === 'GUESTS' || uid === 'GUEST')
|
|
403
|
-
return;
|
|
404
|
-
if (typeof window?.execute !== 'function')
|
|
405
|
-
return;
|
|
406
|
-
const target = await WORK.get_item(`/USERS/${uid}`).catch(() => null);
|
|
407
|
-
if (target)
|
|
408
|
-
window.execute(target);
|
|
409
|
-
},
|
|
410
|
-
async openClass(clsPath) {
|
|
411
|
-
if (!clsPath || typeof window?.execute !== 'function')
|
|
412
|
-
return;
|
|
413
|
-
const target = await WORK.get_item(clsPath).catch(() => null);
|
|
414
|
-
if (target)
|
|
415
|
-
window.execute(target);
|
|
416
|
-
},
|
|
417
761
|
async loadUsers() {
|
|
418
762
|
try {
|
|
419
763
|
const uRoot = (await WORK.get_item('/USERS')) || (await WORK.get_item('/users'));
|
|
@@ -439,8 +783,26 @@ export default {
|
|
|
439
783
|
}
|
|
440
784
|
catch { /* ignore */ }
|
|
441
785
|
},
|
|
786
|
+
async loadAvailableStructures() {
|
|
787
|
+
if (!this.$item?.fetch)
|
|
788
|
+
return;
|
|
789
|
+
try {
|
|
790
|
+
const res = await this.$item.fetch('agent_structures_list');
|
|
791
|
+
const list = Array.isArray(res?.structures) ? res.structures : [];
|
|
792
|
+
const map = {};
|
|
793
|
+
for (const s of list) {
|
|
794
|
+
if (s?.path)
|
|
795
|
+
map[s.path] = s;
|
|
796
|
+
}
|
|
797
|
+
this.availableStructures = list;
|
|
798
|
+
this.structureMap = map;
|
|
799
|
+
}
|
|
800
|
+
catch {
|
|
801
|
+
this.availableStructures = [];
|
|
802
|
+
}
|
|
803
|
+
},
|
|
442
804
|
async loadInheritedBoss() {
|
|
443
|
-
if (this.
|
|
805
|
+
if (this.currentBoss || !this.$item?.path) {
|
|
444
806
|
this.inheritedBossInfo = null;
|
|
445
807
|
return;
|
|
446
808
|
}
|
|
@@ -460,7 +822,7 @@ export default {
|
|
|
460
822
|
this.inheritedBossInfo = {
|
|
461
823
|
fromPath: pPath,
|
|
462
824
|
fromLabel: anc.label || anc.DATA?.label || anc.id || (pPath === '/' ? 'WORK' : pPath),
|
|
463
|
-
users: ids,
|
|
825
|
+
users: ids.slice(0, 1),
|
|
464
826
|
};
|
|
465
827
|
return;
|
|
466
828
|
}
|
|
@@ -471,45 +833,46 @@ export default {
|
|
|
471
833
|
},
|
|
472
834
|
async loadAvailableClasses() {
|
|
473
835
|
try {
|
|
474
|
-
const
|
|
475
|
-
const
|
|
476
|
-
const basePath = m ? m[1] : '';
|
|
477
|
-
if (!basePath)
|
|
478
|
-
return;
|
|
479
|
-
const modRoot = await WORK.get_item(basePath + '/MODULES/Register');
|
|
480
|
-
if (!modRoot?.fetch)
|
|
481
|
-
return;
|
|
482
|
-
const info = await WORK.fetch(location.origin + basePath + '/MODULES/Register', 'info', { deep: 4, branch: 'classes' });
|
|
483
|
-
const list = [];
|
|
836
|
+
const res = this.$item?.fetch ? await this.$item.fetch('agent_available_classes').catch(() => null) : null;
|
|
837
|
+
const roots = Array.isArray(res?.roots) ? res.roots : [];
|
|
484
838
|
const map = {};
|
|
485
|
-
const
|
|
486
|
-
const visit = (nodes) => {
|
|
839
|
+
const indexNodes = (nodes) => {
|
|
487
840
|
for (const n of Array.isArray(nodes) ? nodes : []) {
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
841
|
+
if (n?.path && n.selectable) {
|
|
842
|
+
const base = splitClassTitle(n.shortPath || n.path);
|
|
843
|
+
map[n.path] = {
|
|
844
|
+
title: n.label || base.title,
|
|
845
|
+
section: base.section,
|
|
846
|
+
icon: n.icon || 'odant:class',
|
|
847
|
+
};
|
|
495
848
|
}
|
|
496
|
-
if (Array.isArray(n
|
|
497
|
-
|
|
849
|
+
if (Array.isArray(n?.children))
|
|
850
|
+
indexNodes(n.children);
|
|
498
851
|
}
|
|
499
852
|
};
|
|
500
|
-
|
|
501
|
-
this.
|
|
853
|
+
indexNodes(roots);
|
|
854
|
+
this.classTreeRoots = roots;
|
|
502
855
|
this.classMap = map;
|
|
503
856
|
}
|
|
504
857
|
catch { /* ignore */ }
|
|
505
858
|
},
|
|
506
|
-
async persist(nextSec) {
|
|
859
|
+
async persist(nextSec, auditTitle = '', auditSummary = '') {
|
|
507
860
|
this.error = '';
|
|
508
861
|
try {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
862
|
+
if (typeof this.$item?.fetch === 'function') {
|
|
863
|
+
const res = await this.$item.fetch('security_update', {}, JSON.stringify({
|
|
864
|
+
security: nextSec,
|
|
865
|
+
title: auditTitle || 'Обновлены права и роли подразделения',
|
|
866
|
+
summary: auditSummary || '',
|
|
867
|
+
}));
|
|
868
|
+
this.security = JSON.parse(JSON.stringify(res?.security || nextSec));
|
|
869
|
+
}
|
|
870
|
+
else {
|
|
871
|
+
const body = await this.$item.body;
|
|
872
|
+
body['#security'] = nextSec;
|
|
873
|
+
await this.$item.save(body);
|
|
874
|
+
this.security = JSON.parse(JSON.stringify(nextSec));
|
|
875
|
+
}
|
|
513
876
|
this.$item.reset?.();
|
|
514
877
|
this.$item.fire?.('changed', { value: null });
|
|
515
878
|
await this.loadInheritedBoss();
|
|
@@ -525,32 +888,117 @@ export default {
|
|
|
525
888
|
}
|
|
526
889
|
}
|
|
527
890
|
catch { /* ignore cross-origin */ }
|
|
528
|
-
this.shadowRoot?.querySelector?.('oda-messenger-settings')?.reload?.();
|
|
529
891
|
}
|
|
530
892
|
catch (e) {
|
|
531
893
|
this.error = String(e?.message || e);
|
|
532
894
|
}
|
|
533
895
|
},
|
|
534
|
-
async
|
|
535
|
-
|
|
536
|
-
if (e?.target)
|
|
537
|
-
e.target.value = '';
|
|
538
|
-
if (!uid)
|
|
896
|
+
async openUser(uid) {
|
|
897
|
+
if (!uid || uid === 'USERS' || uid === 'GUESTS' || uid === 'GUEST' || typeof window?.execute !== 'function')
|
|
539
898
|
return;
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
899
|
+
const target = await WORK.get_item(`/USERS/${uid}`).catch(() => null);
|
|
900
|
+
if (target)
|
|
901
|
+
window.execute(target);
|
|
902
|
+
},
|
|
903
|
+
async openMember(entry) {
|
|
904
|
+
if (!entry || entry.isGroup || typeof window?.execute !== 'function')
|
|
905
|
+
return;
|
|
906
|
+
if (entry.isNode) {
|
|
907
|
+
const target = await WORK.get_item(entry.id).catch(() => null);
|
|
908
|
+
if (target)
|
|
909
|
+
window.execute(target);
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
await this.openUser(entry.id);
|
|
913
|
+
},
|
|
914
|
+
async openClass(clsPath) {
|
|
915
|
+
if (!clsPath || typeof window?.execute !== 'function')
|
|
916
|
+
return;
|
|
917
|
+
const target = await WORK.get_item(clsPath).catch(() => null);
|
|
918
|
+
if (target)
|
|
919
|
+
window.execute(target);
|
|
545
920
|
},
|
|
546
|
-
|
|
921
|
+
toggleBossPicker() {
|
|
922
|
+
this.bossPickerOpen = !this.bossPickerOpen;
|
|
923
|
+
this.bossSearch = '';
|
|
924
|
+
},
|
|
925
|
+
async pickBoss(uid) {
|
|
926
|
+
this.bossPickerOpen = false;
|
|
927
|
+
await this.setBoss(uid);
|
|
928
|
+
},
|
|
929
|
+
async setBoss(uid) {
|
|
547
930
|
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
548
|
-
|
|
931
|
+
const cleanUid = String(uid || '').trim();
|
|
932
|
+
sec.BOSS = cleanUid ? [cleanUid] : [];
|
|
933
|
+
const label = cleanUid ? this.userLabel(cleanUid) : 'наследуется сверху';
|
|
934
|
+
await this.persist(sec, `Назначен руководитель: ${label}`, `В подразделении ${this.$item?.path || ''} руководитель (BOSS): ${label}.`);
|
|
935
|
+
},
|
|
936
|
+
async clearBoss() {
|
|
937
|
+
this.bossPickerOpen = false;
|
|
938
|
+
await this.setBoss('');
|
|
939
|
+
},
|
|
940
|
+
onBossDragOver(e) {
|
|
941
|
+
if (!this.canEdit)
|
|
549
942
|
return;
|
|
550
|
-
|
|
551
|
-
|
|
943
|
+
e.preventDefault();
|
|
944
|
+
if (e.dataTransfer)
|
|
945
|
+
e.dataTransfer.dropEffect = 'copy';
|
|
946
|
+
this.bossDropHover = true;
|
|
552
947
|
},
|
|
553
|
-
|
|
948
|
+
async onBossDrop(e) {
|
|
949
|
+
this.bossDropHover = false;
|
|
950
|
+
if (!this.canEdit)
|
|
951
|
+
return;
|
|
952
|
+
e.preventDefault();
|
|
953
|
+
const dropped = parseDroppedItem(e);
|
|
954
|
+
if (!isDroppedUser(dropped)) {
|
|
955
|
+
this.error = 'Для назначения руководителя перетащите пользователя из дерева.';
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
const uid = dropped.id || dropped.path.split('/').pop();
|
|
959
|
+
if (uid)
|
|
960
|
+
await this.setBoss(uid);
|
|
961
|
+
},
|
|
962
|
+
onRoleDragOver(e, trail) {
|
|
963
|
+
if (!this.canEdit)
|
|
964
|
+
return;
|
|
965
|
+
e.preventDefault();
|
|
966
|
+
if (e.dataTransfer)
|
|
967
|
+
e.dataTransfer.dropEffect = 'copy';
|
|
968
|
+
this.dropHoverTrail = trail;
|
|
969
|
+
},
|
|
970
|
+
onRoleDragLeave(trail) {
|
|
971
|
+
if (this.dropHoverTrail === trail)
|
|
972
|
+
this.dropHoverTrail = '';
|
|
973
|
+
},
|
|
974
|
+
async onRoleDrop(e, trail) {
|
|
975
|
+
this.dropHoverTrail = '';
|
|
976
|
+
if (!this.canEdit)
|
|
977
|
+
return;
|
|
978
|
+
e.preventDefault();
|
|
979
|
+
const dropped = parseDroppedItem(e);
|
|
980
|
+
if (!dropped)
|
|
981
|
+
return;
|
|
982
|
+
if (isDroppedUser(dropped)) {
|
|
983
|
+
const uid = dropped.id || dropped.path.split('/').pop();
|
|
984
|
+
if (uid)
|
|
985
|
+
await this._addMemberToRole(trail, uid);
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
if (isDroppedStructure(dropped)) {
|
|
989
|
+
if (dropped.path && dropped.path !== this.$item?.path)
|
|
990
|
+
await this._addMemberToRole(trail, dropped.path);
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
if (isDroppedClass(dropped) && dropped.path) {
|
|
994
|
+
await this._addLinksToRole(trail, [dropped.path]);
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
toggleRoleExpand(trail) {
|
|
998
|
+
const cur = this.expandedRoles?.[trail] !== false;
|
|
999
|
+
this.expandedRoles = { ...this.expandedRoles, [trail]: !cur };
|
|
1000
|
+
},
|
|
1001
|
+
_findRoleMut(sec, trail) {
|
|
554
1002
|
const steps = String(trail || '').split('/').filter(Boolean);
|
|
555
1003
|
let list = Array.isArray(sec.ROLES) ? sec.ROLES : [];
|
|
556
1004
|
let node = null;
|
|
@@ -562,55 +1010,50 @@ export default {
|
|
|
562
1010
|
}
|
|
563
1011
|
return node;
|
|
564
1012
|
},
|
|
565
|
-
|
|
566
|
-
|
|
1013
|
+
openAddRole(parentTrail = '') {
|
|
1014
|
+
this.addingRoleParent = this.addingRoleParent === parentTrail ? null : parentTrail;
|
|
1015
|
+
this.newRoleLabel = '';
|
|
1016
|
+
},
|
|
1017
|
+
cancelAddRole() {
|
|
1018
|
+
this.addingRoleParent = null;
|
|
1019
|
+
this.newRoleLabel = '';
|
|
1020
|
+
},
|
|
1021
|
+
onNewRoleKey(e) {
|
|
1022
|
+
if (e?.key === 'Enter')
|
|
1023
|
+
this.confirmAddRole();
|
|
1024
|
+
else if (e?.key === 'Escape')
|
|
1025
|
+
this.cancelAddRole();
|
|
1026
|
+
},
|
|
1027
|
+
async confirmAddRole() {
|
|
1028
|
+
const label = String(this.newRoleLabel || '').trim();
|
|
567
1029
|
if (!label)
|
|
568
1030
|
return;
|
|
569
|
-
const
|
|
1031
|
+
const parentTrail = this.addingRoleParent || '';
|
|
1032
|
+
const id = label.toLowerCase().replace(/[^a-zа-яё0-9_-]+/gi, '_').replace(/^_+|_+$/g, '') || ('role_' + Date.now());
|
|
570
1033
|
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
USERS: [],
|
|
576
|
-
LINKS: [],
|
|
577
|
-
};
|
|
578
|
-
if (parentTrail) {
|
|
579
|
-
const parent = this._findPlaceMut(sec, parentTrail);
|
|
580
|
-
if (!parent)
|
|
581
|
-
return;
|
|
582
|
-
if (parent.external)
|
|
583
|
-
newNode.external = true;
|
|
584
|
-
parent.ROLES = Array.isArray(parent.ROLES) ? parent.ROLES : [];
|
|
585
|
-
if (!parent.ROLES.some(r => r.id === id))
|
|
586
|
-
parent.ROLES.push(newNode);
|
|
1034
|
+
const targetList = parentTrail
|
|
1035
|
+
? ((this._findRoleMut(sec, parentTrail) || {}).ROLES ??= [])
|
|
1036
|
+
: (sec.ROLES ??= []);
|
|
1037
|
+
if (!targetList.some(r => r.id === id)) {
|
|
1038
|
+
targetList.push({ id, label, USERS: [], LINKS: [] });
|
|
587
1039
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
this.newPlaceLabel = '';
|
|
593
|
-
this.newPlaceExternal = false;
|
|
594
|
-
}
|
|
595
|
-
await this.persist(sec);
|
|
1040
|
+
if (parentTrail)
|
|
1041
|
+
this.expandedRoles = { ...this.expandedRoles, [parentTrail]: true };
|
|
1042
|
+
this.cancelAddRole();
|
|
1043
|
+
await this.persist(sec, `Создана роль «${label}»`, `В подразделении ${this.$item?.path || ''} добавлена роль «${label}».`);
|
|
596
1044
|
},
|
|
597
|
-
async
|
|
1045
|
+
async toggleRoleExternal(trail, checked) {
|
|
598
1046
|
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
599
|
-
const node = this.
|
|
1047
|
+
const node = this._findRoleMut(sec, trail);
|
|
600
1048
|
if (!node)
|
|
601
1049
|
return;
|
|
602
1050
|
if (checked)
|
|
603
1051
|
node.external = true;
|
|
604
1052
|
else
|
|
605
1053
|
delete node.external;
|
|
606
|
-
await this.persist(sec);
|
|
1054
|
+
await this.persist(sec, `Обновлена роль «${node.label || node.id}»`, `Роль «${node.label || node.id}»: внешний клиент = ${checked ? 'да' : 'нет'}.`);
|
|
607
1055
|
},
|
|
608
|
-
async
|
|
609
|
-
const name = window.prompt?.('Название подчинённого рабочего места:');
|
|
610
|
-
if (name && name.trim())
|
|
611
|
-
await this.addPlace(parentTrail, name.trim());
|
|
612
|
-
},
|
|
613
|
-
async removePlace(trail) {
|
|
1056
|
+
async removeRole(trail) {
|
|
614
1057
|
const steps = String(trail || '').split('/').filter(Boolean);
|
|
615
1058
|
if (!steps.length)
|
|
616
1059
|
return;
|
|
@@ -620,149 +1063,122 @@ export default {
|
|
|
620
1063
|
sec.ROLES = (sec.ROLES || []).filter(r => r?.id !== targetId);
|
|
621
1064
|
}
|
|
622
1065
|
else {
|
|
623
|
-
const parent = this.
|
|
1066
|
+
const parent = this._findRoleMut(sec, steps.join('/'));
|
|
624
1067
|
if (parent && Array.isArray(parent.ROLES))
|
|
625
1068
|
parent.ROLES = parent.ROLES.filter(r => r?.id !== targetId);
|
|
626
1069
|
}
|
|
627
|
-
await this.persist(sec);
|
|
1070
|
+
await this.persist(sec, `Удалена роль «${targetId}»`, `Из подразделения ${this.$item?.path || ''} удалена роль «${targetId}».`);
|
|
628
1071
|
},
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
if (
|
|
632
|
-
|
|
633
|
-
if (!uid)
|
|
1072
|
+
toggleMemberPicker(trail) {
|
|
1073
|
+
this.pickerTrail = '';
|
|
1074
|
+
if (this.memberPickerTrail === trail) {
|
|
1075
|
+
this.closeMemberPicker();
|
|
634
1076
|
return;
|
|
1077
|
+
}
|
|
1078
|
+
this.memberPickerTrail = trail;
|
|
1079
|
+
this.memberSearch = '';
|
|
1080
|
+
},
|
|
1081
|
+
closeMemberPicker() {
|
|
1082
|
+
this.memberPickerTrail = '';
|
|
1083
|
+
this.memberSearch = '';
|
|
1084
|
+
},
|
|
1085
|
+
async pickMember(trail, memberId) {
|
|
1086
|
+
this.closeMemberPicker();
|
|
1087
|
+
await this._addMemberToRole(trail, memberId);
|
|
1088
|
+
},
|
|
1089
|
+
async _addMemberToRole(trail, memberId) {
|
|
635
1090
|
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
636
|
-
const node = this.
|
|
1091
|
+
const node = this._findRoleMut(sec, trail);
|
|
637
1092
|
if (!node)
|
|
638
1093
|
return;
|
|
639
1094
|
node.USERS = Array.isArray(node.USERS) ? node.USERS : [];
|
|
640
|
-
if (!node.USERS.includes(
|
|
641
|
-
node.USERS.push(
|
|
642
|
-
await this.persist(sec);
|
|
1095
|
+
if (!node.USERS.includes(memberId))
|
|
1096
|
+
node.USERS.push(memberId);
|
|
1097
|
+
await this.persist(sec, `В роль «${node.label || node.id}» добавлен участник`, `В роль «${node.label || node.id}» добавлен ${memberId}.`);
|
|
643
1098
|
},
|
|
644
|
-
async
|
|
1099
|
+
async removeRoleMember(trail, memberId) {
|
|
645
1100
|
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
646
|
-
const node = this.
|
|
1101
|
+
const node = this._findRoleMut(sec, trail);
|
|
647
1102
|
if (!node || !Array.isArray(node.USERS))
|
|
648
1103
|
return;
|
|
649
|
-
node.USERS = node.USERS.filter(id => id !==
|
|
650
|
-
await this.persist(sec);
|
|
651
|
-
},
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
if (
|
|
655
|
-
|
|
656
|
-
if (!clsPath)
|
|
1104
|
+
node.USERS = node.USERS.filter(id => id !== memberId);
|
|
1105
|
+
await this.persist(sec, `Из роли «${node.label || node.id}» исключён участник`, `Из роли «${node.label || node.id}» удалён ${memberId}.`);
|
|
1106
|
+
},
|
|
1107
|
+
toggleClassPicker(trail) {
|
|
1108
|
+
this.memberPickerTrail = '';
|
|
1109
|
+
if (this.pickerTrail === trail) {
|
|
1110
|
+
this.closeClassPicker();
|
|
657
1111
|
return;
|
|
1112
|
+
}
|
|
1113
|
+
this.pickerTrail = trail;
|
|
1114
|
+
this.classSearch = '';
|
|
1115
|
+
this.pickerChecked = {};
|
|
1116
|
+
},
|
|
1117
|
+
closeClassPicker() {
|
|
1118
|
+
this.pickerTrail = '';
|
|
1119
|
+
this.classSearch = '';
|
|
1120
|
+
this.pickerChecked = {};
|
|
1121
|
+
},
|
|
1122
|
+
toggleClassExpand(path) {
|
|
1123
|
+
this.expandedClassPaths = {
|
|
1124
|
+
...this.expandedClassPaths,
|
|
1125
|
+
[path]: !this.expandedClassPaths?.[path],
|
|
1126
|
+
};
|
|
1127
|
+
},
|
|
1128
|
+
togglePickerCheck(path, checked) {
|
|
1129
|
+
this.pickerChecked = {
|
|
1130
|
+
...this.pickerChecked,
|
|
1131
|
+
[path]: Boolean(checked),
|
|
1132
|
+
};
|
|
1133
|
+
},
|
|
1134
|
+
onPickerLabelTap(node) {
|
|
1135
|
+
if (node.hasChildren && !node.selectable) {
|
|
1136
|
+
this.toggleClassExpand(node.path);
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
if (node.selectable)
|
|
1140
|
+
this.togglePickerCheck(node.path, !node.checked);
|
|
1141
|
+
},
|
|
1142
|
+
async applyClassPicker(trail) {
|
|
1143
|
+
const paths = Object.keys(this.pickerChecked || {}).filter(k => this.pickerChecked[k]);
|
|
1144
|
+
if (!paths.length)
|
|
1145
|
+
return;
|
|
1146
|
+
await this._addLinksToRole(trail, paths);
|
|
1147
|
+
this.closeClassPicker();
|
|
1148
|
+
},
|
|
1149
|
+
async _addLinksToRole(trail, paths) {
|
|
658
1150
|
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
659
|
-
const node = this.
|
|
1151
|
+
const node = this._findRoleMut(sec, trail);
|
|
660
1152
|
if (!node)
|
|
661
1153
|
return;
|
|
662
1154
|
node.LINKS = Array.isArray(node.LINKS) ? node.LINKS : [];
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
1155
|
+
let added = 0;
|
|
1156
|
+
for (const p of paths) {
|
|
1157
|
+
if (p && !node.LINKS.some(l => l?.id === p)) {
|
|
1158
|
+
node.LINKS.push({ id: p, access: 'read' });
|
|
1159
|
+
added++;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
if (added) {
|
|
1163
|
+
this.expandedRoles = { ...this.expandedRoles, [trail]: true };
|
|
1164
|
+
await this.persist(sec, `К роли «${node.label || node.id}» привязаны классы (${added})`, `К роли «${node.label || node.id}» привязаны классы: ${paths.join(', ')}.`);
|
|
1165
|
+
}
|
|
666
1166
|
},
|
|
667
|
-
async
|
|
1167
|
+
async updateRoleLinkAccess(trail, clsPath, access) {
|
|
668
1168
|
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
669
|
-
const node = this.
|
|
1169
|
+
const node = this._findRoleMut(sec, trail);
|
|
670
1170
|
const link = node?.LINKS?.find(l => l?.id === clsPath);
|
|
671
1171
|
if (!link)
|
|
672
1172
|
return;
|
|
673
1173
|
link.access = access === 'write' ? 'write' : 'read';
|
|
674
|
-
await this.persist(sec);
|
|
1174
|
+
await this.persist(sec, `Изменён доступ роли к классу`, `Роль «${node.label || node.id}»: для ${clsPath} установлен доступ «${link.access}».`);
|
|
675
1175
|
},
|
|
676
|
-
async
|
|
1176
|
+
async removeRoleLink(trail, clsPath) {
|
|
677
1177
|
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
678
|
-
const node = this.
|
|
679
|
-
const link = node?.LINKS?.find(l => l?.id === clsPath);
|
|
680
|
-
if (!link)
|
|
681
|
-
return;
|
|
682
|
-
if (scope)
|
|
683
|
-
link.scope = scope;
|
|
684
|
-
else
|
|
685
|
-
delete link.scope;
|
|
686
|
-
await this.persist(sec);
|
|
687
|
-
},
|
|
688
|
-
async removePlaceLink(trail, clsPath) {
|
|
689
|
-
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
690
|
-
const node = this._findPlaceMut(sec, trail);
|
|
1178
|
+
const node = this._findRoleMut(sec, trail);
|
|
691
1179
|
if (!node || !Array.isArray(node.LINKS))
|
|
692
1180
|
return;
|
|
693
1181
|
node.LINKS = node.LINKS.filter(l => l?.id !== clsPath);
|
|
694
|
-
await this.persist(sec);
|
|
695
|
-
},
|
|
696
|
-
inviteStatusLabel(st) {
|
|
697
|
-
return ({ active: 'активно', used: 'принято', revoked: 'отозвано', expired: 'истекло' })[st] || st;
|
|
698
|
-
},
|
|
699
|
-
inviteLinkOf(token) {
|
|
700
|
-
return `${location.origin}/?invite=${encodeURIComponent(token || '')}`;
|
|
701
|
-
},
|
|
702
|
-
async copyText(text) {
|
|
703
|
-
try {
|
|
704
|
-
await navigator.clipboard?.writeText(String(text || ''));
|
|
705
|
-
}
|
|
706
|
-
catch {
|
|
707
|
-
window.prompt?.('Скопируйте ссылку приглашения:', String(text || ''));
|
|
708
|
-
}
|
|
709
|
-
},
|
|
710
|
-
async loadInvites() {
|
|
711
|
-
if (!this.canEdit || !this.$item?.fetch) {
|
|
712
|
-
this.invitesList = [];
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
try {
|
|
716
|
-
const list = await this.$item.fetch('invite_list', {});
|
|
717
|
-
this.invitesList = Array.isArray(list) ? list : [];
|
|
718
|
-
}
|
|
719
|
-
catch {
|
|
720
|
-
this.invitesList = [];
|
|
721
|
-
}
|
|
722
|
-
},
|
|
723
|
-
openInvite(trail) {
|
|
724
|
-
if (this.inviteTrail === trail) {
|
|
725
|
-
this.inviteTrail = '';
|
|
726
|
-
this.inviteResult = null;
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
this.inviteTrail = trail;
|
|
730
|
-
this.inviteChannel = 'link';
|
|
731
|
-
this.inviteRecipient = '';
|
|
732
|
-
this.inviteNote = '';
|
|
733
|
-
this.inviteResult = null;
|
|
734
|
-
},
|
|
735
|
-
async sendInvite() {
|
|
736
|
-
if (!this.inviteTrail || this.inviteBusy)
|
|
737
|
-
return;
|
|
738
|
-
this.inviteBusy = true;
|
|
739
|
-
this.error = '';
|
|
740
|
-
try {
|
|
741
|
-
const res = await this.$item.fetch('invite_create', {}, {
|
|
742
|
-
trail: this.inviteTrail,
|
|
743
|
-
channel: this.inviteChannel,
|
|
744
|
-
recipient: this.inviteRecipient,
|
|
745
|
-
note: this.inviteNote,
|
|
746
|
-
origin: location.origin,
|
|
747
|
-
});
|
|
748
|
-
this.inviteResult = res;
|
|
749
|
-
await this.loadInvites();
|
|
750
|
-
}
|
|
751
|
-
catch (e) {
|
|
752
|
-
this.error = String(e?.message || e);
|
|
753
|
-
}
|
|
754
|
-
finally {
|
|
755
|
-
this.inviteBusy = false;
|
|
756
|
-
}
|
|
757
|
-
},
|
|
758
|
-
async revokeInvite(id) {
|
|
759
|
-
this.error = '';
|
|
760
|
-
try {
|
|
761
|
-
await this.$item.fetch('invite_revoke', {}, { id });
|
|
762
|
-
await this.loadInvites();
|
|
763
|
-
}
|
|
764
|
-
catch (e) {
|
|
765
|
-
this.error = String(e?.message || e);
|
|
766
|
-
}
|
|
1182
|
+
await this.persist(sec, `Отвязан класс от роли`, `От роли «${node.label || node.id}» отвязан класс ${clsPath}.`);
|
|
767
1183
|
},
|
|
768
1184
|
}
|