odant-work 1.0.65 → 1.0.67
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 +56 -59
- package/{PROJECTS → $server/$folder/$class}/$domain/handlers/methods/restore/$handler/class.js +40 -24
- package/$server/$folder/$class/$structure/$server/handlers/methods/distro/$handler/class.js +0 -2
- package/$server/$folder/$class/$structure/handlers/methods/archive/$handler/class.js +27 -0
- package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +9 -0
- package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +310 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +160 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/class.js +10 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/system.js +233 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/agent.js +289 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/{search/$handler → system/$handler/tabs}/search.js +4 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/{staff/$handler → system/$handler/tabs}/staff.js +122 -14
- package/$server/$folder/$class/handlers/pages/form/editor/$handler/class.js +3 -0
- package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +10 -6
- package/$server/$folder/handlers/pages/form/$handler/form.js +27 -2
- package/$server/$folder/lib/dot/dot-math.js +1 -1
- package/$server/$folder/lib/dot/dot.js +19 -5
- package/$server/$folder/lib/explorer/explorer.js +29 -15
- package/$server/$folder/lib/node/node.js +49 -4
- package/$server/$folder/lib/security/users/users.js +68 -3
- package/$server/$folder/lib/tools/tools.js +3 -3
- package/$server/$folder/lib/tree/tree.js +29 -13
- package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/gantt.js" +293 -1
- package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/scheduler.js" +234 -1
- package/ORGANIZATIONS/$domain/class.js +1 -0
- package/PROJECTS/$domain/class.js +1 -0
- package/package.json +1 -1
- package/sources/client/handler.js +27 -11
- package/sources/client.js +36 -0
- package/sources/data/api.js +25 -5
- package/sources/data/db.js +39 -0
- package/sources/data/scope.js +2 -1
- package/sources/host/websocket.js +22 -0
- package/sources/modules/agent/index.js +11 -1
- package/sources/modules/agent/node-rules.js +171 -0
- package/sources/modules/agent/resources.js +1 -0
- package/sources/modules/agent/scheduler.js +75 -17
- package/sources/modules/agent/triggers.js +486 -198
- package/sources/modules/agent/twin-bus.js +163 -0
- package/sources/server/access/gateway.js +3 -0
- package/sources/server/access/links.js +8 -4
- package/sources/server/access/policy.js +7 -2
- package/sources/server/access/workplaces.js +14 -5
- package/sources/server/chat-threads.js +640 -0
- package/sources/server/class/archive.js +4 -3
- package/sources/server/class/feed.js +59 -0
- package/sources/server/class/security.js +18 -3
- package/sources/server/handler.js +1 -2
- package/$server/$folder/$class/$structure/$base/handlers/methods/archive/$handler/class.js +0 -23
- package/$server/$folder/$class/$structure/$project/handlers/methods/archive/$handler/class.js +0 -23
- package/$server/$folder/$class/$structure/$server/handlers/pages/form/license/$handler/class.js +0 -9
- package/$server/$folder/$class/$structure/handlers/pages/form/database/$handler/class.js +0 -9
- package/$server/$folder/$class/$structure/handlers/pages/form/gantt/$handler/class.js +0 -27
- package/$server/$folder/$class/$structure/handlers/pages/form/gantt/$handler/gantt.js +0 -293
- package/$server/$folder/$class/$structure/handlers/pages/form/messengers/$handler/class.js +0 -5
- package/$server/$folder/$class/$structure/handlers/pages/form/scheduler/$handler/class.js +0 -27
- package/$server/$folder/$class/$structure/handlers/pages/form/scheduler/$handler/scheduler.js +0 -234
- package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +0 -5
- package/$server/$folder/$class/$structure/handlers/pages/form/staff/$handler/class.js +0 -5
- package/ORGANIZATIONS/$domain/handlers/methods/restore/$handler/class.js +0 -173
- /package/$server/$folder/$class/$structure/handlers/pages/form/{database/$handler → system/$handler/tabs}/database.js +0 -0
- /package/$server/$folder/$class/$structure/{$server/handlers/pages/form/license/$handler → handlers/pages/form/system/$handler/tabs}/license.js +0 -0
- /package/$server/$folder/$class/$structure/handlers/pages/form/{messengers/$handler → system/$handler/tabs}/messengers.js +0 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
imports: 'oda//app-layout.js, oda//icon, oda//button',
|
|
3
|
+
template: /*html*/`
|
|
4
|
+
<style>
|
|
5
|
+
:host {
|
|
6
|
+
@apply --vertical;
|
|
7
|
+
@apply --flex;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
background: var(--content-background);
|
|
10
|
+
color: var(--content-color);
|
|
11
|
+
min-height: 0;
|
|
12
|
+
}
|
|
13
|
+
.left-wrap {
|
|
14
|
+
@apply --vertical;
|
|
15
|
+
@apply --flex;
|
|
16
|
+
min-height: 0;
|
|
17
|
+
background: var(--subtle-background);
|
|
18
|
+
}
|
|
19
|
+
.search-box {
|
|
20
|
+
@apply --horizontal;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: 6px;
|
|
23
|
+
padding: 8px 10px;
|
|
24
|
+
border-bottom: 1px solid var(--subtle-border, var(--border-color));
|
|
25
|
+
}
|
|
26
|
+
.search-input {
|
|
27
|
+
flex: 1;
|
|
28
|
+
min-width: 0;
|
|
29
|
+
padding: 5px 9px;
|
|
30
|
+
border: 1px solid var(--control-border-color, var(--border-color));
|
|
31
|
+
border-radius: 7px;
|
|
32
|
+
font: inherit;
|
|
33
|
+
font-size: 13px;
|
|
34
|
+
background: var(--content-background);
|
|
35
|
+
color: var(--control-color, inherit);
|
|
36
|
+
}
|
|
37
|
+
.tree-scroll {
|
|
38
|
+
@apply --flex;
|
|
39
|
+
overflow-y: auto;
|
|
40
|
+
padding: 8px;
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
gap: 2px;
|
|
44
|
+
}
|
|
45
|
+
.sec-title {
|
|
46
|
+
font-size: 11px;
|
|
47
|
+
font-weight: 700;
|
|
48
|
+
text-transform: uppercase;
|
|
49
|
+
letter-spacing: .04em;
|
|
50
|
+
color: var(--muted-color);
|
|
51
|
+
padding: 8px 6px 4px;
|
|
52
|
+
}
|
|
53
|
+
.row {
|
|
54
|
+
@apply --horizontal;
|
|
55
|
+
align-items: center;
|
|
56
|
+
gap: 6px;
|
|
57
|
+
padding: 5px 8px;
|
|
58
|
+
border-radius: 7px;
|
|
59
|
+
border: 1px solid transparent;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
user-select: none;
|
|
62
|
+
}
|
|
63
|
+
.row:hover {
|
|
64
|
+
background: var(--content-background);
|
|
65
|
+
border-color: var(--subtle-border, var(--border-color));
|
|
66
|
+
}
|
|
67
|
+
.row.active {
|
|
68
|
+
background: var(--accent-soft);
|
|
69
|
+
border-color: var(--accent-color);
|
|
70
|
+
color: var(--accent-color);
|
|
71
|
+
}
|
|
72
|
+
.exp {
|
|
73
|
+
width: 16px;
|
|
74
|
+
height: 16px;
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
opacity: 0.7;
|
|
79
|
+
flex-shrink: 0;
|
|
80
|
+
}
|
|
81
|
+
.row-label {
|
|
82
|
+
flex: 1;
|
|
83
|
+
min-width: 0;
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
text-overflow: ellipsis;
|
|
86
|
+
white-space: nowrap;
|
|
87
|
+
font-size: 13px;
|
|
88
|
+
font-weight: 500;
|
|
89
|
+
}
|
|
90
|
+
.badge {
|
|
91
|
+
font-size: 10.5px;
|
|
92
|
+
padding: 1px 6px;
|
|
93
|
+
border-radius: 9px;
|
|
94
|
+
background: var(--content-background);
|
|
95
|
+
color: var(--muted-color);
|
|
96
|
+
border: 1px solid var(--subtle-border, var(--border-color));
|
|
97
|
+
flex-shrink: 0;
|
|
98
|
+
}
|
|
99
|
+
.badge.write {
|
|
100
|
+
color: var(--accent-color);
|
|
101
|
+
border-color: var(--accent-color);
|
|
102
|
+
}
|
|
103
|
+
iframe.class-frame {
|
|
104
|
+
border: none;
|
|
105
|
+
width: 100%;
|
|
106
|
+
height: 100%;
|
|
107
|
+
flex: 1;
|
|
108
|
+
min-height: 0;
|
|
109
|
+
}
|
|
110
|
+
.empty-pane {
|
|
111
|
+
@apply --flex;
|
|
112
|
+
@apply --vertical;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
gap: 10px;
|
|
116
|
+
color: var(--muted-color);
|
|
117
|
+
padding: 24px;
|
|
118
|
+
text-align: center;
|
|
119
|
+
font-size: 13.5px;
|
|
120
|
+
}
|
|
121
|
+
</style>
|
|
122
|
+
|
|
123
|
+
<oda-app-layout flex>
|
|
124
|
+
<div slot="left-panel" class="left-wrap">
|
|
125
|
+
<div class="search-box">
|
|
126
|
+
<input class="search-input" type="search" placeholder="Поиск класса, модуля, счёта…" :value="filter" @input="filter = $event.target.value">
|
|
127
|
+
<oda-button icon="icons:refresh" title="Обновить дерево классов" @tap="reload()"></oda-button>
|
|
128
|
+
</div>
|
|
129
|
+
<div class="tree-scroll">
|
|
130
|
+
<div ~if="loading" class="sec-title">Загрузка…</div>
|
|
131
|
+
|
|
132
|
+
<div ~if="visibleLinkRows.length" class="sec-title">Доступные классы ({{visibleLinkRows.length}})</div>
|
|
133
|
+
<div class="row" ~for="visibleLinkRows"
|
|
134
|
+
~class="{ active: selectedPath === $for.item.path }"
|
|
135
|
+
:style="'padding-left:' + (8 + $for.item.depth * 16) + 'px'"
|
|
136
|
+
@tap="selectNode($for.item)">
|
|
137
|
+
<span class="exp" @tap.stop="toggleNode('link', $for.item)">
|
|
138
|
+
<oda-icon ~if="$for.item.hasChildren" :icon="$for.item.expanded ? 'icons:chevron-right:90' : 'icons:chevron-right'" icon-size="14"></oda-icon>
|
|
139
|
+
</span>
|
|
140
|
+
<oda-icon :icon="$for.item.icon || 'odant:class'" icon-size="17"></oda-icon>
|
|
141
|
+
<span class="row-label" :title="$for.item.path">{{$for.item.label}}</span>
|
|
142
|
+
<span ~if="$for.item.objectCount" class="badge">{{$for.item.objectCount}}</span>
|
|
143
|
+
<span class="badge" ~class="{ write: $for.item.access === 'write' || $for.item.access === 'admin' }">{{accessShort($for.item.access)}}</span>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<div ~if="isBoss && visibleModuleRows.length" class="sec-title">Модули и классы ({{visibleModuleRows.length}})</div>
|
|
147
|
+
<div class="row" ~for="visibleModuleRows"
|
|
148
|
+
~class="{ active: selectedPath === $for.item.path }"
|
|
149
|
+
:style="'padding-left:' + (8 + $for.item.depth * 16) + 'px'"
|
|
150
|
+
@tap="selectNode($for.item)">
|
|
151
|
+
<span class="exp" @tap.stop="toggleNode('mod', $for.item)">
|
|
152
|
+
<oda-icon ~if="$for.item.hasChildren" :icon="$for.item.expanded ? 'icons:chevron-right:90' : 'icons:chevron-right'" icon-size="14"></oda-icon>
|
|
153
|
+
</span>
|
|
154
|
+
<oda-icon :icon="$for.item.icon || 'odant:class'" icon-size="17"></oda-icon>
|
|
155
|
+
<span class="row-label" :title="$for.item.path">{{$for.item.label}}</span>
|
|
156
|
+
<span ~if="$for.item.objectCount" class="badge">{{$for.item.objectCount}}</span>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
<div ~if="!loading && !visibleLinkRows.length && (!isBoss || !visibleModuleRows.length)" style="padding:14px 8px;color:var(--muted-color);font-size:13px;">
|
|
160
|
+
Нет доступных классов для вашей роли в этом узле.
|
|
161
|
+
</div>
|
|
162
|
+
<div ~if="error" style="padding:8px;color:var(--error-color, #c00);font-size:12.5px;">{{error}}</div>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<div slot="main" vertical flex style="min-width: 0; min-height: 0; overflow: hidden;">
|
|
167
|
+
<iframe ~if="frameUrl" class="class-frame" :src="frameUrl"></iframe>
|
|
168
|
+
<div ~if="!frameUrl" class="empty-pane">
|
|
169
|
+
<oda-icon icon="carbon:data-base" icon-size="40" style="opacity:0.4;"></oda-icon>
|
|
170
|
+
<div>Выберите класс или модуль слева, чтобы открыть его форму</div>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
</oda-app-layout>
|
|
174
|
+
`,
|
|
175
|
+
filter: '',
|
|
176
|
+
loading: false,
|
|
177
|
+
isBoss: false,
|
|
178
|
+
linkTree: [],
|
|
179
|
+
moduleTree: [],
|
|
180
|
+
collapsedKeys: {},
|
|
181
|
+
selectedNode: null,
|
|
182
|
+
frameUrl: '',
|
|
183
|
+
error: '',
|
|
184
|
+
async attached() {
|
|
185
|
+
await this.reload();
|
|
186
|
+
},
|
|
187
|
+
get selectedPath() {
|
|
188
|
+
return this.selectedNode?.path || '';
|
|
189
|
+
},
|
|
190
|
+
get visibleLinkRows() {
|
|
191
|
+
return this._flattenVisible(this.linkTree, 'link');
|
|
192
|
+
},
|
|
193
|
+
get visibleModuleRows() {
|
|
194
|
+
return this._flattenVisible(this.moduleTree, 'mod');
|
|
195
|
+
},
|
|
196
|
+
_matchesFilter(node) {
|
|
197
|
+
const q = String(this.filter || '').trim().toLowerCase();
|
|
198
|
+
if (!q)
|
|
199
|
+
return true;
|
|
200
|
+
const own = String(node.label || '').toLowerCase().includes(q) || String(node.path || '').toLowerCase().includes(q);
|
|
201
|
+
if (own)
|
|
202
|
+
return true;
|
|
203
|
+
const kids = node.children || node.items || [];
|
|
204
|
+
return kids.some(c => this._matchesFilter(c));
|
|
205
|
+
},
|
|
206
|
+
_flattenVisible(nodes, kind, depth = 0, out = []) {
|
|
207
|
+
const hasQ = Boolean(String(this.filter || '').trim());
|
|
208
|
+
for (const n of Array.isArray(nodes) ? nodes : []) {
|
|
209
|
+
if (!n?.path || (n.id && String(n.id).startsWith('$')))
|
|
210
|
+
continue;
|
|
211
|
+
if (!this._matchesFilter(n))
|
|
212
|
+
continue;
|
|
213
|
+
const kids = (n.children || n.items || []).filter(c => c?.path && !(c.id && String(c.id).startsWith('$')));
|
|
214
|
+
const hasChildren = kids.length > 0;
|
|
215
|
+
const key = `${kind}:${n.path}`;
|
|
216
|
+
const expanded = hasQ ? true : !this.collapsedKeys?.[key];
|
|
217
|
+
out.push({
|
|
218
|
+
path: n.path,
|
|
219
|
+
label: n.label || n.id || n.path.split('/').pop(),
|
|
220
|
+
icon: n.icon || '',
|
|
221
|
+
type: n.type || '',
|
|
222
|
+
access: n.access || 'read',
|
|
223
|
+
objectCount: Number(n.objectCount) || 0,
|
|
224
|
+
depth,
|
|
225
|
+
hasChildren,
|
|
226
|
+
expanded,
|
|
227
|
+
});
|
|
228
|
+
if (hasChildren && expanded)
|
|
229
|
+
this._flattenVisible(kids, kind, depth + 1, out);
|
|
230
|
+
}
|
|
231
|
+
return out;
|
|
232
|
+
},
|
|
233
|
+
toggleNode(kind, row) {
|
|
234
|
+
if (!row?.hasChildren)
|
|
235
|
+
return;
|
|
236
|
+
const key = `${kind}:${row.path}`;
|
|
237
|
+
const next = { ...(this.collapsedKeys || {}) };
|
|
238
|
+
next[key] = !next[key];
|
|
239
|
+
this.collapsedKeys = next;
|
|
240
|
+
},
|
|
241
|
+
accessShort(a) {
|
|
242
|
+
if (a === 'admin') return 'A';
|
|
243
|
+
if (a === 'write') return 'W';
|
|
244
|
+
return 'R';
|
|
245
|
+
},
|
|
246
|
+
async reload() {
|
|
247
|
+
this.error = '';
|
|
248
|
+
if (!this.$item)
|
|
249
|
+
return;
|
|
250
|
+
this.loading = true;
|
|
251
|
+
try {
|
|
252
|
+
this.isBoss = !!(WORK?.DEV_MODE || await this.$item.isAdmin);
|
|
253
|
+
const lt = await this.$item.fetch('link_tree').catch(() => []);
|
|
254
|
+
this.linkTree = Array.isArray(lt) ? lt : [];
|
|
255
|
+
|
|
256
|
+
if (this.isBoss) {
|
|
257
|
+
const p = String(this.$item.path || '');
|
|
258
|
+
const m = /^(\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+)/.exec(p);
|
|
259
|
+
const modsPath = m ? `${m[1]}/MODULES` : (this.$item.type === '$server' ? '/MODULES' : '');
|
|
260
|
+
if (modsPath) {
|
|
261
|
+
const info = await WORK.fetch(location.origin + modsPath, 'info', { deep: 6, branch: 'classes' }).catch(() => null);
|
|
262
|
+
this.moduleTree = Array.isArray(info?.items) ? info.items : [];
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
this.moduleTree = [];
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
this.moduleTree = [];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (!this.selectedNode) {
|
|
273
|
+
const firstLeaf = this.visibleLinkRows.find(r => !r.hasChildren) || this.visibleLinkRows[0]
|
|
274
|
+
|| (this.isBoss ? (this.visibleModuleRows.find(r => !r.hasChildren) || this.visibleModuleRows[0]) : null);
|
|
275
|
+
if (firstLeaf)
|
|
276
|
+
await this.selectNode(firstLeaf);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
this.error = String(e?.message || e);
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
this.loading = false;
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
async selectNode(row) {
|
|
287
|
+
if (!row?.path)
|
|
288
|
+
return;
|
|
289
|
+
this.selectedNode = row;
|
|
290
|
+
const item = await WORK.get_item(row.path).catch(() => null);
|
|
291
|
+
if (!item) {
|
|
292
|
+
this.frameUrl = '';
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const short = item.short || item.path || '';
|
|
296
|
+
if (short) {
|
|
297
|
+
try {
|
|
298
|
+
sessionStorage.setItem('work.form.nav:' + short, JSON.stringify({ noClassTree: true }));
|
|
299
|
+
}
|
|
300
|
+
catch { /* ignore */ }
|
|
301
|
+
}
|
|
302
|
+
const base = item.open_url;
|
|
303
|
+
if (!base) {
|
|
304
|
+
this.frameUrl = '';
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const sep = base.includes('?') ? '&' : '?';
|
|
308
|
+
this.frameUrl = `${base}${sep}noTree=1`;
|
|
309
|
+
},
|
|
310
|
+
}
|
|
@@ -368,6 +368,53 @@ ODA({is: 'oda-chat',
|
|
|
368
368
|
<div class="feed-mode-bar" ~if="showFeedModeToggle">
|
|
369
369
|
<button type="button" class="feed-mode-btn" ~class="{ active: feedMode === 'own' }" @tap="setFeedMode('own')" title="Мои записи из личного кабинета (/USERS)">Мои записи</button>
|
|
370
370
|
<button type="button" class="feed-mode-btn" ~class="{ active: feedMode === 'local' }" @tap="setFeedMode('local')" title="Местный лог открытой точки (доступно только BOSS)">Местный лог</button>
|
|
371
|
+
<button type="button" class="feed-mode-btn" ~class="{ active: feedMode === 'audit' }" @tap="setFeedMode('audit')" title="Взаимодействия пользователей и клиентов с Агентом (доступно только BOSS)">Взаимодействия</button>
|
|
372
|
+
</div>
|
|
373
|
+
<div ~if="feedMode === 'audit' && showFeedModeToggle" style="position:absolute;inset:44px 12px 68px 12px;z-index:11;background:var(--content-background,#fff);border:1px solid var(--border-color,#cbd5e1);border-radius:10px;box-shadow:0 6px 24px rgba(0,0,0,0.14);display:flex;overflow:hidden;">
|
|
374
|
+
<div style="width:260px;border-right:1px solid var(--subtle-border,#e2e8f0);overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:4px;background:var(--subtle-background,#f8fafc);">
|
|
375
|
+
<div style="font-size:12px;font-weight:700;padding:4px 6px;color:var(--muted-color);">Диалоги с Агентом ({{auditThreads.length}})</div>
|
|
376
|
+
<div ~if="!auditThreads.length" style="font-size:12.5px;color:var(--muted-color);padding:8px 6px;">Взаимодействий пока нет</div>
|
|
377
|
+
<div ~for="auditThreads" @tap="openAuditThread($for.item)" ~class="{ active: auditSelectedId === $for.item.id }" style="padding:7px 9px;border-radius:7px;cursor:pointer;border:1px solid var(--subtle-border,transparent);background:var(--content-background,#fff);font-size:12.5px;">
|
|
378
|
+
<div style="font-weight:600;display:flex;justify-content:space-between;gap:6px;">
|
|
379
|
+
<span>{{$for.item.peerLabel}}</span>
|
|
380
|
+
<span style="font-size:11px;opacity:0.7;">{{$for.item.messageCount}}</span>
|
|
381
|
+
</div>
|
|
382
|
+
<div ~if="$for.item.lastMessage" style="font-size:11.5px;color:var(--muted-color);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px;">{{$for.item.lastMessage.content || ($for.item.lastMessage.taskPath ? 'Задача' : 'Вложение')}}</div>
|
|
383
|
+
</div>
|
|
384
|
+
</div>
|
|
385
|
+
<div style="flex:1;display:flex;flex-direction:column;overflow-y:auto;padding:12px 16px;gap:8px;">
|
|
386
|
+
<div ~if="!auditSelectedId" style="color:var(--muted-color);font-size:13px;margin:auto;">Выберите пользователя слева для просмотра истории взаимодействия с Агентом</div>
|
|
387
|
+
<div ~for="auditMessages" style="padding:8px 11px;border-radius:8px;border:1px solid var(--subtle-border,#e2e8f0);background:var(--subtle-background,#f8fafc);font-size:13px;">
|
|
388
|
+
<div style="font-size:11px;color:var(--muted-color);display:flex;justify-content:space-between;margin-bottom:3px;">
|
|
389
|
+
<b>{{$for.item.sender === '$twin' ? 'Агент узла' : $for.item.sender}}</b>
|
|
390
|
+
<span>{{new Date($for.item.created).toLocaleString()}}</span>
|
|
391
|
+
</div>
|
|
392
|
+
<div style="white-space:pre-wrap;">{{$for.item.content || ($for.item.taskPath ? 'Задача: ' + $for.item.taskPath : '')}}</div>
|
|
393
|
+
<div ~if="$for.item.kind === 'approval'" style="display:flex;align-items:center;gap:8px;margin-top:6px;">
|
|
394
|
+
<span ~if="$for.item.meta?.status === 'approved'" style="font-size:11.5px;font-weight:700;color:#059669;">✓ Утверждено</span>
|
|
395
|
+
<span ~if="$for.item.meta?.status === 'rejected'" style="font-size:11.5px;font-weight:700;color:#dc2626;">✕ Отклонено</span>
|
|
396
|
+
<oda-button ~if="$for.item.meta?.status === 'pending'" icon="icons:check" info-invert @tap="resolveApprovalMsg($for.item, 'approve')">Утвердить</oda-button>
|
|
397
|
+
<oda-button ~if="$for.item.meta?.status === 'pending'" icon="icons:close" @tap="resolveApprovalMsg($for.item, 'reject')">Отклонить</oda-button>
|
|
398
|
+
</div>
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
<div class="feed-mode-bar" ~if="$item && $item.type !== '$user'" :style="showFeedModeToggle ? 'top: 42px;' : 'top: 8px;'">
|
|
403
|
+
<button type="button" class="feed-mode-btn" ~class="{ active: showParticipants }" @tap="toggleParticipants()" title="Участники и рабочие места подразделения">Участники ({{participantsCount}})</button>
|
|
404
|
+
</div>
|
|
405
|
+
<div ~if="showParticipants && $item && $item.type !== '$user'" style="position:absolute;top:44px;right:12px;z-index:12;width:280px;max-height:360px;overflow-y:auto;background:var(--content-background,#fff);border:1px solid var(--border-color,#cbd5e1);border-radius:10px;box-shadow:0 6px 20px rgba(0,0,0,0.16);padding:10px 12px;display:flex;flex-direction:column;gap:8px;font-size:12.5px;">
|
|
406
|
+
<div style="display:flex;align-items:center;justify-content:space-between;font-weight:700;">
|
|
407
|
+
<span>Участники ({{participantsCount}})</span>
|
|
408
|
+
<oda-button icon="icons:close" :icon-size="14" @tap="showParticipants = false"></oda-button>
|
|
409
|
+
</div>
|
|
410
|
+
<div ~if="!participantsList.length" style="color:var(--muted-color);">Назначенных участников нет</div>
|
|
411
|
+
<div ~for="participantsList" @tap="openParticipant($for.item)" style="display:flex;align-items:center;gap:8px;padding:5px 7px;border-radius:7px;cursor:pointer;border:1px solid var(--subtle-border,transparent);">
|
|
412
|
+
<item-icon :$item="$for.item" icon-size="22" default="icons:person"></item-icon>
|
|
413
|
+
<div style="flex:1;min-width:0;">
|
|
414
|
+
<div style="font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{$for.item.label || $for.item.id}}</div>
|
|
415
|
+
<div ~if="$for.item._placeLabel" style="font-size:11px;color:var(--muted-color);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{$for.item._placeLabel}}</div>
|
|
416
|
+
</div>
|
|
417
|
+
</div>
|
|
371
418
|
</div>
|
|
372
419
|
<chat-ribbon id="ribbon" :$item @chat-item-expanded="onCardExpanded($event)"></chat-ribbon>
|
|
373
420
|
<div class="mover" vertical hidden>
|
|
@@ -552,13 +599,56 @@ ODA({is: 'oda-chat',
|
|
|
552
599
|
}, 100);
|
|
553
600
|
this.$pdp?._hydrateModel?.();
|
|
554
601
|
this._geo();
|
|
602
|
+
this._bindChatSocket();
|
|
603
|
+
},
|
|
604
|
+
detached() {
|
|
605
|
+
if (this._onWsChatMsg && globalThis.WORK?.chatEvents) {
|
|
606
|
+
globalThis.WORK.chatEvents.removeEventListener('chat:message', this._onWsChatMsg);
|
|
607
|
+
this._onWsChatMsg = null;
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
_bindChatSocket() {
|
|
611
|
+
if (this._onWsChatMsg)
|
|
612
|
+
return;
|
|
613
|
+
globalThis.WORK.chatEvents ??= new EventTarget();
|
|
614
|
+
this._onWsChatMsg = (ev) => {
|
|
615
|
+
const d = ev?.detail;
|
|
616
|
+
const cur = this.$item;
|
|
617
|
+
if (!d || !cur)
|
|
618
|
+
return;
|
|
619
|
+
const curPath = String(cur.path || '/').replace(/\/+$/, '') || '/';
|
|
620
|
+
const hitTwin = d.kind === 'twin' && d.nodePath === curPath;
|
|
621
|
+
const hitDm = d.kind === 'dm' && cur.type === '$user' && (d.message?.sender === cur.id || d.message?.sender === WORK.uid);
|
|
622
|
+
if (hitTwin || hitDm) {
|
|
623
|
+
this.$('#ribbon')?.refreshFeed?.();
|
|
624
|
+
if (d.threadId)
|
|
625
|
+
cur.fetch?.('chat_mark_read', { threadId: d.threadId })?.catch?.(() => {});
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
globalThis.WORK.chatEvents.addEventListener('chat:message', this._onWsChatMsg);
|
|
555
629
|
},
|
|
556
630
|
focusInput(){
|
|
557
631
|
this.$('work-prompt-bar')?.focusInput();
|
|
558
632
|
},
|
|
559
633
|
focusedItem: null,
|
|
560
634
|
feedMode: 'own',
|
|
635
|
+
showParticipants: false,
|
|
561
636
|
_canLocalFeed: false,
|
|
637
|
+
get participantsList() {
|
|
638
|
+
return Array.isArray(this.$pdp?.deptUsers) ? this.$pdp.deptUsers : [];
|
|
639
|
+
},
|
|
640
|
+
get participantsCount() {
|
|
641
|
+
return this.participantsList.length;
|
|
642
|
+
},
|
|
643
|
+
toggleParticipants() {
|
|
644
|
+
this.showParticipants = !this.showParticipants;
|
|
645
|
+
},
|
|
646
|
+
openParticipant(u) {
|
|
647
|
+
if (!u?.id || typeof window?.execute !== 'function')
|
|
648
|
+
return;
|
|
649
|
+
this.showParticipants = false;
|
|
650
|
+
window.execute(u);
|
|
651
|
+
},
|
|
562
652
|
get showFeedModeToggle() {
|
|
563
653
|
return Boolean(this.$item && this.$item.type !== '$user' && this._canLocalFeed);
|
|
564
654
|
},
|
|
@@ -586,13 +676,65 @@ ODA({is: 'oda-chat',
|
|
|
586
676
|
this._canLocalFeed = false;
|
|
587
677
|
}
|
|
588
678
|
},
|
|
679
|
+
auditThreads: [],
|
|
680
|
+
auditSelectedId: '',
|
|
681
|
+
auditMessages: [],
|
|
589
682
|
setFeedMode(mode) {
|
|
590
|
-
const next = mode === 'local' && this.showFeedModeToggle ?
|
|
683
|
+
const next = (mode === 'local' || mode === 'audit') && this.showFeedModeToggle ? mode : 'own';
|
|
591
684
|
if (this.feedMode === next)
|
|
592
685
|
return;
|
|
593
686
|
this.feedMode = next;
|
|
687
|
+
if (next === 'audit') {
|
|
688
|
+
this.loadAuditThreads();
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
594
691
|
this.$('#ribbon')?.refreshFeed?.();
|
|
595
692
|
},
|
|
693
|
+
async loadAuditThreads() {
|
|
694
|
+
if (!this.$item?.fetch)
|
|
695
|
+
return;
|
|
696
|
+
try {
|
|
697
|
+
const list = await this.$item.fetch('chat_threads_list', { mode: 'audit' });
|
|
698
|
+
const raw = Array.isArray(list) ? list : [];
|
|
699
|
+
const uids = [...new Set(raw.flatMap(t => (t.participants || []).map(p => p.uid)).filter(Boolean))];
|
|
700
|
+
const users = uids.length && typeof WORK.usersByIds === 'function' ? await WORK.usersByIds(uids).catch(() => []) : [];
|
|
701
|
+
const nameMap = Object.fromEntries((users || []).filter(Boolean).map(u => [u.id, u.label || u.DATA?.label || u.id]));
|
|
702
|
+
this.auditThreads = raw.map(t => {
|
|
703
|
+
const peer = (t.participants || []).find(p => p.uid !== '$twin') || t.participants?.[0];
|
|
704
|
+
const roleHint = peer?.role === 'client' ? ' (Клиент)' : '';
|
|
705
|
+
return {
|
|
706
|
+
...t,
|
|
707
|
+
peerLabel: (nameMap[peer?.uid] || peer?.uid || t.title || t.id) + roleHint,
|
|
708
|
+
};
|
|
709
|
+
});
|
|
710
|
+
if (this.auditThreads.length && !this.auditSelectedId)
|
|
711
|
+
await this.openAuditThread(this.auditThreads[0]);
|
|
712
|
+
}
|
|
713
|
+
catch {
|
|
714
|
+
this.auditThreads = [];
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
async openAuditThread(thread) {
|
|
718
|
+
if (!thread?.id || !this.$item?.fetch)
|
|
719
|
+
return;
|
|
720
|
+
this.auditSelectedId = thread.id;
|
|
721
|
+
try {
|
|
722
|
+
const res = await this.$item.fetch('chat_messages_list', { threadId: thread.id, limit: 100 });
|
|
723
|
+
this.auditMessages = Array.isArray(res?.messages) ? res.messages : [];
|
|
724
|
+
}
|
|
725
|
+
catch {
|
|
726
|
+
this.auditMessages = [];
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
async resolveApprovalMsg(msg, action) {
|
|
730
|
+
if (!msg?.id || !this.auditSelectedId || !this.$item?.fetch)
|
|
731
|
+
return;
|
|
732
|
+
try {
|
|
733
|
+
await this.$item.fetch('chat_action', { threadId: this.auditSelectedId, messageId: msg.id, action });
|
|
734
|
+
await this.openAuditThread({ id: this.auditSelectedId });
|
|
735
|
+
}
|
|
736
|
+
catch { /* ignore */ }
|
|
737
|
+
},
|
|
596
738
|
async _ownCabinet() {
|
|
597
739
|
const uid = globalThis.WORK?.uid;
|
|
598
740
|
if (!uid || typeof globalThis.WORK?.get_item !== 'function')
|
|
@@ -754,6 +896,16 @@ ODA({is: 'oda-chat',
|
|
|
754
896
|
msgParams.includes = JSON.stringify(uploadedPaths);
|
|
755
897
|
await target.fetch('save_message', msgParams);
|
|
756
898
|
}
|
|
899
|
+
const chatTarget = this.$pdp.$item || target;
|
|
900
|
+
if (chatTarget?.fetch && (text || uploadedPaths.length)) {
|
|
901
|
+
const chatPayload = {
|
|
902
|
+
kind: this.$pdp.isPrivate ? 'dm' : 'twin',
|
|
903
|
+
...(this.$pdp.isPrivate ? { peerId: this.$pdp.$item?.id || WORK.uid } : {}),
|
|
904
|
+
message: text,
|
|
905
|
+
attachments: uploadedPaths.map(p => ({ path: p, name: p.split('/').pop() || 'file' })),
|
|
906
|
+
};
|
|
907
|
+
chatTarget.fetch('chat_send', {}, JSON.stringify(chatPayload))?.catch?.(() => {});
|
|
908
|
+
}
|
|
757
909
|
});
|
|
758
910
|
this.clear();
|
|
759
911
|
this.$('#ribbon')?.refreshFeed?.();
|
|
@@ -877,6 +1029,13 @@ ODA({is: 'oda-chat',
|
|
|
877
1029
|
}
|
|
878
1030
|
}
|
|
879
1031
|
if (path) {
|
|
1032
|
+
const threadItem = this.$pdp?.$item || item;
|
|
1033
|
+
threadItem?.fetch?.('chat_send', {}, JSON.stringify({
|
|
1034
|
+
kind: threadItem.type === '$user' ? 'dm' : 'twin',
|
|
1035
|
+
...(threadItem.type === '$user' ? { peerId: threadItem.id } : {}),
|
|
1036
|
+
message: text,
|
|
1037
|
+
taskPath: path,
|
|
1038
|
+
}))?.catch?.(() => {});
|
|
880
1039
|
this._awaitTaskPath = String(path);
|
|
881
1040
|
this._awaitTaskKey = taskKeyOf(path);
|
|
882
1041
|
await this._openCreated(path);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Мета хендлера form/chat. Визуалка — chat.js. */
|
|
2
2
|
export default {
|
|
3
3
|
icon: 'icons:question-answer',
|
|
4
|
+
label: 'Чат',
|
|
5
|
+
order: 1,
|
|
4
6
|
async showSettings() {
|
|
5
7
|
const { openMessengerSettingsDialog } = await import('/$server/$folder/lib/messenger-settings/messenger-settings.js');
|
|
6
8
|
return openMessengerSettingsDialog(this);
|