diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js
index 63da86b8..7dd144f9 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioCubierta.js
@@ -286,6 +286,15 @@ class DisenioCubierta {
this.papelFaja.init();
this.gramajeFaja.init();
+ this.acabadoCubierta.onChange(() => {
+ if (this.acabadoCubierta.getVal() > 0) {
+ $('#alert-cubierta-sin-acabado').addClass('d-none');
+ }
+ else {
+ $('#alert-cubierta-sin-acabado').removeClass('d-none');
+ }
+ });
+
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
// Eventos
diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js
index 5e69213c..1cb00768 100644
--- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js
+++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/disenioInterior.js
@@ -93,6 +93,8 @@ class DisenioInterior {
this.gramajeNegroForResumen = "";
this.papelColorForResumen = "";
this.gramajeColorForResumen = "";
+
+ this.errores = [];
}
@@ -377,72 +379,36 @@ class DisenioInterior {
validate(goToNext = true) {
- let errores = [];
-
- let continueCheck = true;
+ this.errores = [];
// impresion interior
- if ($('.disenio-interior.selected').length > 0) {
- $('#divImpresionInterior').removeClass('is-invalid');
- }
- else {
- errores.push(window.translations["validation"].disenio_interior);
- $('#divImpresionInterior').addClass('is-invalid');
- continueCheck = false;
- }
+ let continueCheck = this.validateDisenioInterior();
// papel interior
if (continueCheck) {
- const papelSeleccionado = $('.custom-selector-papel input[type="radio"]:checked');
- if (papelSeleccionado.length > 0) {
- if (!$('#divPapelEspecialInterior').hasClass("d-none")) {
- if ($('#papelEspecialInterior').select2('data').length == 0) {
- $('#divPapelInterior').addClass('is-invalid');
- errores.push(window.translations["validation"].papel_interior_especial);
- continueCheck = false;
- }
- else {
- $('#divPapelInterior').removeClass('is-invalid');
- }
- }
- else {
- $('#divPapelInterior').removeClass('is-invalid');
- }
- } else {
- $('#divPapelInterior').addClass('is-invalid');
- errores.push(window.translations["validation"].papel_interior);
- continueCheck = false;
- }
+ continueCheck = this.validatePapelInterior();
}
// gramaje interior
if (continueCheck) {
- const gramajeSeleccionado = $('.custom-selector-gramaje input[type="radio"]:checked');
- if (gramajeSeleccionado.length > 0) {
- $('#divGramajeInterior').removeClass('is-invalid');
- }
- else {
- $('#divGramajeInterior').addClass('is-invalid');
- errores.push(window.translations["validation"].gramaje_interior);
- }
+ this.validateGramajeInterior();
}
const skAlert = document.getElementById('sk-alert');
skAlert.innerHTML = '';
- const uniqueErrors = [...new Set(errores)];
+ this.errores = [...new Set(this.errores)];
- if (uniqueErrors.length > 0) {
+ if (this.errores.length > 0) {
const message = window.translations["validation"].fix_errors +
`
- ${uniqueErrors.map(err => `- ${err}
`).join('')}
+ ${this.errores.map(err => `- ${err}
`).join('')}
`;
popErrorAlert(message, 'sk-alert', false);
- errores = [];
return false;
}
else {
document.getElementById('sk-alert').innerHTML = '';
- errores = [];
+ this.errores = [];
if (goToNext)
this.validatorStepper.next();
else
@@ -450,6 +416,58 @@ class DisenioInterior {
}
}
+ validateDisenioInterior() {
+
+ if ($('.disenio-interior.selected').length > 0) {
+ $('#divImpresionInterior').removeClass('is-invalid');
+ return true;
+ }
+ else {
+ this.errores.push(window.translations["validation"].disenio_interior);
+ $('#divImpresionInterior').addClass('is-invalid');
+ return false;
+ }
+ }
+
+ validatePapelInterior() {
+
+ const papelSeleccionado = $('.custom-selector-papel input[type="radio"]:checked');
+ if (papelSeleccionado.length > 0) {
+ if (!$('#divPapelEspecialInterior').hasClass("d-none")) {
+ if ($('#papelEspecialInterior').select2('data').length == 0) {
+ $('#divPapelInterior').addClass('is-invalid');
+ this.errores.push(window.translations["validation"].papel_interior_especial);
+ return false;
+ }
+ else {
+ $('#divPapelInterior').removeClass('is-invalid');
+ return true;
+ }
+ }
+ else {
+ $('#divPapelInterior').removeClass('is-invalid');
+ return true;
+ }
+ } else {
+ $('#divPapelInterior').addClass('is-invalid');
+ this.errores.push(window.translations["validation"].papel_interior);
+ return false;
+ }
+ }
+
+ validateGramajeInterior() {
+ const gramajeSeleccionado = $('.custom-selector-gramaje input[type="radio"]:checked');
+ if (gramajeSeleccionado.length > 0) {
+ $('#divGramajeInterior').removeClass('is-invalid');
+ return true;
+ }
+ else {
+ $('#divGramajeInterior').addClass('is-invalid');
+ this.errores.push(window.translations["validation"].gramaje_interior);
+ return false;
+ }
+ }
+
getTipoImpresion() {
@@ -730,6 +748,21 @@ class DisenioInterior {
else
this.updatePapeles();
}
+
+ if (this.validateDisenioInterior()) {
+ const hasError = this.errores.filter(err => err === window.translations["validation"].disenio_interior).length > 0;
+ if (hasError) {
+ // remove the item from this.errores
+ this.errores = this.errores.filter(err => err !== window.translations["validation"].disenio_interior);
+ }
+ if (this.errores.length == 0) {
+ document.getElementById('sk-alert').innerHTML = '';
+ }
+ else {
+ document.getElementById('sk-alert').innerHTML = document.getElementById('sk-alert').innerHTML.
+ replace(window.translations["validation"].disenio_interior, '');
+ }
+ }
}
@@ -780,8 +813,23 @@ class DisenioInterior {
(response) => { console.log(response); }
).get();
}
- if (!this.cargando)
+ if (!this.cargando) {
this.gramaje = null;
+ if (this.validatePapelInterior()) {
+ const hasError = this.errores.filter(err => err === window.translations["validation"].papel_interior).length > 0;
+ if (hasError) {
+ // remove the item from this.errores
+ this.errores = this.errores.filter(err => err !== window.translations["validation"].papel_interior);
+ }
+ if (this.errores.length == 0) {
+ document.getElementById('sk-alert').innerHTML = '';
+ }
+ else {
+ document.getElementById('sk-alert').innerHTML = document.getElementById('sk-alert').innerHTML.
+ replace(window.translations["validation"].papel_interior, '');
+ }
+ }
+ }
else {
this.cargando = false;
}
@@ -938,9 +986,24 @@ class DisenioInterior {
const element = $(event.target);
const gramaje = element[0].id;
- this.presupuestoCliente.calcularSolapas(event);
- this.presupuestoCliente.checkLomoInterior(event);
- this.presupuestoCliente.checkForm(event);
+ if (this.validateGramajeInterior()) {
+ const hasError = this.errores.filter(err => err === window.translations["validation"].gramaje_interior).length > 0;
+ if (hasError) {
+ // remove the item from this.errores
+ this.errores = this.errores.filter(err => err !== window.translations["validation"].gramaje_interior);
+ }
+ if (this.errores.length == 0) {
+ document.getElementById('sk-alert').innerHTML = '';
+ }
+ else {
+ document.getElementById('sk-alert').innerHTML = document.getElementById('sk-alert').innerHTML.
+ replace(window.translations["validation"].gramaje_interior, '');
+ }
+
+ this.presupuestoCliente.calcularSolapas(event);
+ this.presupuestoCliente.checkLomoInterior(event);
+ this.presupuestoCliente.checkForm(event);
+ };
});