mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
modificado disenio interior para que borre los errores
This commit is contained in:
@ -286,6 +286,15 @@ class DisenioCubierta {
|
|||||||
this.papelFaja.init();
|
this.papelFaja.init();
|
||||||
this.gramajeFaja.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));
|
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||||
|
|
||||||
// Eventos
|
// Eventos
|
||||||
|
|||||||
@ -93,6 +93,8 @@ class DisenioInterior {
|
|||||||
this.gramajeNegroForResumen = "";
|
this.gramajeNegroForResumen = "";
|
||||||
this.papelColorForResumen = "";
|
this.papelColorForResumen = "";
|
||||||
this.gramajeColorForResumen = "";
|
this.gramajeColorForResumen = "";
|
||||||
|
|
||||||
|
this.errores = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -377,72 +379,36 @@ class DisenioInterior {
|
|||||||
|
|
||||||
validate(goToNext = true) {
|
validate(goToNext = true) {
|
||||||
|
|
||||||
let errores = [];
|
this.errores = [];
|
||||||
|
|
||||||
let continueCheck = true;
|
|
||||||
|
|
||||||
// impresion interior
|
// impresion interior
|
||||||
if ($('.disenio-interior.selected').length > 0) {
|
let continueCheck = this.validateDisenioInterior();
|
||||||
$('#divImpresionInterior').removeClass('is-invalid');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
errores.push(window.translations["validation"].disenio_interior);
|
|
||||||
$('#divImpresionInterior').addClass('is-invalid');
|
|
||||||
continueCheck = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// papel interior
|
// papel interior
|
||||||
if (continueCheck) {
|
if (continueCheck) {
|
||||||
const papelSeleccionado = $('.custom-selector-papel input[type="radio"]:checked');
|
continueCheck = this.validatePapelInterior();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gramaje interior
|
// gramaje interior
|
||||||
if (continueCheck) {
|
if (continueCheck) {
|
||||||
const gramajeSeleccionado = $('.custom-selector-gramaje input[type="radio"]:checked');
|
this.validateGramajeInterior();
|
||||||
if (gramajeSeleccionado.length > 0) {
|
|
||||||
$('#divGramajeInterior').removeClass('is-invalid');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$('#divGramajeInterior').addClass('is-invalid');
|
|
||||||
errores.push(window.translations["validation"].gramaje_interior);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const skAlert = document.getElementById('sk-alert');
|
const skAlert = document.getElementById('sk-alert');
|
||||||
skAlert.innerHTML = '';
|
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 +
|
const message = window.translations["validation"].fix_errors +
|
||||||
`<ul class="mb-0">
|
`<ul class="mb-0">
|
||||||
${uniqueErrors.map(err => `<li>${err}</li>`).join('')}
|
${this.errores.map(err => `<li>${err}</li>`).join('')}
|
||||||
</ul>`;
|
</ul>`;
|
||||||
popErrorAlert(message, 'sk-alert', false);
|
popErrorAlert(message, 'sk-alert', false);
|
||||||
errores = [];
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
document.getElementById('sk-alert').innerHTML = '';
|
document.getElementById('sk-alert').innerHTML = '';
|
||||||
errores = [];
|
this.errores = [];
|
||||||
if (goToNext)
|
if (goToNext)
|
||||||
this.validatorStepper.next();
|
this.validatorStepper.next();
|
||||||
else
|
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() {
|
getTipoImpresion() {
|
||||||
@ -730,6 +748,21 @@ class DisenioInterior {
|
|||||||
else
|
else
|
||||||
this.updatePapeles();
|
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); }
|
(response) => { console.log(response); }
|
||||||
).get();
|
).get();
|
||||||
}
|
}
|
||||||
if (!this.cargando)
|
if (!this.cargando) {
|
||||||
this.gramaje = null;
|
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 {
|
else {
|
||||||
this.cargando = false;
|
this.cargando = false;
|
||||||
}
|
}
|
||||||
@ -938,9 +986,24 @@ class DisenioInterior {
|
|||||||
const element = $(event.target);
|
const element = $(event.target);
|
||||||
const gramaje = element[0].id;
|
const gramaje = element[0].id;
|
||||||
|
|
||||||
this.presupuestoCliente.calcularSolapas(event);
|
if (this.validateGramajeInterior()) {
|
||||||
this.presupuestoCliente.checkLomoInterior(event);
|
const hasError = this.errores.filter(err => err === window.translations["validation"].gramaje_interior).length > 0;
|
||||||
this.presupuestoCliente.checkForm(event);
|
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);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user