@myrtex-org/form 1.1.62 → 1.1.64
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 +21 -15
- package/esm2022/lib/modules/object-form/components/elements/input/table/input-table.component.mjs +16 -11
- package/fesm2022/myrtex-org-form.mjs +34 -23
- 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 +1 -0
- package/lib/modules/object-form/components/elements/input/table/input-table.component.d.ts +2 -2
- package/package.json +1 -1
|
@@ -2240,6 +2240,7 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2240
2240
|
this.store = store;
|
|
2241
2241
|
this.formulaCalculateService = formulaCalculateService;
|
|
2242
2242
|
this.emptyRow = true;
|
|
2243
|
+
this._detector = inject(ChangeDetectorRef);
|
|
2243
2244
|
this.title = data.title;
|
|
2244
2245
|
this.okText = data.okText;
|
|
2245
2246
|
this.settings = data.settings;
|
|
@@ -2265,14 +2266,16 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2265
2266
|
}
|
|
2266
2267
|
ok() {
|
|
2267
2268
|
if (!this._isValid()) {
|
|
2268
|
-
// включаем подсветку полей
|
|
2269
2269
|
this.store.dispatch(updateCheckRequired({ isCheckRequired: true }));
|
|
2270
2270
|
return;
|
|
2271
2271
|
}
|
|
2272
|
-
// возвращаем признак как был до открытия модалки
|
|
2273
2272
|
this.store.dispatch(updateCheckRequired({ isCheckRequired: this.isCheckRequired }));
|
|
2274
|
-
|
|
2275
|
-
this.
|
|
2273
|
+
// Клонируем иммутабельный слепок данных ОДИН раз — в момент закрытия модалки с успехом
|
|
2274
|
+
this.result = {
|
|
2275
|
+
result: true,
|
|
2276
|
+
rowModel: structuredClone(this.rowModel)
|
|
2277
|
+
};
|
|
2278
|
+
this.dialogRef.close(this.result);
|
|
2276
2279
|
}
|
|
2277
2280
|
close() {
|
|
2278
2281
|
// возвращаем признак как был до открытия модалки
|
|
@@ -2281,31 +2284,34 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2281
2284
|
this.dialogRef.close(this.result);
|
|
2282
2285
|
}
|
|
2283
2286
|
_transformValues(value) {
|
|
2284
|
-
|
|
2285
|
-
|
|
2287
|
+
// ВАЖНО: Мы НЕ клонируем весь rowModel целиком, чтобы не ломать ссылки для Angular OnPush
|
|
2288
|
+
if (!this.rowModel || !this.rowModel.data)
|
|
2289
|
+
return;
|
|
2290
|
+
// 1. Диапазон дат
|
|
2286
2291
|
if (value && value.value && Array.isArray(value.value) && value.value[0]?.sysName) {
|
|
2287
2292
|
value.value.forEach((subModel) => {
|
|
2288
|
-
const findSubValue =
|
|
2293
|
+
const findSubValue = this.rowModel.data.find((c) => c.sysName === subModel.sysName);
|
|
2289
2294
|
if (findSubValue) {
|
|
2290
|
-
findSubValue.value = subModel.value;
|
|
2295
|
+
findSubValue.value = subModel.value; // Меняем только примитивное значение (value) внутри объекта
|
|
2291
2296
|
}
|
|
2292
2297
|
});
|
|
2293
2298
|
}
|
|
2294
|
-
// 2.
|
|
2299
|
+
// 2. Одиночный компонент даты (передающий id)
|
|
2295
2300
|
else if (value && value.id && !value.sysName) {
|
|
2296
|
-
const findValue =
|
|
2301
|
+
const findValue = this.rowModel.data.find((c) => c.sysName === value.id);
|
|
2297
2302
|
if (findValue) {
|
|
2298
2303
|
findValue.value = value.value;
|
|
2299
2304
|
}
|
|
2300
2305
|
}
|
|
2301
|
-
// 3.
|
|
2306
|
+
// 3. Все остальные стандартные компоненты
|
|
2302
2307
|
else if (value && value.sysName) {
|
|
2303
|
-
const findValue =
|
|
2308
|
+
const findValue = this.rowModel.data.find((c) => c.sysName === value.sysName);
|
|
2304
2309
|
if (findValue) {
|
|
2305
2310
|
findValue.value = value.value;
|
|
2306
2311
|
}
|
|
2307
2312
|
}
|
|
2308
|
-
|
|
2313
|
+
// Принудительно уведомляем модалку, что внутренности rowModel поменялись (для обновления disabled у кнопки ОК)
|
|
2314
|
+
this._detector.detectChanges();
|
|
2309
2315
|
}
|
|
2310
2316
|
_recalculateFormulaFields() {
|
|
2311
2317
|
const formulaComponents = this._getFormulaNumberComponents(this.settings.components);
|
|
@@ -2592,7 +2598,7 @@ class InputTableComponent {
|
|
|
2592
2598
|
this._detector.detectChanges();
|
|
2593
2599
|
// Если грид уже отрендерен в DOM, принудительно обновляем его данные
|
|
2594
2600
|
if (this.dataGrid?.instance) {
|
|
2595
|
-
this.dataGrid.instance.
|
|
2601
|
+
this.dataGrid.instance.repaint();
|
|
2596
2602
|
}
|
|
2597
2603
|
}
|
|
2598
2604
|
_initColumns(components) {
|
|
@@ -2636,22 +2642,27 @@ class InputTableComponent {
|
|
|
2636
2642
|
const rowData = options.data;
|
|
2637
2643
|
let displayStr = '';
|
|
2638
2644
|
if (rowData) {
|
|
2639
|
-
|
|
2640
|
-
const
|
|
2641
|
-
|
|
2642
|
-
const
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
+
// Приводим sysName компонента к нижнему регистру для безопасного поиска
|
|
2646
|
+
const baseSysName = component.sysName.toLowerCase();
|
|
2647
|
+
// Динамически ищем ключи в объекте строки, которые содержат наш sysName и суффиксы id0/id1
|
|
2648
|
+
const rowKeys = Object.keys(rowData);
|
|
2649
|
+
const startKey = rowKeys.find(k => k.toLowerCase() === `${baseSysName}-id0` || k.toLowerCase() === `${baseSysName}_id0`);
|
|
2650
|
+
const endKey = rowKeys.find(k => k.toLowerCase() === `${baseSysName}-id1` || k.toLowerCase() === `${baseSysName}_id1`);
|
|
2651
|
+
const rawStart = startKey ? rowData[startKey] : null;
|
|
2652
|
+
const rawEnd = endKey ? rowData[endKey] : null;
|
|
2645
2653
|
if (rawStart || rawEnd) {
|
|
2646
2654
|
const formatOptions = component.options.viewType === DateTypeEnum.DateTime
|
|
2647
2655
|
? { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' }
|
|
2648
2656
|
: { day: '2-digit', month: '2-digit', year: 'numeric' };
|
|
2649
|
-
|
|
2650
|
-
const
|
|
2657
|
+
// Проверяем валидность дат перед форматированием
|
|
2658
|
+
const startDate = rawStart ? new Date(rawStart) : null;
|
|
2659
|
+
const endDate = rawEnd ? new Date(rawEnd) : null;
|
|
2660
|
+
const startStr = startDate && !isNaN(startDate.getTime()) ? startDate.toLocaleDateString('ru-RU', formatOptions) : '...';
|
|
2661
|
+
const endStr = endDate && !isNaN(endDate.getTime()) ? endDate.toLocaleDateString('ru-RU', formatOptions) : '...';
|
|
2651
2662
|
displayStr = `${startStr} — ${endStr}`;
|
|
2652
2663
|
}
|
|
2653
2664
|
else {
|
|
2654
|
-
displayStr = '—';
|
|
2665
|
+
displayStr = '—';
|
|
2655
2666
|
}
|
|
2656
2667
|
}
|
|
2657
2668
|
container.textContent = displayStr;
|