@myrtex-org/form 1.1.54 → 1.1.55
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 +30 -14
- package/esm2022/lib/modules/object-form/components/elements/input/table/input-table.component.mjs +19 -29
- package/fesm2022/myrtex-org-form.mjs +47 -41
- 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
|
@@ -1732,7 +1732,7 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1732
1732
|
}
|
|
1733
1733
|
updateValue(event) {
|
|
1734
1734
|
if (this._isInit) {
|
|
1735
|
-
this._isUpdatingInternal = true;
|
|
1735
|
+
this._isUpdatingInternal = true;
|
|
1736
1736
|
if (this.settings.options.range) {
|
|
1737
1737
|
if (!event.value || event.value.length === 0) {
|
|
1738
1738
|
this.dateModel = [];
|
|
@@ -1741,21 +1741,22 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1741
1741
|
this.modelCounter = 0;
|
|
1742
1742
|
}
|
|
1743
1743
|
else if (event.value.length === 2) {
|
|
1744
|
-
console.log(event, 'event date');
|
|
1745
1744
|
this.dateModel = [event.value[0], event.value[1]];
|
|
1746
1745
|
this.modelStart.value = event.value[0];
|
|
1747
1746
|
this.modelEnd.value = event.value[1];
|
|
1748
1747
|
this.modelCounter = this._getDaysDifference(this.modelStart.value, this.modelEnd.value);
|
|
1749
1748
|
}
|
|
1750
|
-
|
|
1749
|
+
// Упаковываем массив измененных моделей в объект, соответствующий типу InputDateTimeValueWithId
|
|
1750
|
+
this.dispatchModify({
|
|
1751
|
+
id: event.id, // сохраняем id события, полученный от mrx-input-date-time
|
|
1752
|
+
value: [structuredClone(this.modelStart), structuredClone(this.modelEnd)]
|
|
1753
|
+
});
|
|
1751
1754
|
}
|
|
1752
1755
|
else {
|
|
1753
1756
|
this.dateModel = event.value;
|
|
1754
1757
|
this.model.value = event.value;
|
|
1758
|
+
this.dispatchModify(event);
|
|
1755
1759
|
}
|
|
1756
|
-
console.log(this.dateModel, 'dateModel date');
|
|
1757
|
-
this.dispatchModify(event);
|
|
1758
|
-
// Снимаем блокировку чуть позже, когда Store переварит изменения
|
|
1759
1760
|
setTimeout(() => this._isUpdatingInternal = false, 600);
|
|
1760
1761
|
}
|
|
1761
1762
|
}
|
|
@@ -1829,15 +1830,30 @@ class InputDateComponent extends BaseFieldComponent {
|
|
|
1829
1830
|
_loadFromInputs() {
|
|
1830
1831
|
if (!this.values)
|
|
1831
1832
|
return;
|
|
1832
|
-
const
|
|
1833
|
-
if (
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1833
|
+
const valuesArray = this.values;
|
|
1834
|
+
if (this.settings.options.range) {
|
|
1835
|
+
// Ищем значения по суффиксам внутри переданного массива строки
|
|
1836
|
+
const startNode = valuesArray.find(x => x.sysName === `${this.settings.sysName}-id0`);
|
|
1837
|
+
const endNode = valuesArray.find(x => x.sysName === `${this.settings.sysName}-id1`);
|
|
1838
|
+
this.modelStart = startNode ? structuredClone(startNode) : { ...defaultValueModel(this.settings), sysName: `${this.settings.sysName}-id0` };
|
|
1839
|
+
this.modelEnd = endNode ? structuredClone(endNode) : { ...defaultValueModel(this.settings), sysName: `${this.settings.sysName}-id1` };
|
|
1840
|
+
if (this.modelStart.value && this.modelEnd.value) {
|
|
1841
|
+
this.dateModel = [this.modelStart.value, this.modelEnd.value];
|
|
1842
|
+
this.modelCounter = this._getDaysDifference(this.modelStart.value, this.modelEnd.value);
|
|
1843
|
+
}
|
|
1844
|
+
else if (this.modelStart.value) {
|
|
1845
|
+
this.dateModel = [this.modelStart.value, ''];
|
|
1846
|
+
this.modelCounter = 0;
|
|
1839
1847
|
}
|
|
1840
1848
|
else {
|
|
1849
|
+
this.dateModel = [];
|
|
1850
|
+
this.modelCounter = 0;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
else {
|
|
1854
|
+
// Логика для обычной даты без ренджа
|
|
1855
|
+
const found = valuesArray.find(x => x.sysName === this.settings.sysName);
|
|
1856
|
+
if (found) {
|
|
1841
1857
|
this.model = structuredClone(found);
|
|
1842
1858
|
this.dateModel = this.model.value;
|
|
1843
1859
|
}
|
|
@@ -2568,29 +2584,20 @@ class InputTableComponent {
|
|
|
2568
2584
|
this._rows = [];
|
|
2569
2585
|
}
|
|
2570
2586
|
_initDataSource(data) {
|
|
2587
|
+
// Маппим массив строк из Store/локального состояния в массив плоских объектов для DevExtreme
|
|
2571
2588
|
this.dataSource = data.map((item) => {
|
|
2572
2589
|
const newDataItem = {};
|
|
2573
|
-
//
|
|
2590
|
+
// Разворачиваем все дочерние элементы строки (включая itb6-id0, itb6-id1, itb6-itt0 и т.д.)
|
|
2574
2591
|
for (let i in item.data) {
|
|
2575
2592
|
newDataItem[item.data[i].sysName] = item.data[i].value;
|
|
2576
2593
|
}
|
|
2577
|
-
//
|
|
2578
|
-
this.settings.components.forEach(component => {
|
|
2579
|
-
const isRangeDate = component.type === ComponentType.InputDate && component.options?.range;
|
|
2580
|
-
if (isRangeDate) {
|
|
2581
|
-
const startKey = `${component.sysName}-id0`;
|
|
2582
|
-
const endKey = `${component.sysName}-id1`;
|
|
2583
|
-
// Клеим их в массив, который ожидает колонка
|
|
2584
|
-
newDataItem[component.sysName] = [
|
|
2585
|
-
newDataItem[startKey] || null,
|
|
2586
|
-
newDataItem[endKey] || null
|
|
2587
|
-
];
|
|
2588
|
-
}
|
|
2589
|
-
});
|
|
2594
|
+
// Обязательно сохраняем id строки, чтобы работали методы editRow и deleteRow
|
|
2590
2595
|
newDataItem.id = item.id;
|
|
2591
2596
|
return newDataItem;
|
|
2592
2597
|
});
|
|
2598
|
+
// Запускаем ручную проверку изменений, так как у компонента стоит ChangeDetectionStrategy.OnPush
|
|
2593
2599
|
this._detector.detectChanges();
|
|
2600
|
+
// Если грид уже отрендерен в DOM, принудительно обновляем его данные
|
|
2594
2601
|
if (this.dataGrid?.instance) {
|
|
2595
2602
|
this.dataGrid.instance.refresh();
|
|
2596
2603
|
}
|
|
@@ -2627,30 +2634,29 @@ class InputTableComponent {
|
|
|
2627
2634
|
caption: component.options.label || '',
|
|
2628
2635
|
columns: component.components.map(c => this._transformColumn(structuredClone(c))),
|
|
2629
2636
|
dataField: component.sysName,
|
|
2630
|
-
dataType: isRangeDate ? '
|
|
2637
|
+
dataType: isRangeDate ? 'string' : this.getDataType(component), // Оставляем string, чтобы грид не пугался объектов
|
|
2631
2638
|
format: this.getFormat(component),
|
|
2632
2639
|
minWidth: 160
|
|
2633
2640
|
};
|
|
2634
|
-
// Используем кастомный шаблон отображения ячейки для диапазона дат
|
|
2635
2641
|
if (isRangeDate) {
|
|
2636
2642
|
column.cellTemplate = (container, options) => {
|
|
2637
|
-
|
|
2643
|
+
// options.data — это весь сырой объект строки из dataSource (то, что вы прислали в логе)
|
|
2644
|
+
const rowData = options.data;
|
|
2638
2645
|
let displayStr = '';
|
|
2639
|
-
if (
|
|
2640
|
-
|
|
2641
|
-
const
|
|
2642
|
-
const
|
|
2643
|
-
? { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' }
|
|
2644
|
-
: { day: '2-digit', month: '2-digit', year: 'numeric' };
|
|
2645
|
-
const startStr = rawStart ? new Date(rawStart).toLocaleDateString('ru-RU', formatOptions) : '...';
|
|
2646
|
-
const endStr = rawEnd ? new Date(rawEnd).toLocaleDateString('ru-RU', formatOptions) : '...';
|
|
2647
|
-
// Если обе даты пустые — ничего не пишем
|
|
2646
|
+
if (rowData) {
|
|
2647
|
+
// Достаем значения напрямую по ключам с суффиксами
|
|
2648
|
+
const rawStart = rowData[`${component.sysName}-id0`];
|
|
2649
|
+
const rawEnd = rowData[`${component.sysName}-id1`];
|
|
2648
2650
|
if (rawStart || rawEnd) {
|
|
2651
|
+
const formatOptions = component.options.viewType === DateTypeEnum.DateTime
|
|
2652
|
+
? { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' }
|
|
2653
|
+
: { day: '2-digit', month: '2-digit', year: 'numeric' };
|
|
2654
|
+
const startStr = rawStart ? new Date(rawStart).toLocaleDateString('ru-RU', formatOptions) : '...';
|
|
2655
|
+
const endStr = rawEnd ? new Date(rawEnd).toLocaleDateString('ru-RU', formatOptions) : '...';
|
|
2649
2656
|
displayStr = `${startStr} — ${endStr}`;
|
|
2650
2657
|
}
|
|
2651
2658
|
}
|
|
2652
|
-
|
|
2653
|
-
container.appendChild(textNode);
|
|
2659
|
+
container.textContent = displayStr; // Безопасно пишем текст в ячейку
|
|
2654
2660
|
};
|
|
2655
2661
|
}
|
|
2656
2662
|
if (dataType === 'boolean') {
|