ngx-dsxlibrary 1.21.39 → 1.21.41
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.
|
@@ -1210,16 +1210,7 @@ class ParameterValuesService {
|
|
|
1210
1210
|
console.warn(`Cantidad distinta: iniciales=${initialNames.length}, api=${apiNames.length}`);
|
|
1211
1211
|
}
|
|
1212
1212
|
}
|
|
1213
|
-
|
|
1214
|
-
* Obtiene un valor específico de un parámetro.
|
|
1215
|
-
* Devuelve `defaultValue` si no existe el parámetro o el índice es inválido.
|
|
1216
|
-
* Valida que el parámetro exista antes de acceder a su valor.
|
|
1217
|
-
* @param parameterName Nombre del parámetro
|
|
1218
|
-
* @param index Índice del valor dentro del array (default: 0)
|
|
1219
|
-
* @param defaultValue Valor por defecto si no existe (default: null)
|
|
1220
|
-
* @returns Valor del parámetro o defaultValue si no existe o el índice es inválido
|
|
1221
|
-
*/
|
|
1222
|
-
getValue(parameterName, index = 0, defaultValue = null) {
|
|
1213
|
+
getValue(parameterName, index = null, defaultValue = null) {
|
|
1223
1214
|
const param = this.dataParameter.find((p) => p.parameterName === parameterName);
|
|
1224
1215
|
if (!param) {
|
|
1225
1216
|
if (!this.alertedParams.has(parameterName)) {
|
|
@@ -1228,6 +1219,9 @@ class ParameterValuesService {
|
|
|
1228
1219
|
}
|
|
1229
1220
|
return defaultValue;
|
|
1230
1221
|
}
|
|
1222
|
+
if (index === null) {
|
|
1223
|
+
return param.values;
|
|
1224
|
+
}
|
|
1231
1225
|
if (index < 0 || index >= param.values.length) {
|
|
1232
1226
|
alert(`Advertencia: Índice ${index} fuera de rango para el parámetro '${parameterName}'.`);
|
|
1233
1227
|
return defaultValue;
|
|
@@ -2873,6 +2867,58 @@ class UtilityAddService {
|
|
|
2873
2867
|
this._serviceAlerta.toastrAlerts(4, 'Error', error instanceof Error ? error.message : String(error), 2);
|
|
2874
2868
|
}
|
|
2875
2869
|
}
|
|
2870
|
+
/**
|
|
2871
|
+
* Maneja la respuesta estándar de una operación HTTP que devuelve un ServiceResult<T>,
|
|
2872
|
+
* mostrando alertas y realizando acciones comunes en formularios.
|
|
2873
|
+
*
|
|
2874
|
+
* @typeParam T - Tipo de dato contenido en la propiedad data de ServiceResult.
|
|
2875
|
+
* @param response - Respuesta del servicio (debe tener isSuccess, title, message, etc.).
|
|
2876
|
+
* @param urlHome - Ruta a la que se navega si la operación es exitosa y el id es mayor a 0.
|
|
2877
|
+
* @param form - Formulario reactivo a resetear si la operación es exitosa.
|
|
2878
|
+
* @param getForm - Función para recargar el formulario (por ejemplo, para obtener datos actualizados).
|
|
2879
|
+
* @param id - Identificador usado para decidir si se navega a urlHome tras éxito.
|
|
2880
|
+
*
|
|
2881
|
+
* @example
|
|
2882
|
+
* // Uso típico en un componente con ServiceResult
|
|
2883
|
+
* this.utilityAddService.handleResponseService<MiModelo>(
|
|
2884
|
+
* response,
|
|
2885
|
+
* '/home',
|
|
2886
|
+
* this.form,
|
|
2887
|
+
* () => this.getForm(),
|
|
2888
|
+
* this.id
|
|
2889
|
+
* );
|
|
2890
|
+
*
|
|
2891
|
+
* @description
|
|
2892
|
+
* - Si response.isSuccess es true:
|
|
2893
|
+
* - Muestra alerta tipo toastr.
|
|
2894
|
+
* - Si id > 0, navega a urlHome.
|
|
2895
|
+
* - Resetea el formulario y ejecuta getForm().
|
|
2896
|
+
* - Si response.isSuccess es false:
|
|
2897
|
+
* - Muestra alerta visual personalizada con icono de error.
|
|
2898
|
+
*/
|
|
2899
|
+
handleResponseService(response, urlHome, form, getForm, id) {
|
|
2900
|
+
try {
|
|
2901
|
+
this.logIfNotProduction('handleResponse - response:', response);
|
|
2902
|
+
if (response.isSuccess) {
|
|
2903
|
+
this._serviceAlerta.toastrAlerts(1, response.title, response.message, 2);
|
|
2904
|
+
if (id > 0) {
|
|
2905
|
+
this._router.navigate([urlHome]);
|
|
2906
|
+
}
|
|
2907
|
+
getForm();
|
|
2908
|
+
form?.reset();
|
|
2909
|
+
}
|
|
2910
|
+
else {
|
|
2911
|
+
this._serviceAlerta.alertaHtmlSuccess(response.title, response.message, {
|
|
2912
|
+
icono: 'icon2/hard_drive_error.png',
|
|
2913
|
+
showConfirmButton: true,
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
catch (error) {
|
|
2918
|
+
this.logIfNotProduction('Error en handleResponseService:', error);
|
|
2919
|
+
this._serviceAlerta.toastrAlerts(4, 'Error', error instanceof Error ? error.message : String(error), 2);
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2876
2922
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UtilityAddService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2877
2923
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UtilityAddService, providedIn: 'root' });
|
|
2878
2924
|
}
|