@myrtex-org/form 1.1.56 → 1.1.58
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/esm2022/lib/modules/object-form/components/elements/input/table/components/input-table-modal/input-table-modal.component.mjs +20 -72
- package/esm2022/lib/modules/object-form/components/elements/input/table/input-table.component.mjs +2 -1
- package/fesm2022/myrtex-org-form.mjs +19 -71
- package/fesm2022/myrtex-org-form.mjs.map +1 -1
- package/lib/modules/object-form/components/elements/input/table/components/input-table-modal/input-table-modal.component.d.ts +2 -3
- package/lib/modules/object-form/components/elements/input/table/input-table.component.d.ts +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ import { AutoSaveStore, ToasterType, LabelModule, ModalServiceComponent, MODAL_D
|
|
|
17
17
|
import { HttpHeaders, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
18
18
|
import * as i2$1 from '@myrtex-org/templates';
|
|
19
19
|
import { FormHeaderModule, MenuAdminModule } from '@myrtex-org/templates';
|
|
20
|
-
import { cloneDeep } from 'lodash-es';
|
|
20
|
+
import { cloneDeep, isArray } from 'lodash-es';
|
|
21
21
|
import * as i2$2 from '@angular/forms';
|
|
22
22
|
import { FormsModule } from '@angular/forms';
|
|
23
23
|
import { provideNgxMask } from 'ngx-mask';
|
|
@@ -2236,7 +2236,6 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2236
2236
|
this.dialogRef = dialogRef;
|
|
2237
2237
|
this.store = store;
|
|
2238
2238
|
this.formulaCalculateService = formulaCalculateService;
|
|
2239
|
-
this._detector = inject(ChangeDetectorRef);
|
|
2240
2239
|
this.emptyRow = true;
|
|
2241
2240
|
this.title = data.title;
|
|
2242
2241
|
this.okText = data.okText;
|
|
@@ -2245,33 +2244,17 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2245
2244
|
this.isCheckRequired = data.isCheckRequired;
|
|
2246
2245
|
this.result = { result: false, rowModel: this.rowModel };
|
|
2247
2246
|
}
|
|
2248
|
-
componentValueChanged(
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
if (event && event.value && Array.isArray(event.value)) {
|
|
2253
|
-
event.value.forEach((subModel) => {
|
|
2254
|
-
if (subModel && subModel.sysName) {
|
|
2255
|
-
const target = cloneRowModel.data.find((x) => x.sysName === subModel.sysName);
|
|
2256
|
-
if (target) {
|
|
2257
|
-
target.value = subModel.value;
|
|
2258
|
-
}
|
|
2259
|
-
else {
|
|
2260
|
-
// Если такой модели в строке почему-то нет, добавляем её
|
|
2261
|
-
cloneRowModel.data.push(subModel);
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2247
|
+
componentValueChanged(valueModel) {
|
|
2248
|
+
if (isArray(valueModel)) {
|
|
2249
|
+
valueModel.forEach(model => {
|
|
2250
|
+
this._transformValues(model);
|
|
2264
2251
|
});
|
|
2265
2252
|
}
|
|
2266
|
-
else
|
|
2267
|
-
|
|
2268
|
-
const target = cloneRowModel.data.find((x) => x.sysName === event.sysName);
|
|
2269
|
-
if (target) {
|
|
2270
|
-
target.value = event.value;
|
|
2271
|
-
}
|
|
2253
|
+
else {
|
|
2254
|
+
this._transformValues(valueModel);
|
|
2272
2255
|
}
|
|
2273
|
-
this.
|
|
2274
|
-
this.
|
|
2256
|
+
this._recalculateFormulaFields();
|
|
2257
|
+
this.emptyRow = this.rowModel.data.every(x => this.isEmpty(x.value, x.valueType));
|
|
2275
2258
|
}
|
|
2276
2259
|
ok() {
|
|
2277
2260
|
if (!this._isValid()) {
|
|
@@ -2292,23 +2275,10 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2292
2275
|
}
|
|
2293
2276
|
_transformValues(value) {
|
|
2294
2277
|
const cloneRowModel = structuredClone(this.rowModel);
|
|
2295
|
-
// Ищем точное совпадение по sysName (например, itb6-id0 или itb6-id1)
|
|
2296
2278
|
const findValue = cloneRowModel.data.find((c) => c.sysName === value.sysName);
|
|
2297
2279
|
if (findValue) {
|
|
2298
2280
|
findValue.value = value.value;
|
|
2299
2281
|
}
|
|
2300
|
-
else {
|
|
2301
|
-
// На случай, если компонент даты вернул базовый sysName, а в модели строки лежат суффиксы
|
|
2302
|
-
// (Подстраховка для обратной совместимости структур)
|
|
2303
|
-
if (Array.isArray(value.value) && value.value.length === 2) {
|
|
2304
|
-
const startNode = cloneRowModel.data.find((c) => c.sysName === `${value.sysName}-id0`);
|
|
2305
|
-
const endNode = cloneRowModel.data.find((c) => c.sysName === `${value.sysName}-id1`);
|
|
2306
|
-
if (startNode)
|
|
2307
|
-
startNode.value = value.value[0];
|
|
2308
|
-
if (endNode)
|
|
2309
|
-
endNode.value = value.value[1];
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
2282
|
this.rowModel = cloneRowModel;
|
|
2313
2283
|
}
|
|
2314
2284
|
_recalculateFormulaFields() {
|
|
@@ -2351,40 +2321,17 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2351
2321
|
}
|
|
2352
2322
|
return result;
|
|
2353
2323
|
}
|
|
2354
|
-
// оставлю пока для проверки
|
|
2355
|
-
// private _isValid(): boolean {
|
|
2356
|
-
// var hasError = false;
|
|
2357
|
-
// var requiredComponents = this._getRequiredComponents(this.settings.components);
|
|
2358
|
-
// for (const component of requiredComponents) {
|
|
2359
|
-
// const value = this.rowModel.data
|
|
2360
|
-
// .find(x => x.sysName == component.sysName
|
|
2361
|
-
// || x.sysName == `${component.sysName}_start`
|
|
2362
|
-
// || x.sysName == `${component.sysName}_end`);
|
|
2363
|
-
// if (!value?.value) {
|
|
2364
|
-
// hasError = true;
|
|
2365
|
-
// break;
|
|
2366
|
-
// }
|
|
2367
|
-
// }
|
|
2368
|
-
// return !hasError;
|
|
2369
|
-
// }
|
|
2370
2324
|
_isValid() {
|
|
2371
|
-
|
|
2372
|
-
|
|
2325
|
+
var hasError = false;
|
|
2326
|
+
var requiredComponents = this._getRequiredComponents(this.settings.components);
|
|
2373
2327
|
for (const component of requiredComponents) {
|
|
2374
|
-
const
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
}
|
|
2382
|
-
else {
|
|
2383
|
-
// Для обычных полей
|
|
2384
|
-
if (!found || found.value === null || found.value === undefined || found.value === '') {
|
|
2385
|
-
hasError = true;
|
|
2386
|
-
break;
|
|
2387
|
-
}
|
|
2328
|
+
const value = this.rowModel.data
|
|
2329
|
+
.find(x => x.sysName == component.sysName
|
|
2330
|
+
|| x.sysName == `${component.sysName}_start`
|
|
2331
|
+
|| x.sysName == `${component.sysName}_end`);
|
|
2332
|
+
if (!value?.value) {
|
|
2333
|
+
hasError = true;
|
|
2334
|
+
break;
|
|
2388
2335
|
}
|
|
2389
2336
|
}
|
|
2390
2337
|
return !hasError;
|
|
@@ -2612,6 +2559,7 @@ class InputTableComponent {
|
|
|
2612
2559
|
}
|
|
2613
2560
|
// Обязательно сохраняем id строки, чтобы работали методы editRow и deleteRow
|
|
2614
2561
|
newDataItem.id = item.id;
|
|
2562
|
+
console.log('Сырая строка в dataSource:', newDataItem);
|
|
2615
2563
|
return newDataItem;
|
|
2616
2564
|
});
|
|
2617
2565
|
// Запускаем ручную проверку изменений, так как у компонента стоит ChangeDetectionStrategy.OnPush
|