@myrtex-org/form 1.1.93 → 1.1.95
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/date/input-date.component.mjs +1 -11
- package/esm2022/lib/modules/object-form/components/elements/input/table/components/input-table-modal/input-table-modal.component.mjs +1 -13
- package/esm2022/lib/modules/object-form/components/elements/input/table/input-table.component.mjs +1 -23
- package/esm2022/lib/modules/object-form/factories/component-factory/component-factory.directive.mjs +19 -4
- package/fesm2022/myrtex-org-form.mjs +18 -47
- package/fesm2022/myrtex-org-form.mjs.map +1 -1
- package/lib/modules/object-form/components/elements/input/table/input-table.component.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1276,12 +1276,27 @@ class ComponentFactoryDirective {
|
|
|
1276
1276
|
const targetField = values.find((v) => v.sysName === this.data?.sysName);
|
|
1277
1277
|
const instance = this.dynamicComponent.instance;
|
|
1278
1278
|
if (targetField && targetField.value !== undefined && targetField.value !== null) {
|
|
1279
|
-
// Приводим к any, чтобы TS не ругался на OptionsBase
|
|
1280
1279
|
const componentOptions = this.data?.options;
|
|
1281
1280
|
// Специфичный хак для InputDate с range: true
|
|
1282
1281
|
if (this.type === 'inputDate' && componentOptions?.range && Array.isArray(targetField.value)) {
|
|
1283
|
-
|
|
1284
|
-
|
|
1282
|
+
// Проверяем, что лежит внутри массива. Если там строки, заворачиваем их в объекты, которые ждет компонент
|
|
1283
|
+
const firstElement = targetField.value[0];
|
|
1284
|
+
const secondElement = targetField.value[1];
|
|
1285
|
+
const startValue = firstElement?.sysName ? firstElement.value : firstElement;
|
|
1286
|
+
const endValue = secondElement?.sysName ? secondElement.value : secondElement;
|
|
1287
|
+
// Формируем полноценные структуры ComponentValueModel
|
|
1288
|
+
instance.modelStart = {
|
|
1289
|
+
sysName: targetField.sysName,
|
|
1290
|
+
type: targetField.type,
|
|
1291
|
+
valueType: targetField.valueType,
|
|
1292
|
+
value: startValue || null
|
|
1293
|
+
};
|
|
1294
|
+
instance.modelEnd = {
|
|
1295
|
+
sysName: targetField.sysName,
|
|
1296
|
+
type: targetField.type,
|
|
1297
|
+
valueType: targetField.valueType,
|
|
1298
|
+
value: endValue || null
|
|
1299
|
+
};
|
|
1285
1300
|
if (typeof instance._customInit === 'function') {
|
|
1286
1301
|
instance._customInit();
|
|
1287
1302
|
}
|
|
@@ -1759,7 +1774,6 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1759
1774
|
return this.settings.options.viewType === DateTypeEnum.DateTime;
|
|
1760
1775
|
}
|
|
1761
1776
|
updateValue(event) {
|
|
1762
|
-
console.log(`[DateComponent -> updateValue] [sysName: ${this.settings.sysName}] Событие от UI элемента:`, event);
|
|
1763
1777
|
if (this._isInit) {
|
|
1764
1778
|
this._isUpdatingInternal = true; // Блокируем внешние обновления на время ввода
|
|
1765
1779
|
if (this.settings.options.range) {
|
|
@@ -1781,7 +1795,6 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1781
1795
|
this.dateModel = event.value;
|
|
1782
1796
|
this.model.value = event.value;
|
|
1783
1797
|
}
|
|
1784
|
-
console.log(`[DateComponent -> updateValue] Сформирован вызов dispatchModify. Отправляемое значение:`, this._transformOutputValue());
|
|
1785
1798
|
this.dispatchModify(event);
|
|
1786
1799
|
// Снимаем блокировку чуть позже, когда Store переварит изменения
|
|
1787
1800
|
setTimeout(() => this._isUpdatingInternal = false, 600);
|
|
@@ -1819,10 +1832,7 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1819
1832
|
_initSubscriptionForValue() {
|
|
1820
1833
|
this._subscriptions$.push(this._store.select(selectValueModel(this.settings))
|
|
1821
1834
|
.subscribe((result) => {
|
|
1822
|
-
console.log(`[DateComponent -> Store Subscription] [sysName: ${this.settings.sysName}] Получено из Store:`, structuredClone(result));
|
|
1823
1835
|
if (!result || this._isUpdatingInternal) {
|
|
1824
|
-
if (this._isUpdatingInternal)
|
|
1825
|
-
console.log(`[DateComponent] Пропущено обновление из Store, так как _isUpdatingInternal = true`);
|
|
1826
1836
|
return;
|
|
1827
1837
|
}
|
|
1828
1838
|
// Если компонент уже инициализирован, проверяем, нужно ли обновляться.
|
|
@@ -1850,7 +1860,6 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1850
1860
|
}));
|
|
1851
1861
|
}
|
|
1852
1862
|
_customInit() {
|
|
1853
|
-
console.log(`[DateComponent -> _customInit] [sysName: ${this.settings.sysName}] Настройка локальных моделей. Текущее состояние range:`, this.settings.options.range);
|
|
1854
1863
|
if (this.settings.options.range) {
|
|
1855
1864
|
if (!this.modelStart) {
|
|
1856
1865
|
this.modelStart = defaultValueModel(this.settings);
|
|
@@ -1876,7 +1885,6 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1876
1885
|
else {
|
|
1877
1886
|
this.dateModel = this.model.value;
|
|
1878
1887
|
}
|
|
1879
|
-
console.log(`[DateComponent -> _customInit] Результат инициализации: dateModel =`, this.dateModel, 'modelCounter =', this.modelCounter);
|
|
1880
1888
|
this._isInit = true;
|
|
1881
1889
|
this._detector.markForCheck();
|
|
1882
1890
|
}
|
|
@@ -1884,7 +1892,6 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1884
1892
|
const start = new Date(startDate);
|
|
1885
1893
|
const end = new Date(endDate);
|
|
1886
1894
|
if (isNaN(start.getTime()) || isNaN(end.getTime())) {
|
|
1887
|
-
console.error('Invalid date format');
|
|
1888
1895
|
return 0;
|
|
1889
1896
|
}
|
|
1890
1897
|
const differenceInMs = Math.abs(end.getTime() - start.getTime());
|
|
@@ -1894,11 +1901,9 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1894
1901
|
if (startDate) {
|
|
1895
1902
|
const start = new Date(startDate);
|
|
1896
1903
|
if (isNaN(start.getTime())) {
|
|
1897
|
-
console.error('Invalid start date format');
|
|
1898
1904
|
return startDate;
|
|
1899
1905
|
}
|
|
1900
1906
|
if (!Number.isInteger(days) || days < 0) {
|
|
1901
|
-
console.error('Days must be a non-negative integer');
|
|
1902
1907
|
return startDate;
|
|
1903
1908
|
}
|
|
1904
1909
|
let newDate = new Date(start.getTime() + days * this._millisecondsInDay);
|
|
@@ -2230,14 +2235,9 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2230
2235
|
this.settings = data.settings;
|
|
2231
2236
|
this.rowModel = data.rowModel;
|
|
2232
2237
|
this.isCheckRequired = data.isCheckRequired;
|
|
2233
|
-
console.log('[Modal -> Constructor] Данные, пришедшие в модалку:', {
|
|
2234
|
-
title: data.title,
|
|
2235
|
-
rowModel: structuredClone(data.rowModel)
|
|
2236
|
-
});
|
|
2237
2238
|
this.result = { result: false, rowModel: this.rowModel };
|
|
2238
2239
|
}
|
|
2239
2240
|
componentValueChanged(valueModel) {
|
|
2240
|
-
console.log('[Modal -> componentValueChanged] Изменение компонента. Пришло значение:', structuredClone(valueModel));
|
|
2241
2241
|
if (Array.isArray(valueModel) && valueModel.length > 0) {
|
|
2242
2242
|
// Проверяем, это элементы диапазона дат (одинаковый sysName) или это разные компоненты
|
|
2243
2243
|
const firstSysName = valueModel[0].sysName;
|
|
@@ -2264,9 +2264,7 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2264
2264
|
this.emptyRow = this.rowModel.data.every(x => this.isEmpty(x.value, x.valueType));
|
|
2265
2265
|
}
|
|
2266
2266
|
ok() {
|
|
2267
|
-
console.log('[Modal -> OK] Попытка сохранения. Текущая модель перед закрытием:', structuredClone(this.rowModel));
|
|
2268
2267
|
if (!this._isValid()) {
|
|
2269
|
-
console.warn('[Modal -> OK] Форма не валидна!');
|
|
2270
2268
|
// включаем подсветку полей
|
|
2271
2269
|
this.store.dispatch(updateCheckRequired({ isCheckRequired: true }));
|
|
2272
2270
|
return;
|
|
@@ -2285,15 +2283,10 @@ class InputTableModalComponent extends ModalServiceComponent {
|
|
|
2285
2283
|
_transformValues(value) {
|
|
2286
2284
|
const cloneRowModel = structuredClone(this.rowModel);
|
|
2287
2285
|
const findValue = cloneRowModel.data.find((c) => c.sysName === value.sysName);
|
|
2288
|
-
console.log(`[Modal -> _transformValues] Пытаемся обновить поле "${value.sysName}". Новое записываемое значение:`, value.value);
|
|
2289
2286
|
if (findValue) {
|
|
2290
2287
|
findValue.value = value.value; // Теперь сюда запишется массив ['2026-05-05', '2026-05-07']
|
|
2291
2288
|
}
|
|
2292
|
-
else {
|
|
2293
|
-
console.warn(`[Modal -> _transformValues] Поле с sysName "${value.sysName}" не найдено в rowModel.data`);
|
|
2294
|
-
}
|
|
2295
2289
|
this.rowModel = cloneRowModel;
|
|
2296
|
-
console.log('[Modal -> _transformValues] Состояние rowModel.data после обновления:', structuredClone(this.rowModel.data));
|
|
2297
2290
|
}
|
|
2298
2291
|
_recalculateFormulaFields() {
|
|
2299
2292
|
const formulaComponents = this._getFormulaNumberComponents(this.settings.components);
|
|
@@ -2467,7 +2460,6 @@ class InputTableComponent {
|
|
|
2467
2460
|
row.data.forEach((cell) => {
|
|
2468
2461
|
// 1. Если пришла строка со слэшем — парсим в массив
|
|
2469
2462
|
if (cell.type === 'inputDate' && typeof cell.value === 'string' && cell.value.includes('/')) {
|
|
2470
|
-
console.log(`[Table <- Store Parsing] Восстанавливаем range-дату:`, cell.value);
|
|
2471
2463
|
cell.value = cell.value.split('/');
|
|
2472
2464
|
}
|
|
2473
2465
|
// 2. ЗАЩИТА: Если бэк прислал null, но у нас в текущей модели таблицы КУДА-ТО УЖЕ введена дата
|
|
@@ -2476,7 +2468,6 @@ class InputTableComponent {
|
|
|
2476
2468
|
const currentRow = this._rows?.find((r) => r.id === row.id);
|
|
2477
2469
|
const currentCell = currentRow?.data?.find((c) => c.sysName === cell.sysName);
|
|
2478
2470
|
if (currentCell && currentCell.value) {
|
|
2479
|
-
console.warn(`[Table Protection] Бэк прислал null для ${cell.sysName}, но мы удерживаем текущее значение:`, currentCell.value);
|
|
2480
2471
|
// Не даем занулить! Возвращаем ей текущее валидное значение из UI
|
|
2481
2472
|
cell.value = structuredClone(currentCell.value);
|
|
2482
2473
|
}
|
|
@@ -2488,7 +2479,6 @@ class InputTableComponent {
|
|
|
2488
2479
|
// -------------------------------------------------
|
|
2489
2480
|
const isDataChanged = JSON.stringify(this.model?.data) !== JSON.stringify(cloneResult.data);
|
|
2490
2481
|
if (isDataChanged) {
|
|
2491
|
-
console.log(`[Table -> Store Apply] [${this.settings.sysName}] Синхронизируем строки.`);
|
|
2492
2482
|
this.model = structuredClone(cloneResult);
|
|
2493
2483
|
this._rows = this._extractRows(this.model.data);
|
|
2494
2484
|
this._initDataSource(this._rows);
|
|
@@ -2556,7 +2546,6 @@ class InputTableComponent {
|
|
|
2556
2546
|
return cell;
|
|
2557
2547
|
});
|
|
2558
2548
|
}
|
|
2559
|
-
console.log('[Table -> Edit Row] Чистая модель для модалки:', structuredClone(rowModel));
|
|
2560
2549
|
this._modalService.open(InputTableModalComponent, {
|
|
2561
2550
|
title: 'Редактирование строки',
|
|
2562
2551
|
okText: 'Сохранить',
|
|
@@ -2624,7 +2613,6 @@ class InputTableComponent {
|
|
|
2624
2613
|
this._rows = [];
|
|
2625
2614
|
}
|
|
2626
2615
|
_initDataSource(data) {
|
|
2627
|
-
console.log('[Table -> _initDataSource] Сборка dataSource из rows:', structuredClone(data));
|
|
2628
2616
|
this.dataSource = data.map((item) => {
|
|
2629
2617
|
const newDataItem = {};
|
|
2630
2618
|
for (let i in item.data) {
|
|
@@ -2635,7 +2623,6 @@ class InputTableComponent {
|
|
|
2635
2623
|
newDataItem.id = item.id;
|
|
2636
2624
|
return newDataItem;
|
|
2637
2625
|
});
|
|
2638
|
-
console.log('[Table -> _initDataSource] Итоговый dataSource, переданный в DataGrid:', structuredClone(this.dataSource));
|
|
2639
2626
|
this._detector.detectChanges();
|
|
2640
2627
|
if (this.dataGrid?.instance) {
|
|
2641
2628
|
this.dataGrid.instance.refresh();
|
|
@@ -2768,28 +2755,13 @@ class InputTableComponent {
|
|
|
2768
2755
|
});
|
|
2769
2756
|
});
|
|
2770
2757
|
}
|
|
2771
|
-
// private _buildTableValueModel(): TableValueModel {
|
|
2772
|
-
// console.log('[Table -> _buildTableValueModel] Старт сборки модели для Стора. Текущие локальные _rows:', structuredClone(this._rows));
|
|
2773
|
-
// const groupedData = this._buildGroupedItems(this._rows, this.settings.options.groups || [], 0);
|
|
2774
|
-
// const totals = this._calculateTotals(this._rows);
|
|
2775
|
-
// this.model = {
|
|
2776
|
-
// sysName: this.settings.sysName,
|
|
2777
|
-
// type: this.settings.type,
|
|
2778
|
-
// data: groupedData,
|
|
2779
|
-
// totals
|
|
2780
|
-
// };
|
|
2781
|
-
// console.log('[Table -> _buildTableValueModel] Сформированная модель для отправки в Стор:', structuredClone(this.model));
|
|
2782
|
-
// return structuredClone(this.model);
|
|
2783
|
-
// }
|
|
2784
2758
|
_buildTableValueModel() {
|
|
2785
|
-
console.log('[Table -> _buildTableValueModel] Старт сборки модели для Стора.');
|
|
2786
2759
|
// 1. Пробегаемся по ТЕКУЩИМ локальным строкам таблицы и принудительно жмем массивы дат в строки
|
|
2787
2760
|
if (this._rows && Array.isArray(this._rows)) {
|
|
2788
2761
|
this._rows.forEach(row => {
|
|
2789
2762
|
if (row.data && Array.isArray(row.data)) {
|
|
2790
2763
|
row.data.forEach((cell) => {
|
|
2791
2764
|
if (cell.type === 'inputDate' && Array.isArray(cell.value)) {
|
|
2792
|
-
console.log(`[_buildTableValueModel] Найдена сырая рендж-дата в ${cell.sysName}, жмем в строку:`, cell.value);
|
|
2793
2765
|
cell.value = cell.value.join('/');
|
|
2794
2766
|
}
|
|
2795
2767
|
});
|
|
@@ -2806,7 +2778,6 @@ class InputTableComponent {
|
|
|
2806
2778
|
data: groupedData,
|
|
2807
2779
|
totals
|
|
2808
2780
|
};
|
|
2809
|
-
console.log('[Table -> _buildTableValueModel] Итоговая модель со строковыми датами для отправки в Стор:', structuredClone(this.model));
|
|
2810
2781
|
return structuredClone(this.model);
|
|
2811
2782
|
}
|
|
2812
2783
|
_buildGroupedItems(rows, groupFields, level) {
|