odant-work 1.0.75 → 1.0.78

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