imm-element-ui 2.7.0 → 2.7.1

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.
@@ -7394,6 +7394,7 @@ class GridComponent {
7394
7394
  this.autoGroupColumnDef = {
7395
7395
  minWidth: 180,
7396
7396
  };
7397
+ this.columnDefsLoadId = 0;
7397
7398
  this.singleClickEdit.set(this.isMobileOrTabletBrowser());
7398
7399
  this.searchPrmSub = toObservable(this.searchPrm).subscribe((searchPrm) => {
7399
7400
  if (searchPrm.modelName !== undefined) {
@@ -7401,19 +7402,19 @@ class GridComponent {
7401
7402
  this.searchPrmSub.unsubscribe();
7402
7403
  }
7403
7404
  });
7404
- effect(async () => {
7405
- this.columnDefs = await this.setRichValue();
7406
- this.columnDefs = gridUtils.handleI18nKey(this.toOptions().columnDefs || [], this.i18nService);
7407
- this.mainField = this.toOptions().mainField;
7408
- this.modelName = this.toOptions().modelName;
7405
+ effect(() => {
7406
+ const options = this.toOptions();
7407
+ void this.refreshColumnDefs(options);
7408
+ this.mainField = options.mainField;
7409
+ this.modelName = options.modelName;
7409
7410
  if (!this.upsert()?.subsert?.find((v) => v.subModelName === this.modelName)) {
7410
7411
  this.upsert()?.subsert?.push({
7411
- subModelName: this.toOptions().modelName,
7412
- fk: this.toOptions().fk,
7412
+ subModelName: options.modelName,
7413
+ fk: options.fk,
7413
7414
  subData: [],
7414
7415
  maptmp: new Map(),
7415
7416
  logtmp: new Map(),
7416
- reference: this.toOptions().reference,
7417
+ reference: options.reference,
7417
7418
  });
7418
7419
  }
7419
7420
  this.subIndex = this.upsert()?.subsert?.findIndex((v) => v.subModelName === this.modelName);
@@ -7425,14 +7426,19 @@ class GridComponent {
7425
7426
  this.getData();
7426
7427
  }, { allowSignalWrites: true });
7427
7428
  effect(() => {
7428
- if (this.rowData() === undefined)
7429
+ const rowData = this.rowData();
7430
+ if (rowData === undefined)
7429
7431
  return;
7430
7432
  untracked(() => {
7431
- if (this.toOptions().rowModelType === 'serverSide' && this.toOptions().serverFunc) {
7433
+ const options = this.toOptions();
7434
+ if (this.hasDynamicSelectDataColumn(options)) {
7435
+ void this.refreshColumnDefs(options);
7436
+ }
7437
+ if (options.rowModelType === 'serverSide' && options.serverFunc) {
7432
7438
  return;
7433
7439
  }
7434
- this.toOptions().rowModelType = 'clientSide';
7435
- this.toOptions().clientFunc = () => of({ data: this.rowData(), totalNum: this.rowData()?.length });
7440
+ options.rowModelType = 'clientSide';
7441
+ options.clientFunc = () => of({ data: rowData, totalNum: rowData?.length });
7436
7442
  setTimeout(() => {
7437
7443
  this.getClientData(undefined);
7438
7444
  }, 100);
@@ -7517,34 +7523,54 @@ class GridComponent {
7517
7523
  });
7518
7524
  });
7519
7525
  }
7520
- async setRichValue() {
7521
- let col = this.toOptions().columnDefs || [];
7526
+ hasDynamicSelectDataColumn(options = this.toOptions()) {
7527
+ return !!options.columnDefs?.some((item) => item?.hasOwnProperty('selectData') && typeof item.selectData === 'function');
7528
+ }
7529
+ async refreshColumnDefs(options = this.toOptions()) {
7530
+ const loadId = ++this.columnDefsLoadId;
7531
+ const columnDefs = await this.setRichValue(options);
7532
+ if (loadId !== this.columnDefsLoadId) {
7533
+ return;
7534
+ }
7535
+ this.columnDefs = gridUtils.handleI18nKey(columnDefs, this.i18nService);
7536
+ if (this.grid?.api) {
7537
+ this.grid.api.setGridOption('columnDefs', this.columnDefs);
7538
+ this.grid.api.refreshCells({
7539
+ force: true,
7540
+ suppressFlash: true,
7541
+ });
7542
+ }
7543
+ }
7544
+ async setRichValue(options = this.toOptions()) {
7545
+ let col = options.columnDefs || [];
7522
7546
  try {
7523
7547
  const processedCols = await Promise.all(col.map(async (item) => {
7524
- if (item.hasOwnProperty('fieldId') && (item.cellEditor == 'agRichSelectCellEditor' || item.cellEditor == 'agSelectCellEditor' || item.cellEditor == 'cellEditSelectFieldComponent') && !item.rowGroup) {
7548
+ const nextItem = { ...item };
7549
+ if (nextItem.hasOwnProperty('fieldId') && (nextItem.cellEditor == 'agRichSelectCellEditor' || nextItem.cellEditor == 'agSelectCellEditor' || nextItem.cellEditor == 'cellEditSelectFieldComponent') && !nextItem.rowGroup) {
7525
7550
  let values = [];
7526
- if (item.cellEditorParams && typeof item.cellEditorParams === 'function') {
7527
- item.cellEditorParams = item.cellEditorParams() || {};
7528
- values = JSON.parse(JSON.stringify(item.cellEditorParams.values || [])) || [];
7551
+ const rawCellEditorParams = typeof item.cellEditorParams === 'function' ? item.cellEditorParams() || {} : item.cellEditorParams || {};
7552
+ const cellEditorParams = { ...rawCellEditorParams };
7553
+ if (cellEditorParams.hasOwnProperty('values')) {
7554
+ values = cellEditorParams.values || [];
7529
7555
  }
7530
- if ((!item.cellEditorParams || !item.cellEditorParams.hasOwnProperty('values')) && item.hasOwnProperty('selectData') && typeof item.selectData === 'function') {
7531
- values = await item.selectData();
7556
+ if (nextItem.hasOwnProperty('selectData') && typeof nextItem.selectData === 'function') {
7557
+ values = (await item.selectData()) || [];
7532
7558
  }
7533
- item.cellEditorParams = {
7534
- ...(item.cellEditorParams || {}),
7559
+ nextItem.cellEditorParams = {
7560
+ ...cellEditorParams,
7535
7561
  valueListMaxHeight: 200,
7536
7562
  suppressMultiSelectPillRenderer: true,
7537
7563
  };
7538
- if (item.cellEditorParams.hasOwnProperty('values')) {
7539
- values = item.cellEditorParams.values;
7564
+ if (nextItem.cellEditorParams.hasOwnProperty('values') && !(nextItem.hasOwnProperty('selectData') && typeof nextItem.selectData === 'function')) {
7565
+ values = nextItem.cellEditorParams.values;
7540
7566
  }
7541
7567
  let isString = values.every((item) => typeof item === 'string');
7542
7568
  if (!isString) {
7543
- const optionValueField = item.cellEditorParams.optionValue || 'value';
7544
- const optionLabelField = item.cellEditorParams.optionLabel || 'label';
7545
- item.cellEditorParams.rawOptions = values;
7546
- item.cellEditorParams.values = values.map((item) => item?.[optionValueField]);
7547
- item.valueFormatter = (params) => {
7569
+ const optionValueField = nextItem.cellEditorParams.optionValue || 'value';
7570
+ const optionLabelField = nextItem.cellEditorParams.optionLabel || 'label';
7571
+ nextItem.cellEditorParams.rawOptions = values;
7572
+ nextItem.cellEditorParams.values = values.map((item) => item?.[optionValueField]);
7573
+ nextItem.valueFormatter = (params) => {
7548
7574
  const options = params.colDef.cellEditorParams.rawOptions;
7549
7575
  const valueField = params.colDef.cellEditorParams.optionValue || 'value';
7550
7576
  const labelField = params.colDef.cellEditorParams.optionLabel || 'label';
@@ -7566,14 +7592,14 @@ class GridComponent {
7566
7592
  return option.length > 0 ? option.map((v) => v?.[labelField]) : params.value;
7567
7593
  }
7568
7594
  };
7569
- item.valueGetter = (params) => {
7595
+ nextItem.valueGetter = (params) => {
7570
7596
  // console.log('pamrams----',params,item.field)
7571
- if ((item.cellEditor == 'agRichSelectCellEditor' || item.cellEditor == 'cellEditSelectFieldComponent') && params.data && params.data.hasOwnProperty(item.field)) {
7572
- return typeof params.data[item.field] == 'string' ? params.data[item.field].split(',') : params.data[item.field];
7597
+ if ((nextItem.cellEditor == 'agRichSelectCellEditor' || nextItem.cellEditor == 'cellEditSelectFieldComponent') && params.data && params.data.hasOwnProperty(nextItem.field)) {
7598
+ return typeof params.data[nextItem.field] == 'string' ? params.data[nextItem.field].split(',') : params.data[nextItem.field];
7573
7599
  }
7574
- return params.data ? params.data[item.field] : '';
7600
+ return params.data ? params.data[nextItem.field] : '';
7575
7601
  };
7576
- item.valueParser = (params) => {
7602
+ nextItem.valueParser = (params) => {
7577
7603
  // console.log('params----',params)
7578
7604
  const options = params.colDef.cellEditorParams.rawOptions;
7579
7605
  const valueField = params.colDef.cellEditorParams.optionValue || 'value';
@@ -7583,16 +7609,16 @@ class GridComponent {
7583
7609
  };
7584
7610
  }
7585
7611
  else {
7586
- item.cellEditorParams.values = values;
7587
- item.valueGetter = (params) => {
7588
- if ((item.cellEditor == 'agRichSelectCellEditor' || item.cellEditor == 'cellEditSelectFieldComponent') && params.data && params.data.hasOwnProperty(item.field)) {
7589
- return typeof params.data[item.field] == 'string' ? params.data[item.field].split(',') : params.data[item.field];
7612
+ nextItem.cellEditorParams.values = values;
7613
+ nextItem.valueGetter = (params) => {
7614
+ if ((nextItem.cellEditor == 'agRichSelectCellEditor' || nextItem.cellEditor == 'cellEditSelectFieldComponent') && params.data && params.data.hasOwnProperty(nextItem.field)) {
7615
+ return typeof params.data[nextItem.field] == 'string' ? params.data[nextItem.field].split(',') : params.data[nextItem.field];
7590
7616
  }
7591
- return params.data ? params.data[item.field] : '';
7617
+ return params.data ? params.data[nextItem.field] : '';
7592
7618
  };
7593
7619
  }
7594
7620
  }
7595
- return item;
7621
+ return nextItem;
7596
7622
  }));
7597
7623
  return processedCols;
7598
7624
  }
@@ -11186,7 +11212,7 @@ class PageFormComponent extends AmComponent {
11186
11212
  }
11187
11213
  this.leftPanelInitialized = true;
11188
11214
  this.leftPanelInitializedMode = this.getLeftPanelMode();
11189
- this.baseGridListSnapshot = this.gridList().map((item) => item);
11215
+ this.baseGridListSnapshot = deepClone(this.gridList(), this);
11190
11216
  const dataSource = this.getPanelDataSource();
11191
11217
  this.runLeftPanelEvent('onInit');
11192
11218
  const items = await this.loadLeftPanelItems(dataSource);