sf-crud 13.2.54 → 13.2.56

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.
@@ -2316,11 +2316,15 @@ class ControlComponent {
2316
2316
  }
2317
2317
  return null;
2318
2318
  }
2319
- loadDefaultValues() {
2319
+ async loadDefaultValues() {
2320
2320
  if (this.control?.config && (this.control.subtype == 'dropdown' || this.control.subtype == 'multiselect' || this.control.subtype == 'group'))
2321
2321
  this.loadDataFromService();
2322
- if (this.control?.subtype == 'autocomplete' || this.control?.subtype === 'autocompleteCustom')
2323
- this.extracValueFromControlBusqueda();
2322
+ if (this.control?.subtype == 'autocomplete' || this.control?.subtype === 'autocompleteCustom') {
2323
+ await this.extracValueFromControlBusqueda();
2324
+ if (this.control.dependency && this.tempValue) {
2325
+ this.sendDependencyValue(this.tempValue);
2326
+ }
2327
+ }
2324
2328
  if (this.value && this.control.type == 'date') {
2325
2329
  this.instanceDate();
2326
2330
  }
@@ -2526,23 +2530,26 @@ class ControlComponent {
2526
2530
  this.cdr.detectChanges();
2527
2531
  });
2528
2532
  }
2529
- extracValueFromControlBusqueda() {
2533
+ async extracValueFromControlBusqueda() {
2530
2534
  const op = this.control.config;
2531
2535
  let url = this.crudService.getURL(op, undefined, undefined, this.context);
2532
2536
  url = url.replace('@query', this.value);
2533
- this.generalService.genericRequest(this.control.config.method, url)
2534
- .then((res) => {
2537
+ try {
2538
+ const res = await this.generalService.genericRequest(this.control.config.method, url);
2535
2539
  if (res.data?.length == 1 && res.data[0][this.control.field]) {
2536
2540
  this.tempValue = res.data[0];
2537
2541
  this.value = res.data[0][this.control.field];
2538
2542
  }
2539
- else
2543
+ else {
2540
2544
  this.setDefaultValue();
2541
- }).finally(() => {
2542
- this.cdr.detectChanges();
2543
- }).catch(() => {
2545
+ }
2546
+ }
2547
+ catch {
2544
2548
  this.setDefaultValue();
2545
- });
2549
+ }
2550
+ finally {
2551
+ this.cdr.detectChanges();
2552
+ }
2546
2553
  }
2547
2554
  onUpload(event) {
2548
2555
  this.uploadingFiles = true;