sf-crud 13.2.51 → 13.2.52

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.
@@ -2218,6 +2218,12 @@ class ControlComponent {
2218
2218
  ngOnChanges(changes) {
2219
2219
  if (!changes)
2220
2220
  return;
2221
+ if (this.control?.subtype === 'file' &&
2222
+ changes['value'] &&
2223
+ !changes['value'].firstChange) {
2224
+ this.loadFiles();
2225
+ return;
2226
+ }
2221
2227
  // Sincroniza el autocomplete cuando el value llega actualizado desde el padre
2222
2228
  if ((this.control?.subtype === 'autocomplete' ||
2223
2229
  this.control?.subtype === 'autocompleteCustom') &&
@@ -2556,16 +2562,23 @@ class ControlComponent {
2556
2562
  const op = this.control.config;
2557
2563
  const url = this.crudService.getURL(op, undefined, undefined, this.context);
2558
2564
  this.generalService.genericRequest(this.control.config.method, url, formData)
2559
- .then(() => {
2565
+ .then((res) => {
2560
2566
  let separator = this.control.config?.separator || ",";
2561
- //se asume que viene namePattern
2562
- if (this.control.type == "string")
2563
- this.value = event.map(f => `${this.generalService.jsonConfig.Server}${path}/${f.name}`).join(separator);
2564
- else if (this.control.type == "array")
2565
- this.value = event.map(f => `${this.generalService.jsonConfig.Server}${path}/${f.name}`);
2566
- // SI NO TRAE namePattern, debe retornar un objeto con el nombre y href
2567
- //else if (this.control.config.namePattern && this.control.type == "array") this.value = event.map(x => x.name)
2568
- //else if (!this.control.config.namePattern && this.control.type == "array") this.value = event.map(f => `${this.generalService.jsonConfig.Server}${path}/${f.name}`)
2567
+ const blobPaths = res?.data?.blobPaths || [];
2568
+ if (blobPaths.length > 0) {
2569
+ const base = (this.generalService.jsonConfig.BlobUrl || '').replace(/\/temp\/?$/, '').replace(/\/+$/, '');
2570
+ const fullUrls = blobPaths.map((p) => `${base}${p}`);
2571
+ if (this.control.type == "string")
2572
+ this.value = fullUrls.join(separator);
2573
+ else if (this.control.type == "array")
2574
+ this.value = fullUrls;
2575
+ }
2576
+ else {
2577
+ if (this.control.type == "string")
2578
+ this.value = event.map(f => `${this.generalService.jsonConfig.Server}${path}/${f.name}`).join(separator);
2579
+ else if (this.control.type == "array")
2580
+ this.value = event.map(f => `${this.generalService.jsonConfig.Server}${path}/${f.name}`);
2581
+ }
2569
2582
  this.sendValue();
2570
2583
  let msg = !this.control.config.limit || this.control.config.limit == 1 ? "Archivo cargado correctamente!" : "Archivos cargados correctamente!";
2571
2584
  this.notificationService.addNotification({ severity: 'info', detail: msg }, this.primeChecking());