odant-work 1.0.94 → 1.0.96
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 +10 -10
- 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/handlers/pages/form/$handler/class.js +91 -11
- package/$server/$folder/lib/explorer/explorer.js +1 -1
- 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 +3 -3
- package/sources/host/auth-methods.js +16 -2
- package/sources/modules/license/index.js +53 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.95",
|
|
4
4
|
"createdAt": 1795100682741,
|
|
5
|
-
"updatedAt":
|
|
5
|
+
"updatedAt": 1796203903734,
|
|
6
6
|
"files": {
|
|
7
7
|
"$server/$folder/$class/$ai/class.js": "eb8a308eca37fa674530a548df981700b363186043fba6c47ae6e335e4cf5c94",
|
|
8
8
|
"$server/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js": "2aafef4d16bf6f893948d4f2b22e63ad9aed8f73af036a75e2385ffba5772293",
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
"$server/$folder/handlers/methods/create/progress.md": "d7a61baaf02afda1f0b65883a809ceed4e59fe5ff01b6471806d3f2b08ef27cf",
|
|
216
216
|
"$server/$folder/handlers/methods/help/$handler/class.js": "ff54bf976cbdc846d7c1b46ff12b111e99a3f4831240a4e420b73c98c0355a5c",
|
|
217
217
|
"$server/$folder/handlers/methods/info/$handler/class.js": "8752efb28abdcfad4e8ce56cfebcd8bb09ec0735cba7b84156d248bfcb0f9db0",
|
|
218
|
-
"$server/$folder/handlers/pages/form/$handler/class.js": "
|
|
218
|
+
"$server/$folder/handlers/pages/form/$handler/class.js": "118e274110cbe6ffca0ce5806a13c3c7c6ac1061aaee3e26591622b52875ebd3",
|
|
219
219
|
"$server/$folder/handlers/pages/form/folder/$handler/class.js": "71664da71a7a92806e50c2faf62786b28014073c56706e5cbb93420e20f10716",
|
|
220
220
|
"$server/$folder/handlers/readme.md": "d810e5ef204cd29a5da09e0a9b30a1c07628243f38e9821803dd8c6f16311080",
|
|
221
221
|
"$server/$folder/lib/calendar-form/calendar-form.js": "dbfc0f7014659222ad3b3519d8e6c79bd5567102ab287096d59d015d66015148",
|
|
@@ -294,7 +294,7 @@
|
|
|
294
294
|
"MODULES/Данные/KLADR/Регионы/$catalog/class.js": "8010bcfe5f1eb81703cac27832e1f4eb83d148764b9bdfde5ea4002cb6435f3e",
|
|
295
295
|
"MODULES/Данные/KLADR/Улицы/$catalog/class.js": "cfbadc196d3db71802e2e3dab492957ce18aaa789870040b3e24d3038a894860",
|
|
296
296
|
"MODULES/Данные/RuCalendar/$module/class.js": "3a8824da32079be2c614de079bf8a8ad3a8bfa5eb9724782398d9f015c566199",
|
|
297
|
-
"MODULES/Данные/Weather/$module/class.js": "
|
|
297
|
+
"MODULES/Данные/Weather/$module/class.js": "52987470a58116df3e57e30418d2e32d7371b9effef34be83a00435c73fa7d2f",
|
|
298
298
|
"MODULES/Коннекторы/1C/$module/class.js": "a08d8c2387f6193a670bfe0aefbd5d2e8d233e456c2ad806e5c7b9a7e8e198df",
|
|
299
299
|
"MODULES/Коннекторы/2GIS/$mcp/class.js": "c2f2e75e1911b3dff04a66c785a5b9fde6ca7b84a31dd33dadc0e2cdfd627f91",
|
|
300
300
|
"MODULES/Коннекторы/2GIS/$mcp/readme.md": "ee03fb6383d51e4a59539f238c193225b3bf2037ac2203546d4b351b2f9cbd8f",
|
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
"MODULES/Коннекторы/Telegram/$module/class.js": "374d9644ed880f32d4e43e4ccdea290a3a3774f8c0096091ca7da502f94f99f2",
|
|
303
303
|
"MODULES/Коннекторы/YandexDisk/$module/class.js": "4c52309f0b2256f8dcc791b3cf04cb5b020db451dd5791a7ad72654358c39933",
|
|
304
304
|
"MODULES/Маркетплейсы/Ozon/$mcp/class.js": "f7e0e15e34da7f5bfc3fbcf61b11ffaf957911316efea35e43e68c599aecdbc4",
|
|
305
|
-
"MODULES/Маркетплейсы/Wildberries/$mcp/class.js": "
|
|
305
|
+
"MODULES/Маркетплейсы/Wildberries/$mcp/class.js": "ad74dd811d115526b53faef5adda9b9e08ad4e3e51206baec7bb8efcb2fc643a",
|
|
306
306
|
"MODULES/Маркетплейсы/YandexMarket/$mcp/class.js": "0bee74d35393e5640111ef1b30de8575ab2682e32b0fbdfef5341c8d59c5170c",
|
|
307
307
|
"MODULES/Модели/GigaChat/$provider/$folder/$class/$ai/class.js": "18f26a4811981973cbf5f90584177028c44ce04fe9ecf4b5e546dccdbbd330d8",
|
|
308
308
|
"MODULES/Модели/GigaChat/$provider/class.js": "20827bd6ba60a9ea93ff7bacee190d6600de4294463831f55a5f5cd8218c08fa",
|
|
@@ -843,8 +843,8 @@
|
|
|
843
843
|
"oda/tools/tester/index.html": "58be4351a9733d2cff91347f6da63d8c60eb32bd2207d9269b9338eb33836e87",
|
|
844
844
|
"oda/tools/tester/readme.md": "ce7e48a8f1a53b6016664ea8e4f6422904bfecdf475cdae65be863f9620ed849",
|
|
845
845
|
"oda/tools/tester/tester.js": "afe9e21081092faf61c515ad934eb8f024a3e89568cc192c157e8afd556663da",
|
|
846
|
-
"package-lock.json": "
|
|
847
|
-
"package.json": "
|
|
846
|
+
"package-lock.json": "2e720c030616fb5f22cba3a795300a18909dd785a5943aaa03378af9d124316a",
|
|
847
|
+
"package.json": "9ce7e63869dde14053438301793adcd13220fbe2810df2a6e3db2e09e57e6686",
|
|
848
848
|
"run.mjs": "96274369c2ab29f293f787fbc1e371fc7e661f9577dccb2d1c245a866d193c77",
|
|
849
849
|
"sources/client.js": "a1fe12500376bae4d354366f483ae62a217dbbbdc6228ed355e28298855ccb77",
|
|
850
850
|
"sources/client/class.js": "ddd2862e2c78d337360a16a26f7af2ad28f603d58f480f39a0cc82192173050a",
|
|
@@ -866,7 +866,7 @@
|
|
|
866
866
|
"sources/data/objects.js": "58a7682c51c840536c5fe1297f4d402b899441286305425e6ceba3312ddcb3f3",
|
|
867
867
|
"sources/data/posting.js": "6595bb9ec632539ae7629504db327d25a491e61c1cdc598bb43d08ea0d45548d",
|
|
868
868
|
"sources/data/print.js": "e60f4fd7d10d6161a40d4fa08165dfb3c343e5ad00f0bddcec24a86a9cb299fd",
|
|
869
|
-
"sources/data/progress.md": "
|
|
869
|
+
"sources/data/progress.md": "088dad92cf3894032823912cb4897da7656b5fbf95f1c9730dbb509e7df0001b",
|
|
870
870
|
"sources/data/readme.md": "2ab6c0f2e2b30fc00714e3deaa2ad261f370b9b8917b96d5b1b8116933c4948b",
|
|
871
871
|
"sources/data/reports.js": "0330f404860fe2589a7d46a2f0fe690ca23249bd841a062a26718742d4fd11d6",
|
|
872
872
|
"sources/data/schema.js": "7b5300961966570d451c97d2cf18667f56116dd1dec5ccea644cb0b83e29401d",
|
|
@@ -874,7 +874,7 @@
|
|
|
874
874
|
"sources/data/sql-inspector.js": "11d83cf3282e42d7f39954bb7bf6ea1462f845f05a5df7444819e2a7de715095",
|
|
875
875
|
"sources/data/time.js": "cb34c1137685e83265938bb007859dfc1fca3548588d1663ee01e1affc87a09a",
|
|
876
876
|
"sources/data/workspace.js": "90a2dd4122d059d2abfe063e7c4153cd1078324f606dfd57e23c538369424e7e",
|
|
877
|
-
"sources/host/auth-methods.js": "
|
|
877
|
+
"sources/host/auth-methods.js": "a7162c89bb8519be6d2db5d292475abadcb990d8ede4a8eec543d6a44566ca15",
|
|
878
878
|
"sources/host/auto-updater.js": "63feae6db03e6ac330a9008278a61f2e631843a2cc2cb8c86c12f7d16e3e1e73",
|
|
879
879
|
"sources/host/babel-merge.js": "492059ca639c9673151ce579bb97f70fa202379db0e6e0be95faa63d64a3085b",
|
|
880
880
|
"sources/host/config.js": "f41058d2ef46afc0ac5e262a0f31064d3288ab3794c4d45c0761498e775f60ae",
|
|
@@ -984,7 +984,7 @@
|
|
|
984
984
|
"sources/modules/lan/scan.js": "bbc92272776b198c09f987af8c09c635f48341ac3311127ec958751f01570f82",
|
|
985
985
|
"sources/modules/lan/store.js": "fed7da49bbf508216b51ea3bc2b30e1e1ff5261edc3cbee57690d4e3130ae9e7",
|
|
986
986
|
"sources/modules/lan/subnet.js": "3d95231b206ba2ddc5fb8cff3002ca2c980a4e856e18cb505c24e7d81d643684",
|
|
987
|
-
"sources/modules/license/index.js": "
|
|
987
|
+
"sources/modules/license/index.js": "d798a6e529e607bb9839ff2902b5a8c1968601addad6c44f1f7b86f43bcf7206",
|
|
988
988
|
"sources/modules/mcp-marketplaces/mcp-stdio.js": "db9e757d3f35803dc8d1ba25614040a0c5b1efacd405591d0a5f901c9a51074a",
|
|
989
989
|
"sources/modules/mcp-marketplaces/ozon.js": "ab543b966a16cd9aa592b03237da0c43646fd7cbb1deef4d8da66f919a634b7f",
|
|
990
990
|
"sources/modules/mcp-marketplaces/wildberries.js": "a3d94623e93dc8ca75f5a5e42794568762c84392b29f7521b9464161ef577380",
|
|
@@ -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'],
|
|
@@ -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;
|
|
@@ -170,6 +170,17 @@ ODA({
|
|
|
170
170
|
height: 22px;
|
|
171
171
|
margin: 0 2px;
|
|
172
172
|
}
|
|
173
|
+
.sub-row {
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-direction: column;
|
|
176
|
+
width: 100%;
|
|
177
|
+
flex-shrink: 0;
|
|
178
|
+
}
|
|
179
|
+
:host([layout="tabs"]) .sub-row {
|
|
180
|
+
width: auto;
|
|
181
|
+
flex-direction: row;
|
|
182
|
+
align-items: center;
|
|
183
|
+
}
|
|
173
184
|
.sub-btn {
|
|
174
185
|
@apply --horizontal;
|
|
175
186
|
align-items: center;
|
|
@@ -231,6 +242,11 @@ ODA({
|
|
|
231
242
|
height: 22px;
|
|
232
243
|
margin: 0 2px;
|
|
233
244
|
}
|
|
245
|
+
.sub-row {
|
|
246
|
+
width: auto;
|
|
247
|
+
flex-direction: row;
|
|
248
|
+
align-items: center;
|
|
249
|
+
}
|
|
234
250
|
.sub-btn {
|
|
235
251
|
width: auto;
|
|
236
252
|
white-space: nowrap;
|
|
@@ -240,7 +256,7 @@ ODA({
|
|
|
240
256
|
}
|
|
241
257
|
</style>
|
|
242
258
|
<nav ~if="groupedItems.length" class="sub-nav" aria-label="Разделы">
|
|
243
|
-
<div ~for="groupedItems"
|
|
259
|
+
<div ~for="groupedItems" class="sub-row">
|
|
244
260
|
<div ~if="$for.item.isSep" class="sub-sep"></div>
|
|
245
261
|
<button ~if="!$for.item.isSep" type="button" class="sub-btn"
|
|
246
262
|
:data-active="$for.item.active ? '1' : ''"
|
|
@@ -269,11 +285,24 @@ ODA({
|
|
|
269
285
|
_loadSeq: 0,
|
|
270
286
|
_attachedDone: false,
|
|
271
287
|
_pendingSubView: '',
|
|
272
|
-
|
|
288
|
+
_pendingMountTabId: '',
|
|
289
|
+
_loadingFor: null,
|
|
290
|
+
_loadingHandler: null,
|
|
291
|
+
_loadingPromise: null,
|
|
292
|
+
_loadedFor: null,
|
|
293
|
+
_loadedHandler: null,
|
|
294
|
+
_attemptedMountIds: null,
|
|
295
|
+
$handler: {
|
|
296
|
+
$def: null,
|
|
297
|
+
set(n) {
|
|
298
|
+
if (n && this.$item)
|
|
299
|
+
this._loadTabs(this.$item);
|
|
300
|
+
}
|
|
301
|
+
},
|
|
273
302
|
$item: {
|
|
274
303
|
$def: null,
|
|
275
304
|
set(n) {
|
|
276
|
-
if (n)
|
|
305
|
+
if (n && this.$handler)
|
|
277
306
|
this._loadTabs(n);
|
|
278
307
|
}
|
|
279
308
|
},
|
|
@@ -363,11 +392,31 @@ ODA({
|
|
|
363
392
|
},
|
|
364
393
|
attached() {
|
|
365
394
|
this._attachedDone = true;
|
|
366
|
-
if (this.$item &&
|
|
395
|
+
if (this.$item && !this.tabs?.length && !this._loadingPromise) {
|
|
367
396
|
this._loadTabs(this.$item);
|
|
368
397
|
}
|
|
369
|
-
else if (this.activeId
|
|
370
|
-
const
|
|
398
|
+
else if (this.activeId) {
|
|
399
|
+
const body = this.$?.('#subBody');
|
|
400
|
+
if (!body) {
|
|
401
|
+
this._pendingMountTabId = this.activeId;
|
|
402
|
+
this.render?.(true);
|
|
403
|
+
}
|
|
404
|
+
else if (!body.children?.length && !this._controls?.[this.activeId] && !this._attemptedMountIds?.has(this.activeId)) {
|
|
405
|
+
const tab = (this.tabs || []).find(t => t.id === this.activeId);
|
|
406
|
+
if (tab)
|
|
407
|
+
this._mountTab(tab, this._pendingSubView || '');
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
onRender() {
|
|
412
|
+
const body = this.$?.('#subBody');
|
|
413
|
+
if (!body)
|
|
414
|
+
return;
|
|
415
|
+
const targetId = this._pendingMountTabId
|
|
416
|
+
|| (!body.children?.length && this.activeId && !this._controls?.[this.activeId] ? this.activeId : '');
|
|
417
|
+
if (targetId && !this._attemptedMountIds?.has(targetId)) {
|
|
418
|
+
this._pendingMountTabId = '';
|
|
419
|
+
const tab = (this.tabs || []).find(t => t.id === targetId);
|
|
371
420
|
if (tab)
|
|
372
421
|
this._mountTab(tab, this._pendingSubView || '');
|
|
373
422
|
}
|
|
@@ -381,7 +430,27 @@ ODA({
|
|
|
381
430
|
}
|
|
382
431
|
return this.$handler?.id ? `/pages/form/${this.$handler.id}` : '/pages/form';
|
|
383
432
|
},
|
|
384
|
-
|
|
433
|
+
_loadTabs(item) {
|
|
434
|
+
const handler = this.$handler || null;
|
|
435
|
+
if (item && this._loadingPromise && this._loadingFor === item && this._loadingHandler === handler)
|
|
436
|
+
return this._loadingPromise;
|
|
437
|
+
if (item && this._loadedFor === item && this._loadedHandler === handler && this.tabs?.length)
|
|
438
|
+
return Promise.resolve();
|
|
439
|
+
this._loadingFor = item || null;
|
|
440
|
+
this._loadingHandler = handler;
|
|
441
|
+
const p = this._doLoadTabs(item).then(() => {
|
|
442
|
+
if (this._loadingFor === item && this._loadingHandler === handler) {
|
|
443
|
+
this._loadedFor = item || null;
|
|
444
|
+
this._loadedHandler = handler;
|
|
445
|
+
}
|
|
446
|
+
}).finally(() => {
|
|
447
|
+
if (this._loadingPromise === p)
|
|
448
|
+
this._loadingPromise = null;
|
|
449
|
+
});
|
|
450
|
+
this._loadingPromise = p;
|
|
451
|
+
return p;
|
|
452
|
+
},
|
|
453
|
+
async _doLoadTabs(item) {
|
|
385
454
|
const seq = ++this._loadSeq;
|
|
386
455
|
if (!item) {
|
|
387
456
|
this.tabs = [];
|
|
@@ -408,6 +477,8 @@ ODA({
|
|
|
408
477
|
t.$context = item;
|
|
409
478
|
this.tabs = list;
|
|
410
479
|
this._controls = {};
|
|
480
|
+
this._attemptedMountIds = new Set();
|
|
481
|
+
this._pendingMountTabId = '';
|
|
411
482
|
const body = this.$?.('#subBody');
|
|
412
483
|
if (body)
|
|
413
484
|
body.innerHTML = '';
|
|
@@ -429,6 +500,7 @@ ODA({
|
|
|
429
500
|
if (!tab)
|
|
430
501
|
return;
|
|
431
502
|
this.activeId = id;
|
|
503
|
+
this.render?.(true);
|
|
432
504
|
await this._mountTab(tab, nestedSubView);
|
|
433
505
|
this.$form?.syncFromView?.(this);
|
|
434
506
|
},
|
|
@@ -438,11 +510,16 @@ ODA({
|
|
|
438
510
|
const seq = ++this._mountSeq;
|
|
439
511
|
const body = this.$?.('#subBody');
|
|
440
512
|
if (!body) {
|
|
513
|
+
this._pendingMountTabId = tab.id;
|
|
441
514
|
this._pendingSubView = nestedSubView || '';
|
|
515
|
+
this.render?.(true);
|
|
442
516
|
return;
|
|
443
517
|
}
|
|
518
|
+
this._pendingMountTabId = '';
|
|
444
519
|
this._pendingSubView = '';
|
|
445
520
|
this._controls ||= {};
|
|
521
|
+
this._attemptedMountIds ||= new Set();
|
|
522
|
+
this._attemptedMountIds.add(tab.id);
|
|
446
523
|
let el = this._controls[tab.id];
|
|
447
524
|
if (!el) {
|
|
448
525
|
const mod = await tab.importView();
|
|
@@ -457,9 +534,9 @@ ODA({
|
|
|
457
534
|
}
|
|
458
535
|
else if (this.depth < 6 && (tab.layout || tab.DATA?.layout || (Array.isArray(tab.DATA?.items) && tab.DATA.items.length))) {
|
|
459
536
|
el = ODA.createComponent('work-subview-container', {
|
|
537
|
+
$handler: tab,
|
|
460
538
|
$item: this.$item,
|
|
461
539
|
$context: this.$item,
|
|
462
|
-
$handler: tab,
|
|
463
540
|
layout: tab.layout || tab.DATA?.layout || 'sidebar',
|
|
464
541
|
role: this.role,
|
|
465
542
|
subViewPath: nestedSubView,
|
|
@@ -478,6 +555,9 @@ ODA({
|
|
|
478
555
|
ch.hidden = ch !== el;
|
|
479
556
|
ch.style.display = ch === el ? '' : 'none';
|
|
480
557
|
}
|
|
558
|
+
if (el[R]?.states)
|
|
559
|
+
el[R].states.sleep = false;
|
|
560
|
+
el.render?.(true);
|
|
481
561
|
if (nestedSubView && typeof el.applyNav === 'function')
|
|
482
562
|
await el.applyNav({ subView: nestedSubView });
|
|
483
563
|
this.$form?.syncFromView?.(this);
|
|
@@ -673,7 +753,7 @@ ODA({is: 'work-form',
|
|
|
673
753
|
:rainbow="saving"
|
|
674
754
|
:error-invert="isViewChanged && !!saveError"
|
|
675
755
|
:success-invert="isViewChanged && !saveError"
|
|
676
|
-
style="position: relative; align-items: center;"
|
|
756
|
+
style="position: relative; align-items: center; padding: 4px; border-radius: 8px;"
|
|
677
757
|
horizontal
|
|
678
758
|
>
|
|
679
759
|
<oda-icon
|
|
@@ -2339,10 +2419,10 @@ ODA({is: 'work-form',
|
|
|
2339
2419
|
}
|
|
2340
2420
|
else if (n.layout || n.DATA?.layout || (Array.isArray(n.DATA?.items) && n.DATA.items.length)) {
|
|
2341
2421
|
el = ODA.createComponent('work-subview-container', {
|
|
2422
|
+
$handler: n,
|
|
2342
2423
|
$item: tabItem,
|
|
2343
2424
|
$context: tabItem,
|
|
2344
2425
|
slot: 'main',
|
|
2345
|
-
$handler: n,
|
|
2346
2426
|
layout: n.layout || n.DATA?.layout || 'sidebar',
|
|
2347
2427
|
role: this.activeRole,
|
|
2348
2428
|
subViewPath: nav?.subView || '',
|
|
@@ -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>
|
|
@@ -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));
|
|
@@ -1,88 +1,262 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* oda-text-input — строчный ввод текста на нативном input: text, password (с показом), email, url, tel, search.
|
|
3
|
-
* Тип — inputType, иначе field.type (если это один из типов текста), иначе text.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
1
|
+
/**
|
|
2
|
+
* oda-text-input — строчный ввод текста на нативном input: text, password (с показом), email, url, tel, search.
|
|
3
|
+
* Тип — inputType, иначе field.type (если это один из типов текста), иначе text.
|
|
4
|
+
* При наличии list (массив, строка с | / ; / , или объект) или field.list включает выпадающий список выбора (dropdown).
|
|
5
|
+
*/
|
|
6
|
+
import { normalizeOptions } from '/oda/components/inputs/input/input.js';
|
|
7
|
+
|
|
8
|
+
const TEXT_TYPES = ['text', 'password', 'email', 'url', 'tel', 'search'];
|
|
9
|
+
|
|
10
|
+
/** адрес электронной почты — выражение из спецификации HTML (то же, что у нативного type=email) */
|
|
11
|
+
const EMAIL = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
12
|
+
|
|
13
|
+
/** скомпилированные pattern (атрибут pattern сопоставляется со всем значением, как у нативного input) */
|
|
14
|
+
const PATTERNS = new Map();
|
|
15
|
+
function patternOf(pattern) {
|
|
16
|
+
if (!PATTERNS.has(pattern)) {
|
|
17
|
+
let re;
|
|
18
|
+
// нативный input компилирует pattern с флагом v, при ошибке — игнорирует его; запасной вариант — u
|
|
19
|
+
for (const flags of ['v', 'u']) {
|
|
20
|
+
try {
|
|
21
|
+
re = new RegExp('^(?:' + pattern + ')$', flags);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
catch { }
|
|
25
|
+
}
|
|
26
|
+
PATTERNS.set(pattern, re);
|
|
27
|
+
}
|
|
28
|
+
return PATTERNS.get(pattern);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ODA({
|
|
32
|
+
is: 'oda-text-input',
|
|
33
|
+
imports: 'oda//input.js, oda//button.js, oda//icon.js',
|
|
34
|
+
extends: 'oda-input',
|
|
35
|
+
template: /*html*/`
|
|
36
|
+
<style>
|
|
37
|
+
.dd-toggle {
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: transform .15s ease;
|
|
40
|
+
}
|
|
41
|
+
.dd-toggle.open {
|
|
42
|
+
transform: rotate(180deg);
|
|
43
|
+
}
|
|
44
|
+
.dd-menu {
|
|
45
|
+
margin: 0;
|
|
46
|
+
padding: 4px;
|
|
47
|
+
border: 1px solid var(--subtle-border, var(--border-color, #d0d7de));
|
|
48
|
+
border-radius: var(--radius-s, 8px);
|
|
49
|
+
background: var(--content-background, #fff);
|
|
50
|
+
color: var(--content-color, inherit);
|
|
51
|
+
box-shadow: var(--elevation-3, 0 8px 24px rgba(0, 0, 0, .14));
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
overflow-y: auto;
|
|
54
|
+
max-height: 260px;
|
|
55
|
+
font: inherit;
|
|
56
|
+
}
|
|
57
|
+
.dd-menu:popover-open {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: 2px;
|
|
61
|
+
}
|
|
62
|
+
.dd-item {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
gap: 8px;
|
|
66
|
+
padding: 6px 10px;
|
|
67
|
+
border-radius: var(--radius-xs, 6px);
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
min-width: 0;
|
|
70
|
+
user-select: none;
|
|
71
|
+
}
|
|
72
|
+
.dd-item:hover,
|
|
73
|
+
.dd-item.active {
|
|
74
|
+
background: var(--subtle-background, rgba(0, 0, 0, .05));
|
|
75
|
+
}
|
|
76
|
+
.dd-item.selected {
|
|
77
|
+
background: var(--accent-soft, rgba(37, 99, 235, .12));
|
|
78
|
+
color: var(--accent-color, inherit);
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
}
|
|
81
|
+
.dd-item.disabled {
|
|
82
|
+
opacity: .45;
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
}
|
|
85
|
+
.dd-label {
|
|
86
|
+
flex: 1 1 auto;
|
|
87
|
+
min-width: 0;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
93
|
+
<input class="control" part="control"
|
|
94
|
+
:type="nativeType" :value="value ?? ''" :placeholder="placeholderText"
|
|
95
|
+
:readonly="isReadonly" :disabled :required="isRequired"
|
|
96
|
+
:minlength="field?.minLength" :maxlength="field?.maxLength" :pattern="pattern || field?.pattern"
|
|
97
|
+
:autocomplete="autocomplete" :inputmode="inputMode"
|
|
98
|
+
@input="onTextInput($this.value)" @keydown="onTextKey($event)">
|
|
99
|
+
<oda-button ~if="textType === 'password'" class="affix" :icon="revealed ? 'icons:visibility-off' : 'icons:visibility'" :icon-size
|
|
100
|
+
title="Показать / скрыть" @tap.stop="revealed = !revealed"></oda-button>
|
|
101
|
+
<oda-button ~if="clearable && !isEmpty && !isReadonly" class="affix" icon="icons:close" :icon-size title="Очистить" @tap.stop="value = ''"></oda-button>
|
|
102
|
+
<oda-button ~if="listOptions.length && !isReadonly && !disabled" class="affix dd-toggle" ~class="{ open: menuOpen }"
|
|
103
|
+
icon="icons:arrow-drop-down" :icon-size="18" title="Выбрать из списка"
|
|
104
|
+
@down.prevent.stop @tap.stop="toggleMenu()"></oda-button>
|
|
105
|
+
<div ~if="listOptions.length" class="dd-menu" popover="auto" @toggle="onPopoverToggle($event)">
|
|
106
|
+
<div ~for="listOptions" style="display: contents">
|
|
107
|
+
<div class="dd-item"
|
|
108
|
+
~class="{ selected: isSelectedOption($for.item), active: $for.index === activeIndex, disabled: !!$for.item.disabled }"
|
|
109
|
+
@pointerdown.prevent="pickOption($for.item)">
|
|
110
|
+
<oda-icon ~if="$for.item.icon" :icon="$for.item.icon" :icon-size="16"></oda-icon>
|
|
111
|
+
<span class="dd-label">{{$for.item.label}}</span>
|
|
112
|
+
<oda-icon ~if="isSelectedOption($for.item)" icon="icons:check" :icon-size="14"></oda-icon>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
`,
|
|
117
|
+
$public: {
|
|
118
|
+
// без $def: пустое значение — undefined (как в данных); $def: '' вечно спорил
|
|
119
|
+
// с привязкой и давал цикл запись→нотификация→рендер (см. pitfalls §21)
|
|
120
|
+
value: {
|
|
121
|
+
$type: String
|
|
122
|
+
},
|
|
123
|
+
/** text | password | email | url | tel | search; пусто — по field.type */
|
|
124
|
+
inputType: '',
|
|
125
|
+
pattern: '',
|
|
126
|
+
autocomplete: 'off',
|
|
127
|
+
/** кнопка очистки */
|
|
128
|
+
clearable: false,
|
|
129
|
+
/** список вариантов (массив, строка с | / ; / , или объект) — включает выпадающий выбор */
|
|
130
|
+
list: undefined
|
|
131
|
+
},
|
|
132
|
+
revealed: false,
|
|
133
|
+
menuOpen: false,
|
|
134
|
+
activeIndex: -1,
|
|
135
|
+
get listOptions() {
|
|
136
|
+
return normalizeOptions(this.list ?? this.field?.list ?? this.field?.items ?? this.field?.options);
|
|
137
|
+
},
|
|
138
|
+
isSelectedOption(o) {
|
|
139
|
+
return !this.isEmpty && o && String(o.value) === String(this.value);
|
|
140
|
+
},
|
|
141
|
+
onTextInput(v) {
|
|
142
|
+
this.value = v;
|
|
143
|
+
},
|
|
144
|
+
toggleMenu() {
|
|
145
|
+
if (this.menuOpen)
|
|
146
|
+
this.closeMenu();
|
|
147
|
+
else
|
|
148
|
+
this.openMenu();
|
|
149
|
+
},
|
|
150
|
+
openMenu() {
|
|
151
|
+
if (this.isReadonly || this.disabled || !this.listOptions.length)
|
|
152
|
+
return;
|
|
153
|
+
const menu = this.$('.dd-menu');
|
|
154
|
+
if (!menu)
|
|
155
|
+
return;
|
|
156
|
+
const rect = this.getBoundingClientRect();
|
|
157
|
+
const vw = window.innerWidth || 0;
|
|
158
|
+
const vh = window.innerHeight || 0;
|
|
159
|
+
const spaceBelow = vh - rect.bottom - 8;
|
|
160
|
+
const spaceAbove = rect.top - 8;
|
|
161
|
+
const maxH = Math.min(260, Math.max(120, Math.max(spaceBelow, spaceAbove)));
|
|
162
|
+
const openUp = spaceBelow < 160 && spaceAbove > spaceBelow;
|
|
163
|
+
menu.style.position = 'fixed';
|
|
164
|
+
menu.style.left = Math.max(8, Math.min(rect.left, vw - Math.max(rect.width, 160) - 8)) + 'px';
|
|
165
|
+
menu.style.width = Math.max(rect.width, 140) + 'px';
|
|
166
|
+
menu.style.maxHeight = maxH + 'px';
|
|
167
|
+
if (openUp) {
|
|
168
|
+
menu.style.top = 'auto';
|
|
169
|
+
menu.style.bottom = Math.max(8, vh - rect.top + 4) + 'px';
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
menu.style.bottom = 'auto';
|
|
173
|
+
menu.style.top = Math.min(vh - 48, rect.bottom + 4) + 'px';
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
if (!menu.matches(':popover-open'))
|
|
177
|
+
menu.showPopover?.();
|
|
178
|
+
}
|
|
179
|
+
catch { /* ignore */ }
|
|
180
|
+
this.menuOpen = true;
|
|
181
|
+
this.activeIndex = this.listOptions.findIndex(o => this.isSelectedOption(o));
|
|
182
|
+
},
|
|
183
|
+
closeMenu() {
|
|
184
|
+
const menu = this.$('.dd-menu');
|
|
185
|
+
try {
|
|
186
|
+
if (menu?.matches?.(':popover-open'))
|
|
187
|
+
menu.hidePopover?.();
|
|
188
|
+
}
|
|
189
|
+
catch { /* ignore */ }
|
|
190
|
+
this.menuOpen = false;
|
|
191
|
+
this.activeIndex = -1;
|
|
192
|
+
},
|
|
193
|
+
onPopoverToggle(e) {
|
|
194
|
+
this.menuOpen = e?.newState === 'open';
|
|
195
|
+
if (!this.menuOpen)
|
|
196
|
+
this.activeIndex = -1;
|
|
197
|
+
},
|
|
198
|
+
pickOption(o) {
|
|
199
|
+
if (!o || o.disabled)
|
|
200
|
+
return;
|
|
201
|
+
this.value = String(o.value ?? '');
|
|
202
|
+
this.closeMenu();
|
|
203
|
+
this.focus();
|
|
204
|
+
},
|
|
205
|
+
onTextKey(e) {
|
|
206
|
+
if (this.isReadonly || this.disabled || !this.listOptions.length)
|
|
207
|
+
return;
|
|
208
|
+
if (e.key === 'ArrowDown') {
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
if (!this.menuOpen)
|
|
211
|
+
this.openMenu();
|
|
212
|
+
else
|
|
213
|
+
this.activeIndex = (this.activeIndex + 1) % this.listOptions.length;
|
|
214
|
+
}
|
|
215
|
+
else if (e.key === 'ArrowUp' && this.menuOpen) {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
this.activeIndex = (this.activeIndex - 1 + this.listOptions.length) % this.listOptions.length;
|
|
218
|
+
}
|
|
219
|
+
else if (e.key === 'Enter' && this.menuOpen && this.activeIndex >= 0) {
|
|
220
|
+
const item = this.listOptions[this.activeIndex];
|
|
221
|
+
if (item && !item.disabled) {
|
|
222
|
+
e.preventDefault();
|
|
223
|
+
this.pickOption(item);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else if (e.key === 'Escape' && this.menuOpen) {
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
e.stopPropagation();
|
|
229
|
+
this.closeMenu();
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
get textType() {
|
|
233
|
+
const t = String(this.inputType || this.field?.type || 'text').toLowerCase();
|
|
234
|
+
return TEXT_TYPES.includes(t) ? t : 'text';
|
|
235
|
+
},
|
|
236
|
+
get nativeType() {
|
|
237
|
+
return this.textType === 'password' && this.revealed ? 'text' : this.textType;
|
|
238
|
+
},
|
|
239
|
+
get inputMode() {
|
|
240
|
+
return { email: 'email', url: 'url', tel: 'tel', search: 'search' }[this.textType] ?? 'text';
|
|
241
|
+
},
|
|
242
|
+
get validationErrors() {
|
|
243
|
+
return this.formatMessage ? [this.formatMessage] : [];
|
|
244
|
+
},
|
|
245
|
+
/**
|
|
246
|
+
* Проверка формата (email, url, pattern) по правилам нативного input, но без создания DOM
|
|
247
|
+
* и с русским текстом (нативное сообщение зависит от языка браузера). Пустое значение сюда не доходит.
|
|
248
|
+
*/
|
|
249
|
+
get formatMessage() {
|
|
250
|
+
const text = this.value ?? '';
|
|
251
|
+
if (this.textType === 'email' && !EMAIL.test(text))
|
|
252
|
+
return 'Введите адрес электронной почты';
|
|
253
|
+
if (this.textType === 'url' && !URL.canParse(text))
|
|
254
|
+
return 'Введите адрес в виде URL (например, https://example.com)';
|
|
255
|
+
const pattern = this.pattern || this.field?.pattern;
|
|
256
|
+
// нерабочий pattern нативный input игнорирует — игнорируем и мы
|
|
257
|
+
const re = pattern && patternOf(pattern);
|
|
258
|
+
if (re && !re.test(text))
|
|
259
|
+
return 'Значение не соответствует формату';
|
|
260
|
+
return '';
|
|
261
|
+
}
|
|
262
|
+
});
|
|
@@ -53,10 +53,17 @@ function cleanField(f, seen) {
|
|
|
53
53
|
field.catalog = f.catalog.trim();
|
|
54
54
|
if (f.analytic === true)
|
|
55
55
|
field.analytic = true;
|
|
56
|
+
const rawList = f.list !== undefined ? f.list : ((type !== 'Select' && type !== 'Radio') ? (f.items ?? f.options) : undefined);
|
|
57
|
+
if (rawList !== undefined && rawList !== null && rawList !== '') {
|
|
58
|
+
field.list = rawList;
|
|
59
|
+
if (f.allowOther !== undefined)
|
|
60
|
+
field.allowOther = Boolean(f.allowOther);
|
|
61
|
+
}
|
|
56
62
|
if (type === 'Select' || type === 'Radio') {
|
|
57
|
-
const
|
|
58
|
-
field.options =
|
|
59
|
-
.
|
|
63
|
+
const rawOpts = Array.isArray(f.options) ? f.options : (Array.isArray(f.items) ? f.items : (Array.isArray(f.list) ? f.list : []));
|
|
64
|
+
field.options = rawOpts
|
|
65
|
+
.map(o => o && typeof o === 'object' ? o : { value: String(o ?? ''), label: String(o ?? '') })
|
|
66
|
+
.filter(o => o && String(o.value ?? '').trim() !== '')
|
|
60
67
|
.map(o => ({
|
|
61
68
|
value: String(o.value).trim(),
|
|
62
69
|
label: String(o.label || o.value).trim(),
|
|
@@ -1055,7 +1062,7 @@ ODA({is: 'oda-editor-form-field',
|
|
|
1055
1062
|
<div class="field-row" ~if="!isBlockField" ~class="{ invalid: hasError, multiline: field?.type === 'Text' }">
|
|
1056
1063
|
<label class="field-label" ~class="{ compact: isCompactField }" :title="label">{{label}}<span class="req" ~if="required"> *</span>:</label>
|
|
1057
1064
|
<div class="editor-box">
|
|
1058
|
-
<div class="field-control" ~is="editor" :value="data?.[field.id]" @value-changed="onFieldValueChanged($event)" :field :meta="field" :at="data?.time || ''" :allow-other="!!field.other" :borderless="false" dense no-header :readonly="Boolean(readonly || field?.readonly || field?.disabled)" :disabled="Boolean(field?.disabled)"></div>
|
|
1065
|
+
<div class="field-control" ~is="editor" :value="data?.[field.id]" @value-changed="onFieldValueChanged($event)" :field :meta="field" :list="field?.list" :at="data?.time || ''" :allow-other="field?.allowOther !== undefined ? !!field.allowOther : (editor === 'oda-combobox-input' ? true : !!field.other)" :borderless="false" dense no-header :readonly="Boolean(readonly || field?.readonly || field?.disabled)" :disabled="Boolean(field?.disabled)"></div>
|
|
1059
1066
|
<div class="field-error" ~if="serverError">{{serverError}}</div>
|
|
1060
1067
|
</div>
|
|
1061
1068
|
</div>
|
|
@@ -1065,7 +1072,7 @@ ODA({is: 'oda-editor-form-field',
|
|
|
1065
1072
|
<span>{{label}}<span class="req" ~if="required"> *</span></span>
|
|
1066
1073
|
</div>
|
|
1067
1074
|
<div class="editor-box">
|
|
1068
|
-
<div ~if="field?.type !== 'Struct'" ~is="editor" :value="data?.[field.id]" @value-changed="onFieldValueChanged($event)" :field :meta="field" :at="data?.time || ''" :allow-other="!!field.other" :borderless="false" no-header :readonly="Boolean(readonly || field?.readonly || field?.disabled)" :disabled="Boolean(field?.disabled)"></div>
|
|
1075
|
+
<div ~if="field?.type !== 'Struct'" ~is="editor" :value="data?.[field.id]" @value-changed="onFieldValueChanged($event)" :field :meta="field" :list="field?.list" :at="data?.time || ''" :allow-other="field?.allowOther !== undefined ? !!field.allowOther : (editor === 'oda-combobox-input' ? true : !!field.other)" :borderless="false" no-header :readonly="Boolean(readonly || field?.readonly || field?.disabled)" :disabled="Boolean(field?.disabled)"></div>
|
|
1069
1076
|
<div ~if="children?.length && expanded" class="children-box" horizontal :denied="formDesigner?.isItemDenied?.(null, groupLayer)">
|
|
1070
1077
|
<div class="group-item" ~for="visibleGroupItems"
|
|
1071
1078
|
~class="{designing: formDesigner?.designMode}"
|
|
@@ -22,6 +22,7 @@ export const CONTROLS = {
|
|
|
22
22
|
datetime: 'oda-date-input',
|
|
23
23
|
timestamp: 'oda-date-input',
|
|
24
24
|
select: 'oda-select-input',
|
|
25
|
+
combobox: 'oda-combobox-input',
|
|
25
26
|
radio: 'oda-radio-input',
|
|
26
27
|
tags: 'oda-tags-input',
|
|
27
28
|
color: 'oda-color-input',
|
|
@@ -39,15 +40,23 @@ export const CONTROLS = {
|
|
|
39
40
|
table: 'oda-table-input'
|
|
40
41
|
};
|
|
41
42
|
|
|
42
|
-
/** выбор тега по карте: field.control → путь `/` (link) → controls[type] → группа без типа (undefined) → controls.default */
|
|
43
|
+
/** выбор тега по карте: field.control → путь `/` (link) → field.list (выбор/дропдаун) → controls[type] → группа без типа (undefined) → controls.default */
|
|
43
44
|
export function controlOf(map = {}, field = {}) {
|
|
44
45
|
if (field.control)
|
|
45
46
|
return field.control;
|
|
46
47
|
const type = field.type;
|
|
47
48
|
if (typeof type === 'string' && type.startsWith('/'))
|
|
48
49
|
return map.link ?? map.default;
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const typeKey = type !== undefined ? String(type).toLowerCase() : '';
|
|
51
|
+
const hasList = field.list !== undefined && field.list !== null && field.list !== ''
|
|
52
|
+
&& (!Array.isArray(field.list) || field.list.length > 0);
|
|
53
|
+
if (hasList && !['select', 'radio', 'tags', 'list', 'link'].includes(typeKey)) {
|
|
54
|
+
if (field.allowOther === false)
|
|
55
|
+
return map.select ?? map.combobox ?? map.default;
|
|
56
|
+
return map.combobox ?? map.select ?? map.default;
|
|
57
|
+
}
|
|
58
|
+
if (type !== undefined && (type in map || typeKey in map))
|
|
59
|
+
return map[type] ?? map[typeKey];
|
|
51
60
|
if (field.fields && type === undefined)
|
|
52
61
|
return undefined;
|
|
53
62
|
return map.default;
|
|
@@ -8,6 +8,7 @@ import '/oda/components/inputs/numeric/numeric.js';
|
|
|
8
8
|
import '/oda/components/inputs/date/date.js';
|
|
9
9
|
import '/oda/components/inputs/checkbox/checkbox.js';
|
|
10
10
|
import '/oda/components/inputs/select/select.js';
|
|
11
|
+
import '/oda/components/inputs/combobox/combobox.js';
|
|
11
12
|
import '/oda/components/inputs/radio/radio.js';
|
|
12
13
|
import '/oda/components/inputs/color/color.js';
|
|
13
14
|
import '/oda/components/inputs/range/range.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.96",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|
|
@@ -66,7 +66,7 @@ export class $handler extends $class{
|
|
|
66
66
|
return this.DATA?.allowUse;
|
|
67
67
|
}
|
|
68
68
|
async import(path, is){
|
|
69
|
-
path = (this.
|
|
69
|
+
path = (this.short || this.path) + '/~/' + (path || 'class.js');
|
|
70
70
|
if(!path.endsWith('.js'))
|
|
71
71
|
path += '.js';
|
|
72
72
|
const module = await import(path);
|
|
@@ -83,7 +83,7 @@ export class $handler extends $class{
|
|
|
83
83
|
}
|
|
84
84
|
if (!comp || typeof comp !== 'object')
|
|
85
85
|
return null;
|
|
86
|
-
const rawPath = this.
|
|
86
|
+
const rawPath = this.short || this.path || this.id;
|
|
87
87
|
const want = is || comp.is || rawExport.tag || makeViewTag(this.id, rawPath);
|
|
88
88
|
// Клонируем описание компонента с сохранением дескрипторов (геттеры/сеттеры),
|
|
89
89
|
// чтобы регистрация в WORK/ODA не мутировала кэшированный ES-модуль.
|
|
@@ -163,7 +163,7 @@ export class $handler extends $class{
|
|
|
163
163
|
async getModule() {
|
|
164
164
|
const $item = Reactor.activate(this);
|
|
165
165
|
$item.$context = await $item.$context;
|
|
166
|
-
const module = await import(`${$item.
|
|
166
|
+
const module = await import(`${$item.short || $item.path}/~/class.js`);
|
|
167
167
|
return module.default;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -6,7 +6,7 @@ import * as CORE from '../server/index.js';
|
|
|
6
6
|
import { $server } from '../server/server.js';
|
|
7
7
|
import { audit } from '../server/access/audit.js';
|
|
8
8
|
import { inspectInvite, consumeInvite } from '../server/access/invites.js';
|
|
9
|
-
import { assertWorkplaceAvailableForLogin } from '../modules/license/index.js';
|
|
9
|
+
import { assertWorkplaceAvailableForLogin, sendLoginCodeViaLicenseHub } from '../modules/license/index.js';
|
|
10
10
|
|
|
11
11
|
const REGISTER_CODE_TTL_MS = 10 * 60 * 1000;
|
|
12
12
|
const REGISTER_MAX_ATTEMPTS = 5;
|
|
@@ -114,7 +114,21 @@ export const authMethods = {
|
|
|
114
114
|
if (DEV_MODE) {
|
|
115
115
|
return "На Вашу почту отправлено письмо с одноразовым кодом, введите его для продолжения регистрации.";
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
// Подключённый (лицензированный) клиент без собственного SMTP отправляет код через сервер поддержки
|
|
118
|
+
let relayError = '';
|
|
119
|
+
try {
|
|
120
|
+
const relayed = await sendLoginCodeViaLicenseHub({ email, code });
|
|
121
|
+
if (relayed?.ok)
|
|
122
|
+
return "На Вашу почту отправлено письмо с одноразовым кодом, введите его для продолжения регистрации.";
|
|
123
|
+
}
|
|
124
|
+
catch (relayErr) {
|
|
125
|
+
relayError = relayErr?.message || String(relayErr);
|
|
126
|
+
console.warn('[auth] Код входа не отправлен через сервер поддержки:', relayError);
|
|
127
|
+
}
|
|
128
|
+
throw new Error(
|
|
129
|
+
'Почтовый сервер не настроен. Администратор (BOSS) может настроить почтовый ящик в корне WORK → представление «Почта» (⚙️ Почтовые ящики) или в файле #system/mail.json'
|
|
130
|
+
+ (relayError ? `, либо подключить лицензию к серверу поддержки (${relayError})` : '')
|
|
131
|
+
);
|
|
118
132
|
}
|
|
119
133
|
const fromUser = activeMailer.fromUser || activeMailer.transport?.options?.auth?.user || 'noreply@localhost';
|
|
120
134
|
const mailOptions = {
|
|
@@ -1122,6 +1122,59 @@ export async function syncWithLicenseHub({ hubUrl, licensePath, systemDir, token
|
|
|
1122
1122
|
return getFullLicenseStatus({ license: lic, licensePath, systemDir: sysDir, trustedPublicKey });
|
|
1123
1123
|
}
|
|
1124
1124
|
|
|
1125
|
+
/**
|
|
1126
|
+
* Отправить одноразовый код входа/регистрации на Email через сервер поддержки,
|
|
1127
|
+
* когда на локальном WORK не настроен собственный почтовый сервер (SMTP).
|
|
1128
|
+
*
|
|
1129
|
+
* Работает только для подключённых (активированных) клиентов: запрос подтверждается
|
|
1130
|
+
* парой licenseId + HWID/отпечатком узла или привязанным токеном владельца (owk1...).
|
|
1131
|
+
*/
|
|
1132
|
+
export async function sendLoginCodeViaLicenseHub({
|
|
1133
|
+
email,
|
|
1134
|
+
code,
|
|
1135
|
+
hubUrl,
|
|
1136
|
+
systemDir,
|
|
1137
|
+
licensePath,
|
|
1138
|
+
trustedPublicKey = '',
|
|
1139
|
+
fetchImpl = globalThis.fetch,
|
|
1140
|
+
} = {}) {
|
|
1141
|
+
const sysDir = systemDir || (licensePath ? path.dirname(licensePath) : SYSTEM_DIR);
|
|
1142
|
+
const lic = loadLocalLicense(licensePath || LICENSE_FILE, { systemDir: sysDir, trustedPublicKey });
|
|
1143
|
+
if (lic.unlicensed) {
|
|
1144
|
+
throw new Error(
|
|
1145
|
+
'Локальная система не подключена к серверу поддержки: привяжите лицензию владельца '
|
|
1146
|
+
+ 'или настройте почтовый сервер в #system/mail.json'
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
const binding = loadOwnerTokenBinding(sysDir);
|
|
1151
|
+
const baseUrl = String(hubUrl || binding?.hubUrl || lic.hubUrl || DEFAULT_LICENSE_HUB_URL).replace(/\/+$/, '');
|
|
1152
|
+
const hw = getHardwareIdentity();
|
|
1153
|
+
const res = await fetchImpl(`${baseUrl}/api/license/send-login-code`, {
|
|
1154
|
+
method: 'POST',
|
|
1155
|
+
headers: {
|
|
1156
|
+
'Content-Type': 'application/json',
|
|
1157
|
+
...(binding?.token ? { Authorization: `Bearer ${binding.token}` } : {}),
|
|
1158
|
+
},
|
|
1159
|
+
signal: typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function'
|
|
1160
|
+
? AbortSignal.timeout(15000)
|
|
1161
|
+
: undefined,
|
|
1162
|
+
body: JSON.stringify({
|
|
1163
|
+
email,
|
|
1164
|
+
...(code ? { code } : {}),
|
|
1165
|
+
licenseId: lic.licenseId,
|
|
1166
|
+
hwid: lic.hardware?.hwid || hw.hwid,
|
|
1167
|
+
nodeFingerprint: lic.hardware?.nodeFingerprint || hw.nodeFingerprint,
|
|
1168
|
+
...(binding?.token ? { token: binding.token } : {}),
|
|
1169
|
+
}),
|
|
1170
|
+
});
|
|
1171
|
+
const data = await res.json().catch(() => ({}));
|
|
1172
|
+
if (!res.ok) {
|
|
1173
|
+
throw new Error(data?.error || `Сервер поддержки (${baseUrl}) отклонил отправку кода (HTTP ${res.status})`);
|
|
1174
|
+
}
|
|
1175
|
+
return data;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1125
1178
|
/**
|
|
1126
1179
|
* Создать заказ (через ЮKassa или по договору/счёту для юрлиц) на сервере work.odant.org.
|
|
1127
1180
|
*/
|