odant-work 1.0.95 → 1.0.97
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/license-base-WORK-PAK-BED9C508.lic.json.4714304.tmp +0 -0
- package/$server/$folder/$class/$ai/class.js +2 -0
- package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +1 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +4 -69
- package/$server/$folder/handlers/pages/form/$handler/class.js +29 -12
- package/$server/$folder/lib/explorer/explorer.js +6 -3
- package/$server/$folder/lib/menu/menu.js +49 -8
- package/oda/components/inputs/combobox/combobox.js +216 -14
- package/oda/components/inputs/input/input.js +26 -4
- package/oda/components/inputs/text/text.js +262 -88
- package/oda/components/layouts/editor-form/editor-form.js +12 -5
- package/oda/components/structure/controls-map.js +12 -3
- package/oda/components/structure/controls.js +1 -0
- package/package.json +1 -1
- package/sources/client/handler.js +10 -3
- package/sources/client.js +6 -1
- package/sources/host/auth-methods.js +73 -15
- package/sources/modules/rag/config.js +2 -2
- package/sources/modules/rag/embed-worker.js +10 -1
- package/sources/modules/rag/extract.js +3 -1
- package/sources/modules/rag/indexer.js +3 -3
- package/sources/modules/user-profile/user-profile.js +14 -3
|
File without changes
|
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
STATIC: [{
|
|
42
42
|
id: 'protocol',
|
|
43
43
|
type: 'String',
|
|
44
|
+
list: ['openai', 'anthropic', 'gigachat', 'yandex', 'ollama', 'local', 'custom'],
|
|
44
45
|
placeholder: 'openai | anthropic | gigachat | custom',
|
|
45
46
|
required: true,
|
|
46
47
|
}, {
|
|
@@ -85,6 +86,7 @@ export default {
|
|
|
85
86
|
}, {
|
|
86
87
|
id: 'effort',
|
|
87
88
|
type: 'String',
|
|
89
|
+
list: ['off', 'low', 'medium', 'high', 'xhigh'],
|
|
88
90
|
placeholder: 'off | low | medium | high | xhigh',
|
|
89
91
|
}, {
|
|
90
92
|
id: 'functionCalling',
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
imports: '~/lib//explorer.js',
|
|
5
5
|
extends: 'item-explorer',
|
|
6
6
|
template: /* html */`
|
|
7
|
-
<item-tree ~for="available" order="{{$for.index + 1}}"
|
|
7
|
+
<item-tree ~for="available" order="{{$for.index + 1}}" hidden slot='left-panel' show-status allow-focus hide-roots="1" hide-tops="0" :$item="$for.item" style="height: 0"></item-tree>
|
|
8
8
|
|
|
9
9
|
`,
|
|
10
10
|
list: ['/NODES'],
|
|
@@ -438,59 +438,6 @@ ODA({
|
|
|
438
438
|
}
|
|
439
439
|
</style>
|
|
440
440
|
<div class="back"></div>
|
|
441
|
-
<div class="feed-top-bar" ~if="showFeedModeToggle || ($item && $item.type !== '$user')">
|
|
442
|
-
<div class="feed-mode-bar" ~if="showFeedModeToggle">
|
|
443
|
-
<button type="button" class="feed-mode-btn" ~class="{ active: feedMode === 'dialog' }" @tap="setFeedMode('dialog')" title="Мой диалог и задачи с Агентом этого узла">Диалог</button>
|
|
444
|
-
<button type="button" class="feed-mode-btn" ~class="{ active: feedMode === 'local' }" @tap="setFeedMode('local')" title="Местный лог открытой точки (доступно только BOSS)">Местный лог</button>
|
|
445
|
-
<button type="button" class="feed-mode-btn" ~class="{ active: feedMode === 'audit' }" @tap="setFeedMode('audit')" title="Взаимодействия пользователей и клиентов с Агентом (доступно только BOSS)">Взаимодействия</button>
|
|
446
|
-
</div>
|
|
447
|
-
<div class="feed-mode-bar" ~if="$item && $item.type !== '$user'">
|
|
448
|
-
<button type="button" class="feed-mode-btn" ~class="{ active: showParticipants }" @tap="toggleParticipants()" title="Участники и рабочие места подразделения">Участники ({{participantsCount}})</button>
|
|
449
|
-
</div>
|
|
450
|
-
</div>
|
|
451
|
-
<div ~if="feedMode === 'audit' && showFeedModeToggle" class="audit-overlay">
|
|
452
|
-
<div class="audit-sidebar">
|
|
453
|
-
<div style="font-size:12px;font-weight:700;padding:4px 6px;color:var(--muted-color);">Диалоги с Агентом ({{auditThreads.length}})</div>
|
|
454
|
-
<div ~if="!auditThreads.length" style="font-size:12.5px;color:var(--muted-color);padding:8px 6px;">Взаимодействий пока нет</div>
|
|
455
|
-
<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;">
|
|
456
|
-
<div style="font-weight:600;display:flex;justify-content:space-between;gap:6px;">
|
|
457
|
-
<span>{{$for.item.peerLabel}}</span>
|
|
458
|
-
<span style="font-size:11px;opacity:0.7;">{{$for.item.messageCount}}</span>
|
|
459
|
-
</div>
|
|
460
|
-
<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>
|
|
461
|
-
</div>
|
|
462
|
-
</div>
|
|
463
|
-
<div class="audit-messages">
|
|
464
|
-
<div ~if="!auditSelectedId" style="color:var(--muted-color);font-size:13px;margin:auto;">Выберите пользователя для просмотра истории взаимодействия с Агентом</div>
|
|
465
|
-
<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;">
|
|
466
|
-
<div style="font-size:11px;color:var(--muted-color);display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;margin-bottom:3px;">
|
|
467
|
-
<b>{{$for.item.sender === '$twin' ? 'Агент узла' : $for.item.sender}}</b>
|
|
468
|
-
<span>{{new Date($for.item.created).toLocaleString()}}</span>
|
|
469
|
-
</div>
|
|
470
|
-
<div style="white-space:pre-wrap;word-break:break-word;">{{$for.item.content || ($for.item.taskPath ? 'Задача: ' + $for.item.taskPath : '')}}</div>
|
|
471
|
-
<div ~if="$for.item.kind === 'approval'" style="display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-top:6px;">
|
|
472
|
-
<span ~if="$for.item.meta?.status === 'approved'" style="font-size:11.5px;font-weight:700;color:#059669;">✓ Утверждено</span>
|
|
473
|
-
<span ~if="$for.item.meta?.status === 'rejected'" style="font-size:11.5px;font-weight:700;color:#dc2626;">✕ Отклонено</span>
|
|
474
|
-
<oda-button ~if="$for.item.meta?.status === 'pending'" icon="icons:check" info-invert @tap="resolveApprovalMsg($for.item, 'approve')">Утвердить</oda-button>
|
|
475
|
-
<oda-button ~if="$for.item.meta?.status === 'pending'" icon="icons:close" @tap="resolveApprovalMsg($for.item, 'reject')">Отклонить</oda-button>
|
|
476
|
-
</div>
|
|
477
|
-
</div>
|
|
478
|
-
</div>
|
|
479
|
-
</div>
|
|
480
|
-
<div ~if="showParticipants && $item && $item.type !== '$user'" class="participants-popover">
|
|
481
|
-
<div style="display:flex;align-items:center;justify-content:space-between;font-weight:700;">
|
|
482
|
-
<span>Участники ({{participantsCount}})</span>
|
|
483
|
-
<oda-button icon="icons:close" :icon-size="14" @tap="showParticipants = false"></oda-button>
|
|
484
|
-
</div>
|
|
485
|
-
<div ~if="!participantsList.length" style="color:var(--muted-color);">Назначенных участников нет</div>
|
|
486
|
-
<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);">
|
|
487
|
-
<item-icon :$item="$for.item" icon-size="22" default="icons:person"></item-icon>
|
|
488
|
-
<div style="flex:1;min-width:0;">
|
|
489
|
-
<div style="font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">{{$for.item.label || $for.item.id}}</div>
|
|
490
|
-
<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>
|
|
491
|
-
</div>
|
|
492
|
-
</div>
|
|
493
|
-
</div>
|
|
494
441
|
<chat-ribbon id="ribbon" :$item @chat-item-expanded="onCardExpanded($event)"></chat-ribbon>
|
|
495
442
|
<div class="mover" vertical hidden>
|
|
496
443
|
<oda-button :hidden="$('#ribbon').scrollTop < 0" content shadow icon="icons:chevron-right:270" @tap="$('#ribbon').scrollTop = -($('#ribbon').scrollHeight)"></oda-button>
|
|
@@ -801,7 +748,7 @@ ODA({
|
|
|
801
748
|
window.execute(u);
|
|
802
749
|
},
|
|
803
750
|
get showFeedModeToggle() {
|
|
804
|
-
return
|
|
751
|
+
return false;
|
|
805
752
|
},
|
|
806
753
|
async _refreshCanLocalFeed(item = this.$item) {
|
|
807
754
|
if (!item || item.type === '$user') {
|
|
@@ -2165,21 +2112,9 @@ ODA({
|
|
|
2165
2112
|
}
|
|
2166
2113
|
},
|
|
2167
2114
|
get logsSource() {
|
|
2168
|
-
//
|
|
2169
|
-
//
|
|
2170
|
-
|
|
2171
|
-
const uid = WORK.uid || '';
|
|
2172
|
-
const local = this.$pdp?.isLocalFeed ? {
|
|
2173
|
-
local: 1
|
|
2174
|
-
} : {};
|
|
2175
|
-
return Promise.resolve(this.$pdp.$item?.fetch?.('chatSource', {
|
|
2176
|
-
role,
|
|
2177
|
-
uid,
|
|
2178
|
-
...local
|
|
2179
|
-
})).then(path => {
|
|
2180
|
-
if (path && typeof path === 'string') return WORK.get_item(path);
|
|
2181
|
-
return this.$pdp.$item;
|
|
2182
|
-
});
|
|
2115
|
+
// Каждый узел хранит свою ленту (chatSource = this.path; серверный logs() сам вызывает _logSource),
|
|
2116
|
+
// поэтому берём прямо this.$pdp.$item без лишнего roundtrip и без сбоя get_item('/') на корне WORK.
|
|
2117
|
+
return this.$pdp?.$item || null;
|
|
2183
2118
|
},
|
|
2184
2119
|
get label() {
|
|
2185
2120
|
let date = new Date(this.day);
|
|
@@ -59,7 +59,7 @@ export default {
|
|
|
59
59
|
}
|
|
60
60
|
#tools item-node {
|
|
61
61
|
flex-shrink: 0;
|
|
62
|
-
border-radius:
|
|
62
|
+
border-radius: 8px;
|
|
63
63
|
padding: 3px 8px;
|
|
64
64
|
min-height: 30px;
|
|
65
65
|
align-items: center;
|
|
@@ -275,7 +275,16 @@ ODA({
|
|
|
275
275
|
$attr: true,
|
|
276
276
|
},
|
|
277
277
|
role: '',
|
|
278
|
-
subViewPath:
|
|
278
|
+
subViewPath: {
|
|
279
|
+
$def: '',
|
|
280
|
+
set(n) {
|
|
281
|
+
if (!n || !this.tabs?.length)
|
|
282
|
+
return;
|
|
283
|
+
const [firstSeg, ...restSegs] = String(n).split('/').filter(Boolean);
|
|
284
|
+
if (firstSeg && this.activeId !== firstSeg && this.tabs.some(t => t.id === firstSeg))
|
|
285
|
+
this.selectTab(firstSeg, restSegs.join('/'));
|
|
286
|
+
}
|
|
287
|
+
},
|
|
279
288
|
activeId: '',
|
|
280
289
|
depth: 0,
|
|
281
290
|
},
|
|
@@ -534,13 +543,13 @@ ODA({
|
|
|
534
543
|
}
|
|
535
544
|
else if (this.depth < 6 && (tab.layout || tab.DATA?.layout || (Array.isArray(tab.DATA?.items) && tab.DATA.items.length))) {
|
|
536
545
|
el = ODA.createComponent('work-subview-container', {
|
|
537
|
-
|
|
538
|
-
$item: this.$item,
|
|
539
|
-
$context: this.$item,
|
|
546
|
+
subViewPath: nestedSubView,
|
|
540
547
|
layout: tab.layout || tab.DATA?.layout || 'sidebar',
|
|
541
548
|
role: this.role,
|
|
542
|
-
subViewPath: nestedSubView,
|
|
543
549
|
depth: (this.depth || 0) + 1,
|
|
550
|
+
$handler: tab,
|
|
551
|
+
$item: this.$item,
|
|
552
|
+
$context: this.$item,
|
|
544
553
|
});
|
|
545
554
|
}
|
|
546
555
|
if (!el)
|
|
@@ -568,6 +577,8 @@ ODA({
|
|
|
568
577
|
const sub = nav.subView || nav.tab || '';
|
|
569
578
|
if (!sub)
|
|
570
579
|
return;
|
|
580
|
+
if (this._loadingPromise)
|
|
581
|
+
await this._loadingPromise.catch(() => {});
|
|
571
582
|
const [firstSeg, ...restSegs] = String(sub).split('/').filter(Boolean);
|
|
572
583
|
if (firstSeg && (this.tabs || []).some(t => t.id === firstSeg)) {
|
|
573
584
|
await this.selectTab(firstSeg, restSegs.join('/'));
|
|
@@ -753,7 +764,7 @@ ODA({is: 'work-form',
|
|
|
753
764
|
:rainbow="saving"
|
|
754
765
|
:error-invert="isViewChanged && !!saveError"
|
|
755
766
|
:success-invert="isViewChanged && !saveError"
|
|
756
|
-
style="position: relative; align-items: center;"
|
|
767
|
+
style="position: relative; align-items: center; padding: 4px; border-radius: 8px;"
|
|
757
768
|
horizontal
|
|
758
769
|
>
|
|
759
770
|
<oda-icon
|
|
@@ -2190,6 +2201,11 @@ ODA({is: 'work-form',
|
|
|
2190
2201
|
if (nav.view === 'objects' && nav.id) {
|
|
2191
2202
|
nav.view = 'objects/object';
|
|
2192
2203
|
}
|
|
2204
|
+
if (nav.view && String(nav.view).includes('/') && !nav.subView) {
|
|
2205
|
+
const [, ...navSubParts] = String(nav.view).split('/').filter(Boolean);
|
|
2206
|
+
if (navSubParts.length)
|
|
2207
|
+
nav.subView = navSubParts.join('/');
|
|
2208
|
+
}
|
|
2193
2209
|
// Сохраним позицию прокрутки ленты чата до изменения полосы вкладок (formTabs)
|
|
2194
2210
|
const curRib = this.view_control?.$?.('form-chat')?.$?.('oda-chat')?.$?.('#ribbon');
|
|
2195
2211
|
if (curRib && curRib.clientHeight > 0 && !curRib._wasHidden) {
|
|
@@ -2419,14 +2435,15 @@ ODA({is: 'work-form',
|
|
|
2419
2435
|
}
|
|
2420
2436
|
else if (n.layout || n.DATA?.layout || (Array.isArray(n.DATA?.items) && n.DATA.items.length)) {
|
|
2421
2437
|
el = ODA.createComponent('work-subview-container', {
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
$context: tabItem,
|
|
2425
|
-
slot: 'main',
|
|
2438
|
+
subViewPath: nav?.subView || '',
|
|
2439
|
+
_initialNav: nav || null,
|
|
2426
2440
|
layout: n.layout || n.DATA?.layout || 'sidebar',
|
|
2427
2441
|
role: this.activeRole,
|
|
2428
|
-
subViewPath: nav?.subView || '',
|
|
2429
2442
|
depth: 0,
|
|
2443
|
+
slot: 'main',
|
|
2444
|
+
$handler: n,
|
|
2445
|
+
$item: tabItem,
|
|
2446
|
+
$context: tabItem,
|
|
2430
2447
|
});
|
|
2431
2448
|
}
|
|
2432
2449
|
else {
|
|
@@ -3,7 +3,7 @@ export default {
|
|
|
3
3
|
imports: 'oda//app-layout.js, oda//tabs.js, oda//icon, oda//button, ~/lib//tree.js, ~/lib//node-explorer.js, ~/lib//consultant.js, ~/lib//class-picker.js, ~/lib//support.js',
|
|
4
4
|
extends: 'oda-app-layout',
|
|
5
5
|
template: /*html*/`
|
|
6
|
-
<item-tree order="0" slot='left-panel'
|
|
6
|
+
<item-tree order="0" slot='left-panel' :clean-structure="cleanStructure" :items-selector :show-size show-status show-users allow-focus :hide-roots :hide-tops :$item style="height: 0"></item-tree>
|
|
7
7
|
<item-consultant order="3" slot='left-panel' id="consultant" label="ИИ" icon="bootstrap:robot" :$item hidden style="height: 0"></item-consultant>
|
|
8
8
|
<div flex vertical slot='main' style="overflow: hidden; position: relative;">
|
|
9
9
|
<call-form ~if="showCall" id="callForm"></call-form>
|
|
@@ -737,13 +737,16 @@ export default {
|
|
|
737
737
|
return;
|
|
738
738
|
if ($item.type === '$handler') {
|
|
739
739
|
const rawHPath = String($item.path || $item.short || '');
|
|
740
|
-
const mForm = rawHPath.match(/^(.*?)\/(?:~|\$[^/]+(?:\/\$[^/]+)*)\/handlers\/pages\/form(?:\/(
|
|
740
|
+
const mForm = rawHPath.match(/^(.*?)\/(?:~|\$[^/]+(?:\/\$[^/]+)*)\/handlers\/pages\/form(?:\/(.+?))?(?:\/\$handler)?$/);
|
|
741
741
|
const rawSelf = $item[R]?.target || $item;
|
|
742
742
|
const ctx = (Object.prototype.hasOwnProperty.call(rawSelf, '$context') || Object.prototype.hasOwnProperty.call($item, '$context'))
|
|
743
743
|
? await $item.$context
|
|
744
744
|
: null;
|
|
745
745
|
if (ctx && ctx.type !== '$handler') {
|
|
746
|
-
const
|
|
746
|
+
const formView = mForm?.[2]
|
|
747
|
+
? mForm[2].split('/').filter(s => s && s[0] !== '$').join('/')
|
|
748
|
+
: '';
|
|
749
|
+
const viewId = formView || ($item.id && $item.id !== 'form' ? $item.id : '');
|
|
747
750
|
$item = ctx;
|
|
748
751
|
if (viewId)
|
|
749
752
|
nav = { ...(nav && typeof nav === 'object' ? nav : {}), view: viewId };
|
|
@@ -41,6 +41,14 @@ export default {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
.menu-loading {
|
|
45
|
+
@apply --horizontal;
|
|
46
|
+
align-items: center;
|
|
47
|
+
gap: 8px;
|
|
48
|
+
padding: 10px 12px;
|
|
49
|
+
font-size: 13px;
|
|
50
|
+
color: var(--muted-color);
|
|
51
|
+
}
|
|
44
52
|
</style>
|
|
45
53
|
<div ~if="showTools" class="tools-list">
|
|
46
54
|
<div ~for="tools" :disabled="Boolean($for.item.disabled)" @pointerdown.stop.prevent="executeTool($for.item, $event)" class="tool">
|
|
@@ -49,6 +57,10 @@ export default {
|
|
|
49
57
|
<span class="tool-shortcut" ~if="$for.item.shortcut">{{$for.item.shortcut}}</span>
|
|
50
58
|
</div>
|
|
51
59
|
</div>
|
|
60
|
+
<div ~if="showHandlers && !handlersRoot && _loadingHandlers" class="menu-loading">
|
|
61
|
+
<oda-icon icon="spinners:3-dots-scale" icon-size="16"></oda-icon>
|
|
62
|
+
<span>Загрузка…</span>
|
|
63
|
+
</div>
|
|
52
64
|
<item-tree ~if="showHandlers" hide-files @resize :hide-tops :hide-roots :prefetch-deep="0" expander-order="1" expand-all :$item="handlersRoot" :allow-categories></item-tree>
|
|
53
65
|
`,
|
|
54
66
|
get $context(){
|
|
@@ -69,24 +81,53 @@ export default {
|
|
|
69
81
|
get showHandlers() {
|
|
70
82
|
return ['handlers', 'both'].includes(this.mode);
|
|
71
83
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
84
|
+
_loadingHandlers: false,
|
|
85
|
+
handlersRoot: null,
|
|
86
|
+
$item: {
|
|
87
|
+
$def: null,
|
|
88
|
+
set(n) {
|
|
89
|
+
this._loadHandlersRoot(n);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
attached() {
|
|
93
|
+
if (this.$item && !this.handlersRoot && !this._loadingHandlers)
|
|
94
|
+
this._loadHandlersRoot(this.$item);
|
|
95
|
+
},
|
|
96
|
+
async _loadHandlersRoot($item = this.$item) {
|
|
97
|
+
if (!$item) {
|
|
98
|
+
this.handlersRoot = null;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const seq = (this._handlersSeq = (this._handlersSeq || 0) + 1);
|
|
102
|
+
this._loadingHandlers = true;
|
|
76
103
|
const stampContext = (node) => {
|
|
77
104
|
if (!node || typeof node !== 'object')
|
|
78
105
|
return node;
|
|
79
106
|
node.$context = $item;
|
|
80
107
|
if (Array.isArray(node.items)) {
|
|
81
108
|
node.items = node.items
|
|
82
|
-
.filter(ch => ch && !(ch.hidden || ch.
|
|
109
|
+
.filter(ch => ch && !(ch.DATA?.hidden === true || (ch.type === '$handler' && ch.hidden === true)))
|
|
83
110
|
.map(ch => stampContext(ch));
|
|
84
111
|
}
|
|
85
112
|
return node;
|
|
86
113
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
$item.
|
|
114
|
+
try {
|
|
115
|
+
// роль должна быть известна до запроса: без неё фильтр по роли не сработает
|
|
116
|
+
await Promise.resolve($item.ensureRole?.());
|
|
117
|
+
const root = await $item.fetch('handlers', { path: this.path });
|
|
118
|
+
if (seq !== this._handlersSeq)
|
|
119
|
+
return;
|
|
120
|
+
const stamped = stampContext(root);
|
|
121
|
+
this.handlersRoot = stamped;
|
|
122
|
+
const tree = this.$?.('item-tree');
|
|
123
|
+
if (tree && tree.$item !== stamped)
|
|
124
|
+
tree.$item = stamped;
|
|
125
|
+
this.async?.(() => this.parentElement?.layout?.(true), 30);
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
if (seq === this._handlersSeq)
|
|
129
|
+
this._loadingHandlers = false;
|
|
130
|
+
}
|
|
90
131
|
},
|
|
91
132
|
get tools(){
|
|
92
133
|
return this.customTools || this.$item?.tools || [];
|
|
@@ -1,39 +1,241 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* oda-combobox-input —
|
|
2
|
+
* oda-combobox-input — ввод с выпадающим списком вариантов (dropdown + свободный/фильтруемый ввод).
|
|
3
|
+
* Варианты из items / list / field.items / field.list / field.options.
|
|
3
4
|
* Текст совпал с подписью варианта — value = значение варианта; иначе value = текст (allowOther) или ошибка.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
ODA({
|
|
7
8
|
is: 'oda-combobox-input',
|
|
8
|
-
imports: 'oda//input.js, oda//button.js',
|
|
9
|
+
imports: 'oda//input.js, oda//button.js, oda//icon.js',
|
|
9
10
|
extends: 'oda-options-input',
|
|
10
11
|
template: /*html*/`
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
<style>
|
|
13
|
+
.dd-toggle {
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
transition: transform .15s ease;
|
|
16
|
+
}
|
|
17
|
+
.dd-toggle.open {
|
|
18
|
+
transform: rotate(180deg);
|
|
19
|
+
}
|
|
20
|
+
.dd-menu {
|
|
21
|
+
margin: 0;
|
|
22
|
+
padding: 4px;
|
|
23
|
+
border: 1px solid var(--subtle-border, var(--border-color, #d0d7de));
|
|
24
|
+
border-radius: var(--radius-s, 8px);
|
|
25
|
+
background: var(--content-background, #fff);
|
|
26
|
+
color: var(--content-color, inherit);
|
|
27
|
+
box-shadow: var(--elevation-3, 0 8px 24px rgba(0, 0, 0, .14));
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
overflow-y: auto;
|
|
30
|
+
max-height: 260px;
|
|
31
|
+
font: inherit;
|
|
32
|
+
}
|
|
33
|
+
.dd-menu:popover-open {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
gap: 2px;
|
|
37
|
+
}
|
|
38
|
+
.dd-item {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: 8px;
|
|
42
|
+
padding: 6px 10px;
|
|
43
|
+
border-radius: var(--radius-xs, 6px);
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
min-width: 0;
|
|
46
|
+
user-select: none;
|
|
47
|
+
}
|
|
48
|
+
.dd-item:hover,
|
|
49
|
+
.dd-item.active {
|
|
50
|
+
background: var(--subtle-background, rgba(0, 0, 0, .05));
|
|
51
|
+
}
|
|
52
|
+
.dd-item.selected {
|
|
53
|
+
background: var(--accent-soft, rgba(37, 99, 235, .12));
|
|
54
|
+
color: var(--accent-color, inherit);
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
}
|
|
57
|
+
.dd-item.disabled {
|
|
58
|
+
opacity: .45;
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
}
|
|
61
|
+
.dd-label {
|
|
62
|
+
flex: 1 1 auto;
|
|
63
|
+
min-width: 0;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
text-overflow: ellipsis;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
}
|
|
68
|
+
.dd-desc {
|
|
69
|
+
font-size: smaller;
|
|
70
|
+
opacity: .65;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
text-overflow: ellipsis;
|
|
73
|
+
white-space: nowrap;
|
|
74
|
+
}
|
|
75
|
+
.dd-empty {
|
|
76
|
+
padding: 8px 10px;
|
|
77
|
+
font-size: smaller;
|
|
78
|
+
opacity: .65;
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
81
|
+
<input class="control" part="control" :value="text" :placeholder="placeholderText"
|
|
82
|
+
:readonly="isReadonly" :disabled :required="isRequired"
|
|
83
|
+
@input="onInput($this.value)" @keydown="onKey($event)">
|
|
84
|
+
<oda-button ~if="!isEmpty && !isReadonly && !disabled" class="affix" icon="icons:close" :icon-size="14" title="Очистить" @tap.stop="clearValue()"></oda-button>
|
|
85
|
+
<oda-button ~if="options.length && !isReadonly && !disabled" class="affix dd-toggle" ~class="{ open: menuOpen }"
|
|
86
|
+
icon="icons:arrow-drop-down" :icon-size="18" title="Выбрать из списка"
|
|
87
|
+
@down.prevent.stop @tap.stop="toggleMenu()"></oda-button>
|
|
88
|
+
<div class="dd-menu" popover="auto" @toggle="onPopoverToggle($event)">
|
|
89
|
+
<div ~for="visibleOptions" style="display: contents">
|
|
90
|
+
<div class="dd-item"
|
|
91
|
+
~class="{ selected: isSelectedOption($for.item), active: $for.index === activeIndex, disabled: !!$for.item.disabled }"
|
|
92
|
+
@pointerdown.prevent="pickOption($for.item)">
|
|
93
|
+
<oda-icon ~if="$for.item.icon" :icon="$for.item.icon" :icon-size="16"></oda-icon>
|
|
94
|
+
<span class="dd-label">{{$for.item.label}}</span>
|
|
95
|
+
<span ~if="$for.item.description || $for.item.desc" class="dd-desc">{{$for.item.description || $for.item.desc}}</span>
|
|
96
|
+
<oda-icon ~if="isSelectedOption($for.item)" icon="icons:check" :icon-size="14"></oda-icon>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
<div ~if="!visibleOptions.length" class="dd-empty">Нет совпадений</div>
|
|
100
|
+
</div>
|
|
17
101
|
`,
|
|
18
102
|
$public: {
|
|
19
|
-
allowOther: true
|
|
103
|
+
allowOther: true,
|
|
20
104
|
},
|
|
21
|
-
/**
|
|
22
|
-
* value не отражается в атрибут: сброс (undefined) возвращался бы из `attributeChangedCallback` как null,
|
|
23
|
-
* а число варианта — строкой. `$type: String` тут нельзя: значение варианта бывает числом.
|
|
24
|
-
* Начальный атрибут value="…" при создании по-прежнему применяется.
|
|
25
|
-
*/
|
|
26
105
|
value: {
|
|
27
106
|
$public: false
|
|
28
107
|
},
|
|
108
|
+
menuOpen: false,
|
|
109
|
+
filterText: '',
|
|
110
|
+
activeIndex: -1,
|
|
29
111
|
/** подпись варианта для значения или само значение */
|
|
30
112
|
get text() {
|
|
31
113
|
return this.isEmpty ? '' : this.optionOf(this.value)?.label ?? String(this.value);
|
|
32
114
|
},
|
|
115
|
+
get visibleOptions() {
|
|
116
|
+
const list = this.options || [];
|
|
117
|
+
const q = String(this.filterText || '').trim().toLowerCase();
|
|
118
|
+
if (!q)
|
|
119
|
+
return list;
|
|
120
|
+
const matched = list.filter(o =>
|
|
121
|
+
String(o.label ?? '').toLowerCase().includes(q)
|
|
122
|
+
|| String(o.value ?? '').toLowerCase().includes(q)
|
|
123
|
+
);
|
|
124
|
+
return matched.length ? matched : list;
|
|
125
|
+
},
|
|
126
|
+
isSelectedOption(o) {
|
|
127
|
+
return !this.isEmpty && o && String(o.value) === String(this.value);
|
|
128
|
+
},
|
|
33
129
|
enter(text) {
|
|
34
130
|
const o = this.options.find(o => o.label === text);
|
|
35
131
|
this.value = o ? o.value : text || undefined;
|
|
36
132
|
},
|
|
133
|
+
onInput(text) {
|
|
134
|
+
this.filterText = text;
|
|
135
|
+
this.enter(text);
|
|
136
|
+
if (this.options.length && !this.menuOpen)
|
|
137
|
+
this.openMenu(false);
|
|
138
|
+
},
|
|
139
|
+
clearValue() {
|
|
140
|
+
this.filterText = '';
|
|
141
|
+
this.enter('');
|
|
142
|
+
this.closeMenu();
|
|
143
|
+
},
|
|
144
|
+
toggleMenu() {
|
|
145
|
+
if (this.menuOpen)
|
|
146
|
+
this.closeMenu();
|
|
147
|
+
else
|
|
148
|
+
this.openMenu(true);
|
|
149
|
+
},
|
|
150
|
+
openMenu(showAll = true) {
|
|
151
|
+
if (this.isReadonly || this.disabled || !this.options.length)
|
|
152
|
+
return;
|
|
153
|
+
if (showAll)
|
|
154
|
+
this.filterText = '';
|
|
155
|
+
const menu = this.$('.dd-menu');
|
|
156
|
+
if (!menu)
|
|
157
|
+
return;
|
|
158
|
+
const rect = this.getBoundingClientRect();
|
|
159
|
+
const vw = window.innerWidth || 0;
|
|
160
|
+
const vh = window.innerHeight || 0;
|
|
161
|
+
const spaceBelow = vh - rect.bottom - 8;
|
|
162
|
+
const spaceAbove = rect.top - 8;
|
|
163
|
+
const maxH = Math.min(260, Math.max(120, Math.max(spaceBelow, spaceAbove)));
|
|
164
|
+
const openUp = spaceBelow < 160 && spaceAbove > spaceBelow;
|
|
165
|
+
menu.style.position = 'fixed';
|
|
166
|
+
menu.style.left = Math.max(8, Math.min(rect.left, vw - Math.max(rect.width, 160) - 8)) + 'px';
|
|
167
|
+
menu.style.width = Math.max(rect.width, 140) + 'px';
|
|
168
|
+
menu.style.maxHeight = maxH + 'px';
|
|
169
|
+
if (openUp) {
|
|
170
|
+
menu.style.top = 'auto';
|
|
171
|
+
menu.style.bottom = Math.max(8, vh - rect.top + 4) + 'px';
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
menu.style.bottom = 'auto';
|
|
175
|
+
menu.style.top = Math.min(vh - 48, rect.bottom + 4) + 'px';
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
if (!menu.matches(':popover-open'))
|
|
179
|
+
menu.showPopover?.();
|
|
180
|
+
}
|
|
181
|
+
catch { /* ignore */ }
|
|
182
|
+
this.menuOpen = true;
|
|
183
|
+
const curIdx = this.visibleOptions.findIndex(o => this.isSelectedOption(o));
|
|
184
|
+
this.activeIndex = curIdx;
|
|
185
|
+
},
|
|
186
|
+
closeMenu() {
|
|
187
|
+
const menu = this.$('.dd-menu');
|
|
188
|
+
try {
|
|
189
|
+
if (menu?.matches?.(':popover-open'))
|
|
190
|
+
menu.hidePopover?.();
|
|
191
|
+
}
|
|
192
|
+
catch { /* ignore */ }
|
|
193
|
+
this.menuOpen = false;
|
|
194
|
+
this.activeIndex = -1;
|
|
195
|
+
},
|
|
196
|
+
onPopoverToggle(e) {
|
|
197
|
+
const open = e?.newState === 'open';
|
|
198
|
+
this.menuOpen = open;
|
|
199
|
+
if (!open) {
|
|
200
|
+
this.activeIndex = -1;
|
|
201
|
+
this.filterText = '';
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
pickOption(o) {
|
|
205
|
+
if (!o || o.disabled)
|
|
206
|
+
return;
|
|
207
|
+
this.filterText = '';
|
|
208
|
+
this.value = o.value;
|
|
209
|
+
this.closeMenu();
|
|
210
|
+
this.focus();
|
|
211
|
+
},
|
|
212
|
+
onKey(e) {
|
|
213
|
+
if (this.isReadonly || this.disabled || !this.options.length)
|
|
214
|
+
return;
|
|
215
|
+
if (e.key === 'ArrowDown') {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
if (!this.menuOpen)
|
|
218
|
+
this.openMenu(true);
|
|
219
|
+
else if (this.visibleOptions.length)
|
|
220
|
+
this.activeIndex = (this.activeIndex + 1) % this.visibleOptions.length;
|
|
221
|
+
}
|
|
222
|
+
else if (e.key === 'ArrowUp' && this.menuOpen && this.visibleOptions.length) {
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
this.activeIndex = (this.activeIndex - 1 + this.visibleOptions.length) % this.visibleOptions.length;
|
|
225
|
+
}
|
|
226
|
+
else if (e.key === 'Enter' && this.menuOpen && this.activeIndex >= 0) {
|
|
227
|
+
const item = this.visibleOptions[this.activeIndex];
|
|
228
|
+
if (item && !item.disabled) {
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
this.pickOption(item);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else if (e.key === 'Escape' && this.menuOpen) {
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
e.stopPropagation();
|
|
236
|
+
this.closeMenu();
|
|
237
|
+
}
|
|
238
|
+
},
|
|
37
239
|
get validationErrors() {
|
|
38
240
|
return this.isOther && !this.allowOther ? ['Выберите значение из списка'] : [];
|
|
39
241
|
}
|
|
@@ -193,21 +193,43 @@ ODA({
|
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
+
export function normalizeOptions(raw) {
|
|
197
|
+
if (!raw)
|
|
198
|
+
return [];
|
|
199
|
+
let arr;
|
|
200
|
+
if (Array.isArray(raw)) {
|
|
201
|
+
arr = raw;
|
|
202
|
+
}
|
|
203
|
+
else if (typeof raw === 'string') {
|
|
204
|
+
const sep = raw.includes('|') ? '|' : (raw.includes(';') ? ';' : ',');
|
|
205
|
+
arr = raw.split(sep).map(s => s.trim()).filter(Boolean);
|
|
206
|
+
}
|
|
207
|
+
else if (typeof raw === 'object') {
|
|
208
|
+
arr = Object.entries(raw).map(([value, label]) => ({ value, label: label == null ? String(value) : String(label) }));
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
return arr.map(i => i !== null && typeof i === 'object'
|
|
214
|
+
? { ...i, value: i.value ?? i.id ?? i.label, label: i.label ?? String(i.value ?? i.id ?? '') }
|
|
215
|
+
: { value: i, label: String(i) });
|
|
216
|
+
}
|
|
217
|
+
|
|
196
218
|
ODA({
|
|
197
219
|
is: 'oda-options-input',
|
|
198
220
|
extends: 'oda-input',
|
|
199
221
|
$public: {
|
|
200
|
-
/** варианты: значения или {value, label, icon, description, disabled}; иначе field.items / field.options */
|
|
222
|
+
/** варианты: значения или {value, label, icon, description, disabled}; иначе list / field.items / field.list / field.options */
|
|
201
223
|
items: {
|
|
202
224
|
$type: Array
|
|
203
225
|
},
|
|
226
|
+
/** настроечный список вариантов (массив, строка с разделителем | / ; / , или объект) — включает выпадающий выбор */
|
|
227
|
+
list: undefined,
|
|
204
228
|
/** разрешить своё значение вне списка */
|
|
205
229
|
allowOther: false
|
|
206
230
|
},
|
|
207
231
|
get options() {
|
|
208
|
-
return (this.items ?? this.field?.items ?? this.field?.
|
|
209
|
-
? { ...i, value: i.value ?? i.id ?? i.label, label: i.label ?? String(i.value ?? i.id ?? '') }
|
|
210
|
-
: { value: i, label: String(i) });
|
|
232
|
+
return normalizeOptions(this.items ?? this.list ?? this.field?.items ?? this.field?.list ?? this.field?.options);
|
|
211
233
|
},
|
|
212
234
|
optionOf(value) {
|
|
213
235
|
return this.options.find(o => String(o.value) === String(value));
|