ngx-dsxlibrary 2.21.70 → 2.21.72
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.
- package/README.md +51 -0
- package/fesm2022/ngx-dsxlibrary.mjs +2475 -698
- package/fesm2022/ngx-dsxlibrary.mjs.map +1 -1
- package/ngx-dsxlibrary-2.21.72.tgz +0 -0
- package/package.json +1 -1
- package/src/assets/css/primeng_dsx_table.css +1 -2
- package/src/assets/css/sweetAlert2.css +16 -0
- package/types/ngx-dsxlibrary.d.ts +661 -111
- package/ngx-dsxlibrary-2.21.70.tgz +0 -0
package/README.md
CHANGED
|
@@ -45,6 +45,57 @@ Notas:
|
|
|
45
45
|
- Si el archivo viene en `null` o `undefined`, ese campo se omite del `FormData`.
|
|
46
46
|
- Es ideal para simplificar flujos de carga de archivos con metadata.
|
|
47
47
|
|
|
48
|
+
### Guardado y subida con `SaveEntityPostFileService`
|
|
49
|
+
|
|
50
|
+
La librería incluye un helper para flujos comunes donde se guarda una entidad
|
|
51
|
+
y, opcionalmente, se sube un archivo después de obtener el ID generado: el
|
|
52
|
+
servicio `SaveEntityPostFileService`.
|
|
53
|
+
|
|
54
|
+
- Resetea el formulario automáticamente cuando TODO (guardado + subida)
|
|
55
|
+
finaliza con éxito.
|
|
56
|
+
- Muestra diálogos amigables en errores controlados mediante `DsxMessagesService`.
|
|
57
|
+
- Acepta un flag `viewLog` para imprimir respuestas en consola en entornos
|
|
58
|
+
no productivos.
|
|
59
|
+
|
|
60
|
+
Uso básico:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { SaveEntityPostFileService } from 'ngx-dsxlibrary';
|
|
64
|
+
|
|
65
|
+
constructor(
|
|
66
|
+
private saveEntityPostFile: SaveEntityPostFileService,
|
|
67
|
+
private baseService: SomeEntityService,
|
|
68
|
+
) {}
|
|
69
|
+
|
|
70
|
+
// Guardar sin archivo
|
|
71
|
+
this.saveEntityPostFile.saveOnly(
|
|
72
|
+
this.baseService.save(this.form.getRawValue()),
|
|
73
|
+
(response) => { /* éxito: response contiene ServiceResult<number> */ },
|
|
74
|
+
(error) => { /* manejar error */ },
|
|
75
|
+
() => this.form.reset(), // reset opcional
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Guardar y luego subir archivo
|
|
79
|
+
const file = this.fileInput.files?.[0] ?? null;
|
|
80
|
+
if (file) {
|
|
81
|
+
this.saveEntityPostFile.saveWithFile(
|
|
82
|
+
this.baseService.save(this.form.getRawValue()),
|
|
83
|
+
(id, f) => this.baseService.attachFile(id, f),
|
|
84
|
+
file,
|
|
85
|
+
(response) => { /* éxito: response de la subida */ },
|
|
86
|
+
(error) => { /* manejar error */ },
|
|
87
|
+
() => { this.form.reset(); this.clearFileInput(); },
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Consejos:
|
|
93
|
+
|
|
94
|
+
- Si necesitas lógica personalizada al resetear el formulario, pasa una
|
|
95
|
+
función `resetForm` al servicio.
|
|
96
|
+
- Para depuración local, activa `viewLog: true` en las llamadas para ver la
|
|
97
|
+
respuesta de `save` y `upload` en consola.
|
|
98
|
+
|
|
48
99
|
### Fuentes compartidas (@font-face)
|
|
49
100
|
|
|
50
101
|
La librería expone un archivo CSS con `@font-face` para que cualquier proyecto consumidor lo importe una sola vez.
|