imm-element-ui 2.6.9 → 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.
@@ -7076,6 +7076,12 @@ class UploadRenderer {
7076
7076
  this.fileList = this.toFileList(params.value);
7077
7077
  return true;
7078
7078
  }
7079
+ choose(callback) {
7080
+ if (this.isDisabled() || this.loading) {
7081
+ return;
7082
+ }
7083
+ callback();
7084
+ }
7079
7085
  uploadHandler(event, fu) {
7080
7086
  const files = Array.from(event.files || []);
7081
7087
  if (!files.length || this.isDisabled()) {
@@ -7174,32 +7180,33 @@ class UploadRenderer {
7174
7180
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: UploadRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
7175
7181
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: UploadRenderer, isStandalone: true, selector: "ng-component", ngImport: i0, template: `
7176
7182
  <div class="upload-renderer">
7177
- <p-fileUpload
7178
- #fu
7179
- auto
7180
- mode="basic"
7181
- [name]="uploadParams.name || 'file'"
7182
- [multiple]="uploadParams.multiple ?? true"
7183
- [accept]="uploadParams.accept"
7184
- [maxFileSize]="uploadParams.maxFileSize"
7185
- [fileLimit]="uploadParams.fileLimit"
7186
- [withCredentials]="uploadParams.withCredentials ?? false"
7187
- [customUpload]="true"
7188
- [disabled]="isDisabled() || loading"
7189
- mode="advanced"
7190
- [styleClass]="'upload-renderer-choose'"
7191
- (uploadHandler)="uploadHandler($event, fu)">
7192
- <ng-template
7193
- #header
7194
- let-chooseCallback="chooseCallback">
7195
- <p-button
7196
- icon="pi pi-cloud-upload"
7197
- [text]="true"
7198
- size="small"
7199
- [disabled]="isDisabled() || loading"
7200
- (onClick)="chooseCallback()" />
7201
- </ng-template>
7202
- </p-fileUpload>
7183
+ @if (!isDisabled()) {
7184
+ <p-fileUpload
7185
+ #fu
7186
+ auto
7187
+ mode="advanced"
7188
+ [name]="uploadParams.name || 'file'"
7189
+ [multiple]="uploadParams.multiple ?? true"
7190
+ [accept]="uploadParams.accept"
7191
+ [maxFileSize]="uploadParams.maxFileSize"
7192
+ [fileLimit]="uploadParams.fileLimit"
7193
+ [withCredentials]="uploadParams.withCredentials ?? false"
7194
+ [customUpload]="true"
7195
+ [disabled]="loading"
7196
+ [styleClass]="'upload-renderer-choose'"
7197
+ (uploadHandler)="uploadHandler($event, fu)">
7198
+ <ng-template
7199
+ #header
7200
+ let-chooseCallback="chooseCallback">
7201
+ <p-button
7202
+ icon="pi pi-cloud-upload"
7203
+ [text]="true"
7204
+ size="small"
7205
+ [disabled]="loading"
7206
+ (onClick)="choose(chooseCallback)" />
7207
+ </ng-template>
7208
+ </p-fileUpload>
7209
+ }
7203
7210
 
7204
7211
  <div class="upload-renderer-files">
7205
7212
  @for (file of fileList; track index; let index = $index) {
@@ -7212,13 +7219,15 @@ class UploadRenderer {
7212
7219
  (click)="$event.stopPropagation()"
7213
7220
  >{{ file }}</a
7214
7221
  >
7215
- <p-button
7216
- icon="pi pi-times"
7217
- severity="danger"
7218
- size="small"
7219
- [text]="true"
7220
- [disabled]="isDisabled() || loading"
7221
- (onClick)="deleteHandler(file, index)" />
7222
+ @if (!isDisabled()) {
7223
+ <p-button
7224
+ icon="pi pi-times"
7225
+ severity="danger"
7226
+ size="small"
7227
+ [text]="true"
7228
+ [disabled]="loading"
7229
+ (onClick)="deleteHandler(file, index)" />
7230
+ }
7222
7231
  </div>
7223
7232
  }
7224
7233
  </div>
@@ -7229,32 +7238,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
7229
7238
  type: Component,
7230
7239
  args: [{ standalone: true, imports: [ButtonModule, FileUpload], template: `
7231
7240
  <div class="upload-renderer">
7232
- <p-fileUpload
7233
- #fu
7234
- auto
7235
- mode="basic"
7236
- [name]="uploadParams.name || 'file'"
7237
- [multiple]="uploadParams.multiple ?? true"
7238
- [accept]="uploadParams.accept"
7239
- [maxFileSize]="uploadParams.maxFileSize"
7240
- [fileLimit]="uploadParams.fileLimit"
7241
- [withCredentials]="uploadParams.withCredentials ?? false"
7242
- [customUpload]="true"
7243
- [disabled]="isDisabled() || loading"
7244
- mode="advanced"
7245
- [styleClass]="'upload-renderer-choose'"
7246
- (uploadHandler)="uploadHandler($event, fu)">
7247
- <ng-template
7248
- #header
7249
- let-chooseCallback="chooseCallback">
7250
- <p-button
7251
- icon="pi pi-cloud-upload"
7252
- [text]="true"
7253
- size="small"
7254
- [disabled]="isDisabled() || loading"
7255
- (onClick)="chooseCallback()" />
7256
- </ng-template>
7257
- </p-fileUpload>
7241
+ @if (!isDisabled()) {
7242
+ <p-fileUpload
7243
+ #fu
7244
+ auto
7245
+ mode="advanced"
7246
+ [name]="uploadParams.name || 'file'"
7247
+ [multiple]="uploadParams.multiple ?? true"
7248
+ [accept]="uploadParams.accept"
7249
+ [maxFileSize]="uploadParams.maxFileSize"
7250
+ [fileLimit]="uploadParams.fileLimit"
7251
+ [withCredentials]="uploadParams.withCredentials ?? false"
7252
+ [customUpload]="true"
7253
+ [disabled]="loading"
7254
+ [styleClass]="'upload-renderer-choose'"
7255
+ (uploadHandler)="uploadHandler($event, fu)">
7256
+ <ng-template
7257
+ #header
7258
+ let-chooseCallback="chooseCallback">
7259
+ <p-button
7260
+ icon="pi pi-cloud-upload"
7261
+ [text]="true"
7262
+ size="small"
7263
+ [disabled]="loading"
7264
+ (onClick)="choose(chooseCallback)" />
7265
+ </ng-template>
7266
+ </p-fileUpload>
7267
+ }
7258
7268
 
7259
7269
  <div class="upload-renderer-files">
7260
7270
  @for (file of fileList; track index; let index = $index) {
@@ -7267,13 +7277,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
7267
7277
  (click)="$event.stopPropagation()"
7268
7278
  >{{ file }}</a
7269
7279
  >
7270
- <p-button
7271
- icon="pi pi-times"
7272
- severity="danger"
7273
- size="small"
7274
- [text]="true"
7275
- [disabled]="isDisabled() || loading"
7276
- (onClick)="deleteHandler(file, index)" />
7280
+ @if (!isDisabled()) {
7281
+ <p-button
7282
+ icon="pi pi-times"
7283
+ severity="danger"
7284
+ size="small"
7285
+ [text]="true"
7286
+ [disabled]="loading"
7287
+ (onClick)="deleteHandler(file, index)" />
7288
+ }
7277
7289
  </div>
7278
7290
  }
7279
7291
  </div>
@@ -7382,6 +7394,7 @@ class GridComponent {
7382
7394
  this.autoGroupColumnDef = {
7383
7395
  minWidth: 180,
7384
7396
  };
7397
+ this.columnDefsLoadId = 0;
7385
7398
  this.singleClickEdit.set(this.isMobileOrTabletBrowser());
7386
7399
  this.searchPrmSub = toObservable(this.searchPrm).subscribe((searchPrm) => {
7387
7400
  if (searchPrm.modelName !== undefined) {
@@ -7389,19 +7402,19 @@ class GridComponent {
7389
7402
  this.searchPrmSub.unsubscribe();
7390
7403
  }
7391
7404
  });
7392
- effect(async () => {
7393
- this.columnDefs = await this.setRichValue();
7394
- this.columnDefs = gridUtils.handleI18nKey(this.toOptions().columnDefs || [], this.i18nService);
7395
- this.mainField = this.toOptions().mainField;
7396
- 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;
7397
7410
  if (!this.upsert()?.subsert?.find((v) => v.subModelName === this.modelName)) {
7398
7411
  this.upsert()?.subsert?.push({
7399
- subModelName: this.toOptions().modelName,
7400
- fk: this.toOptions().fk,
7412
+ subModelName: options.modelName,
7413
+ fk: options.fk,
7401
7414
  subData: [],
7402
7415
  maptmp: new Map(),
7403
7416
  logtmp: new Map(),
7404
- reference: this.toOptions().reference,
7417
+ reference: options.reference,
7405
7418
  });
7406
7419
  }
7407
7420
  this.subIndex = this.upsert()?.subsert?.findIndex((v) => v.subModelName === this.modelName);
@@ -7413,14 +7426,19 @@ class GridComponent {
7413
7426
  this.getData();
7414
7427
  }, { allowSignalWrites: true });
7415
7428
  effect(() => {
7416
- if (this.rowData() === undefined)
7429
+ const rowData = this.rowData();
7430
+ if (rowData === undefined)
7417
7431
  return;
7418
7432
  untracked(() => {
7419
- 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) {
7420
7438
  return;
7421
7439
  }
7422
- this.toOptions().rowModelType = 'clientSide';
7423
- this.toOptions().clientFunc = () => of({ data: this.rowData(), totalNum: this.rowData()?.length });
7440
+ options.rowModelType = 'clientSide';
7441
+ options.clientFunc = () => of({ data: rowData, totalNum: rowData?.length });
7424
7442
  setTimeout(() => {
7425
7443
  this.getClientData(undefined);
7426
7444
  }, 100);
@@ -7444,12 +7462,12 @@ class GridComponent {
7444
7462
  this.editingFix();
7445
7463
  }
7446
7464
  withGridContext(options) {
7447
- const gridDisabled = this.gridDisable();
7465
+ this.gridDisable();
7448
7466
  return {
7449
7467
  ...options,
7450
7468
  context: {
7451
7469
  ...(options.context || {}),
7452
- gridDisabled: () => gridDisabled,
7470
+ gridDisabled: () => this.gridDisable(),
7453
7471
  grid: () => this,
7454
7472
  },
7455
7473
  };
@@ -7505,34 +7523,54 @@ class GridComponent {
7505
7523
  });
7506
7524
  });
7507
7525
  }
7508
- async setRichValue() {
7509
- 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 || [];
7510
7546
  try {
7511
7547
  const processedCols = await Promise.all(col.map(async (item) => {
7512
- 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) {
7513
7550
  let values = [];
7514
- if (item.cellEditorParams && typeof item.cellEditorParams === 'function') {
7515
- item.cellEditorParams = item.cellEditorParams() || {};
7516
- 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 || [];
7517
7555
  }
7518
- if ((!item.cellEditorParams || !item.cellEditorParams.hasOwnProperty('values')) && item.hasOwnProperty('selectData') && typeof item.selectData === 'function') {
7519
- values = await item.selectData();
7556
+ if (nextItem.hasOwnProperty('selectData') && typeof nextItem.selectData === 'function') {
7557
+ values = (await item.selectData()) || [];
7520
7558
  }
7521
- item.cellEditorParams = {
7522
- ...(item.cellEditorParams || {}),
7559
+ nextItem.cellEditorParams = {
7560
+ ...cellEditorParams,
7523
7561
  valueListMaxHeight: 200,
7524
7562
  suppressMultiSelectPillRenderer: true,
7525
7563
  };
7526
- if (item.cellEditorParams.hasOwnProperty('values')) {
7527
- values = item.cellEditorParams.values;
7564
+ if (nextItem.cellEditorParams.hasOwnProperty('values') && !(nextItem.hasOwnProperty('selectData') && typeof nextItem.selectData === 'function')) {
7565
+ values = nextItem.cellEditorParams.values;
7528
7566
  }
7529
7567
  let isString = values.every((item) => typeof item === 'string');
7530
7568
  if (!isString) {
7531
- const optionValueField = item.cellEditorParams.optionValue || 'value';
7532
- const optionLabelField = item.cellEditorParams.optionLabel || 'label';
7533
- item.cellEditorParams.rawOptions = values;
7534
- item.cellEditorParams.values = values.map((item) => item?.[optionValueField]);
7535
- 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) => {
7536
7574
  const options = params.colDef.cellEditorParams.rawOptions;
7537
7575
  const valueField = params.colDef.cellEditorParams.optionValue || 'value';
7538
7576
  const labelField = params.colDef.cellEditorParams.optionLabel || 'label';
@@ -7554,14 +7592,14 @@ class GridComponent {
7554
7592
  return option.length > 0 ? option.map((v) => v?.[labelField]) : params.value;
7555
7593
  }
7556
7594
  };
7557
- item.valueGetter = (params) => {
7595
+ nextItem.valueGetter = (params) => {
7558
7596
  // console.log('pamrams----',params,item.field)
7559
- if ((item.cellEditor == 'agRichSelectCellEditor' || item.cellEditor == 'cellEditSelectFieldComponent') && params.data && params.data.hasOwnProperty(item.field)) {
7560
- 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];
7561
7599
  }
7562
- return params.data ? params.data[item.field] : '';
7600
+ return params.data ? params.data[nextItem.field] : '';
7563
7601
  };
7564
- item.valueParser = (params) => {
7602
+ nextItem.valueParser = (params) => {
7565
7603
  // console.log('params----',params)
7566
7604
  const options = params.colDef.cellEditorParams.rawOptions;
7567
7605
  const valueField = params.colDef.cellEditorParams.optionValue || 'value';
@@ -7571,16 +7609,16 @@ class GridComponent {
7571
7609
  };
7572
7610
  }
7573
7611
  else {
7574
- item.cellEditorParams.values = values;
7575
- item.valueGetter = (params) => {
7576
- if ((item.cellEditor == 'agRichSelectCellEditor' || item.cellEditor == 'cellEditSelectFieldComponent') && params.data && params.data.hasOwnProperty(item.field)) {
7577
- 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];
7578
7616
  }
7579
- return params.data ? params.data[item.field] : '';
7617
+ return params.data ? params.data[nextItem.field] : '';
7580
7618
  };
7581
7619
  }
7582
7620
  }
7583
- return item;
7621
+ return nextItem;
7584
7622
  }));
7585
7623
  return processedCols;
7586
7624
  }
@@ -11174,7 +11212,7 @@ class PageFormComponent extends AmComponent {
11174
11212
  }
11175
11213
  this.leftPanelInitialized = true;
11176
11214
  this.leftPanelInitializedMode = this.getLeftPanelMode();
11177
- this.baseGridListSnapshot = this.gridList().map((item) => item);
11215
+ this.baseGridListSnapshot = deepClone(this.gridList(), this);
11178
11216
  const dataSource = this.getPanelDataSource();
11179
11217
  this.runLeftPanelEvent('onInit');
11180
11218
  const items = await this.loadLeftPanelItems(dataSource);