@myrtex-org/form 1.1.82 → 1.1.84

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.
@@ -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, isArray } from 'lodash-es';
20
+ import { cloneDeep } 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';
@@ -2210,12 +2210,26 @@ class InputTableModalComponent extends ModalServiceComponent {
2210
2210
  }
2211
2211
  componentValueChanged(valueModel) {
2212
2212
  console.log('[Modal -> componentValueChanged] Изменение компонента. Пришло значение:', structuredClone(valueModel));
2213
- if (isArray(valueModel)) {
2214
- valueModel.forEach(model => {
2215
- this._transformValues(model);
2216
- });
2213
+ if (Array.isArray(valueModel) && valueModel.length > 0) {
2214
+ // Проверяем, это элементы диапазона дат (одинаковый sysName) или это разные компоненты
2215
+ const firstSysName = valueModel[0].sysName;
2216
+ const isRangeDate = valueModel.every(m => m.sysName === firstSysName && m.type === ComponentType.InputDate);
2217
+ if (isRangeDate) {
2218
+ // Собираем чистый массив значений дат [string | null, string | null]
2219
+ const rangeValues = valueModel.map(m => m.value);
2220
+ // Создаем синтетическую модель, где value — это массив дат
2221
+ const rangePayload = {
2222
+ ...valueModel[0],
2223
+ value: rangeValues
2224
+ };
2225
+ this._transformValues(rangePayload);
2226
+ }
2227
+ else {
2228
+ // Если это массив от разных компонентов (стандартная логика dispenser)
2229
+ valueModel.forEach(model => this._transformValues(model));
2230
+ }
2217
2231
  }
2218
- else {
2232
+ else if (valueModel && !Array.isArray(valueModel)) {
2219
2233
  this._transformValues(valueModel);
2220
2234
  }
2221
2235
  this._recalculateFormulaFields();
@@ -2243,17 +2257,15 @@ class InputTableModalComponent extends ModalServiceComponent {
2243
2257
  _transformValues(value) {
2244
2258
  const cloneRowModel = structuredClone(this.rowModel);
2245
2259
  const findValue = cloneRowModel.data.find((c) => c.sysName === value.sysName);
2246
- console.log(`[Modal -> _transformValues] Пытаемся обновить поле "${value.sysName}". Найдено в rowModel.data:`, structuredClone(findValue));
2247
- // const cloneRowModel = structuredClone(this.rowModel);
2248
- // const findValue: ComponentValueModel | undefined = cloneRowModel.data.find((c: ComponentValueModel) => c.sysName === value.sysName);
2260
+ console.log(`[Modal -> _transformValues] Пытаемся обновить поле "${value.sysName}". Новое записываемое значение:`, value.value);
2249
2261
  if (findValue) {
2250
- findValue.value = value.value;
2251
- console.log(`[Modal -> _transformValues] Успешно обновили "${value.sysName}". Новое значение поля:`, findValue.value);
2262
+ findValue.value = value.value; // Теперь сюда запишется массив ['2026-05-05', '2026-05-07']
2252
2263
  }
2253
2264
  else {
2254
- console.warn(`[Modal -> _transformValues] Внимание! Поле с sysName "${value.sysName}" не найдено в rowModel.data`);
2265
+ console.warn(`[Modal -> _transformValues] Поле с sysName "${value.sysName}" не найдено в rowModel.data`);
2255
2266
  }
2256
2267
  this.rowModel = cloneRowModel;
2268
+ console.log('[Modal -> _transformValues] Состояние rowModel.data после обновления:', structuredClone(this.rowModel.data));
2257
2269
  }
2258
2270
  _recalculateFormulaFields() {
2259
2271
  const formulaComponents = this._getFormulaNumberComponents(this.settings.components);
@@ -2418,12 +2430,19 @@ class InputTableComponent {
2418
2430
  }));
2419
2431
  this._subscriptions$.push(this._store.select(selectValueModel(this.settings))
2420
2432
  .subscribe((result) => {
2433
+ console.log('[Table <- Store Subscription Triggered] Данные прилетели из Стора:', structuredClone(result));
2421
2434
  const cloneResult = structuredClone(result);
2422
2435
  if (cloneResult && !Array.isArray(cloneResult) && this.model.data !== cloneResult.data) {
2436
+ console.log('[Table -> Store Apply] Данные внутри модели изменились. Начинаем extractRows...');
2423
2437
  this.model = structuredClone(cloneResult);
2424
- this._rows = this._extractRows(this.model.data);
2438
+ const extracted = this._extractRows(this.model.data);
2439
+ console.log('[Table -> Store Apply] Результат выполнения _extractRows:', structuredClone(extracted));
2440
+ this._rows = extracted;
2425
2441
  this._initDataSource(this._rows);
2426
2442
  }
2443
+ else {
2444
+ console.log('[Table -> Store Skip] Обновление пропущено (данные идентичны или не валидны)');
2445
+ }
2427
2446
  }));
2428
2447
  }
2429
2448
  ngOnDestroy() {
@@ -2465,11 +2484,12 @@ class InputTableComponent {
2465
2484
  console.log('[Table -> Edit Row] Найдено в локальном rows:', structuredClone(findRow));
2466
2485
  // const findRow: TableRowModel | undefined = this._rows.find(item => item.id === event.row.data.id);
2467
2486
  if (findRow) {
2487
+ const rowModelClone = structuredClone(findRow);
2468
2488
  this._modalService.open(InputTableModalComponent, {
2469
2489
  title: 'Редактирование строки',
2470
2490
  okText: 'Сохранить',
2471
2491
  settings: this.settings,
2472
- rowModel: findRow
2492
+ rowModel: rowModelClone
2473
2493
  }).afterClosed().subscribe(resolve => {
2474
2494
  console.log('[Table <- Modal Closed (Edit)] Результат из модалки:', structuredClone(resolve));
2475
2495
  if (resolve.result) {
@@ -2578,6 +2598,31 @@ class InputTableComponent {
2578
2598
  format: this.getFormat(component),
2579
2599
  minWidth: 160
2580
2600
  };
2601
+ if (component.type === ComponentType.InputDate && component.options.range) {
2602
+ column.calculateCellValue = (rowData) => {
2603
+ const dateRange = rowData[component.sysName];
2604
+ if (Array.isArray(dateRange) && dateRange.length === 2) {
2605
+ const formatDate = (dateStr) => {
2606
+ if (!dateStr)
2607
+ return '';
2608
+ const d = new Date(dateStr);
2609
+ if (isNaN(d.getTime()))
2610
+ return '';
2611
+ const day = String(d.getDate()).padStart(2, '0');
2612
+ const month = String(d.getMonth() + 1).padStart(2, '0');
2613
+ const year = d.getFullYear();
2614
+ return `${day}.${month}.${year}`;
2615
+ };
2616
+ const startFormatted = formatDate(dateRange[0]);
2617
+ const endFormatted = formatDate(dateRange[1]);
2618
+ if (startFormatted && endFormatted) {
2619
+ return `${startFormatted} — ${endFormatted}`;
2620
+ }
2621
+ return startFormatted || endFormatted || '';
2622
+ }
2623
+ return dateRange || '';
2624
+ };
2625
+ }
2581
2626
  if (dataType === 'boolean') {
2582
2627
  column.calculateCellValue = (rowData) => {
2583
2628
  const value = rowData[component.sysName];
@@ -2646,6 +2691,7 @@ class InputTableComponent {
2646
2691
  });
2647
2692
  }
2648
2693
  _buildTableValueModel() {
2694
+ console.log('[Table -> _buildTableValueModel] Старт сборки модели для Стора. Текущие локальные _rows:', structuredClone(this._rows));
2649
2695
  const groupedData = this._buildGroupedItems(this._rows, this.settings.options.groups || [], 0);
2650
2696
  const totals = this._calculateTotals(this._rows);
2651
2697
  this.model = {
@@ -2654,6 +2700,7 @@ class InputTableComponent {
2654
2700
  data: groupedData,
2655
2701
  totals
2656
2702
  };
2703
+ console.log('[Table -> _buildTableValueModel] Сформированная модель для отправки в Стор:', structuredClone(this.model));
2657
2704
  return structuredClone(this.model);
2658
2705
  }
2659
2706
  _buildGroupedItems(rows, groupFields, level) {