mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
click para moverse del menu
This commit is contained in:
@ -29,7 +29,7 @@
|
||||
|
||||
<div class="bs-stepper-header">
|
||||
|
||||
<div class="step active" data-target="#datos-generales">
|
||||
<div class="step active titulos-menu" data-target="#datos-generales">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-info-circle ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -38,7 +38,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="step" data-target="#interior-libro">
|
||||
<div class="step titulos-menu" data-target="#interior-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-book ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -47,7 +47,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="step" data-target="#cubierta-libro">
|
||||
<div class="step titulos-menu" data-target="#cubierta-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-books ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -56,7 +56,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="step" data-target="#direcciones-libro">
|
||||
<div class="step titulos-menu" data-target="#direcciones-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-map-pins ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -65,7 +65,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="step" data-target="#resumen-libro">
|
||||
<div class="step titulos-menu" data-target="#resumen-libro">
|
||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||
<span class="bs-stepper-circle"><i class="ti ti-checkbox ti-sm"></i></span>
|
||||
<span class="bs-stepper-label">
|
||||
@ -100,7 +100,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="cubierta-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div id="cubierta-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||
<div class="row g-3">
|
||||
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta") ?>
|
||||
</div>
|
||||
|
||||
@ -5,7 +5,9 @@ import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js';
|
||||
class DatosGenerales {
|
||||
|
||||
constructor(domItem, wizardForm, validatorStepper) {
|
||||
|
||||
this.domItem = domItem;
|
||||
this.allowNext = true;
|
||||
|
||||
this.wizardStep = wizardForm.querySelector('#datos-generales');
|
||||
this.validatorStepper = validatorStepper;
|
||||
@ -116,25 +118,25 @@ class DatosGenerales {
|
||||
const value4 = $("#tirada4").val();
|
||||
let tiradas = [value];
|
||||
|
||||
if(!(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0)){
|
||||
if (!(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0)) {
|
||||
return {
|
||||
valid: false,
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
};
|
||||
}
|
||||
if(value2.length > 0 && Number.isInteger(parseInt(value2)) && parseInt(value2) > 0){
|
||||
if (value2.length > 0 && Number.isInteger(parseInt(value2)) && parseInt(value2) > 0) {
|
||||
tiradas.push(value2);
|
||||
}
|
||||
if(value3.length > 0 && Number.isInteger(parseInt(value3)) && parseInt(value3) > 0){
|
||||
if (value3.length > 0 && Number.isInteger(parseInt(value3)) && parseInt(value3) > 0) {
|
||||
tiradas.push(value3);
|
||||
}
|
||||
if(value4.length > 0 && Number.isInteger(parseInt(value4)) && parseInt(value4) > 0){
|
||||
if (value4.length > 0 && Number.isInteger(parseInt(value4)) && parseInt(value4) > 0) {
|
||||
tiradas.push(value4);
|
||||
}
|
||||
// comprobar si hay valores > 30
|
||||
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
|
||||
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
|
||||
if(noPOD && siPOD){
|
||||
if (noPOD && siPOD) {
|
||||
return {
|
||||
valid: false,
|
||||
message: "No se pueden mezclar tiradas <30 con >30",
|
||||
@ -367,7 +369,8 @@ class DatosGenerales {
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', () => {
|
||||
stepper.next();
|
||||
if (this.allowNext)
|
||||
stepper.next();
|
||||
});
|
||||
}
|
||||
|
||||
@ -528,8 +531,8 @@ class DatosGenerales {
|
||||
$('#addSobrecubierta').prop('checked', false).trigger('change');
|
||||
$(".sobrecubierta-items").addClass('d-none');
|
||||
}
|
||||
else{
|
||||
if($('#addSobrecubierta').hasClass('d-none')){
|
||||
else {
|
||||
if ($('#addSobrecubierta').hasClass('d-none')) {
|
||||
$('#addSobrecubierta').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ class Direcciones {
|
||||
this.domItem = domItem;
|
||||
this.wizardStep = wizardForm.querySelector('#direcciones-libro');
|
||||
this.validatorStepper = validatorStepper;
|
||||
this.allowNext = true;
|
||||
|
||||
this.unidadesAdd = this.domItem.find('#unidadesEnvio');
|
||||
this.btnAdd = this.domItem.find('#insertarDireccion');
|
||||
@ -19,7 +20,7 @@ class Direcciones {
|
||||
this.entregaPieCallero = this.domItem.find('#entregaPieCalle');
|
||||
|
||||
this.direccionesCliente = new ClassSelect($("#direcciones"), '/misdirecciones/getSelect2');
|
||||
|
||||
|
||||
this.divDirecciones = $(this.domItem.find('#divDirecciones'));
|
||||
this.divTiradas = this.domItem.find('#containerTiradasEnvios');
|
||||
|
||||
@ -94,13 +95,13 @@ class Direcciones {
|
||||
|
||||
let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {},
|
||||
(response) => {
|
||||
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]);
|
||||
tarjeta.setUnidades(unidades);
|
||||
tarjeta.setEntregaPalets(entregaPalets);
|
||||
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self));
|
||||
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self));
|
||||
this.divDirecciones.append(tarjeta.card);
|
||||
this.direcciones.push(tarjeta);
|
||||
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]);
|
||||
tarjeta.setUnidades(unidades);
|
||||
tarjeta.setEntregaPalets(entregaPalets);
|
||||
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self));
|
||||
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self));
|
||||
this.divDirecciones.append(tarjeta.card);
|
||||
this.direcciones.push(tarjeta);
|
||||
},
|
||||
() => {
|
||||
console.error('Error getting address');
|
||||
@ -175,7 +176,8 @@ class Direcciones {
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', () => {
|
||||
stepper.next();
|
||||
if (this.allowNext)
|
||||
stepper.next();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
class DisenioCubierta {
|
||||
|
||||
constructor(domItem, wizardForm, validatorStepper) {
|
||||
|
||||
this.domItem = domItem;
|
||||
this.allowNext = true;
|
||||
|
||||
this.wizardStep = wizardForm.querySelector('#cubierta-libro');
|
||||
this.validatorStepper = validatorStepper;
|
||||
@ -28,7 +30,7 @@ class DisenioCubierta {
|
||||
this.papelGuardas = this.domItem.find("#papelGuardas");
|
||||
this.guardasImpresas = this.domItem.find("#guardasImpresas");
|
||||
this.cabezada = this.domItem.find("#cabezada");
|
||||
|
||||
|
||||
this.cartulinaEstucada = this.domItem.find("#cartulinaEstucada");
|
||||
this.estucadoMate = this.domItem.find("#estucadoMate");
|
||||
|
||||
@ -174,7 +176,7 @@ class DisenioCubierta {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
if(datosSobrecubierta && datosSobrecubierta.papel) {
|
||||
if (datosSobrecubierta && datosSobrecubierta.papel) {
|
||||
this.sobrecubierta.trigger('click');
|
||||
this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change');
|
||||
this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho);
|
||||
@ -313,7 +315,8 @@ class DisenioCubierta {
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', () => {
|
||||
stepper.next();
|
||||
if (this.allowNext)
|
||||
stepper.next();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ class DisenioInterior {
|
||||
|
||||
this.wizardStep = wizardForm.querySelector('#interior-libro');
|
||||
this.validatorStepper = validatorStepper;
|
||||
this.allowNext = true;
|
||||
|
||||
this.disenioInterior = this.domItem.find(".disenio-interior");
|
||||
this.divPapelInterior = this.domItem.find("#divPapelInterior");
|
||||
@ -364,7 +365,8 @@ class DisenioInterior {
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', () => {
|
||||
stepper.next();
|
||||
if (this.allowNext)
|
||||
stepper.next();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +35,8 @@ class PresupuestoCliente {
|
||||
|
||||
this.divTiradasPrecios = $("#divTiradasPrecio");
|
||||
|
||||
this.titulosMenu = $(".titulos-menu");
|
||||
|
||||
this.datos = {};
|
||||
this.ajax_calcular = new Ajax('/presupuestocliente/calcular',
|
||||
{}, this.datos,
|
||||
@ -65,6 +67,8 @@ class PresupuestoCliente {
|
||||
this.btnPrev.on('click', this.#prevtStep.bind(this));
|
||||
this.btnSave.on('click', this.#savePresupuesto.bind(this));
|
||||
|
||||
this.titulosMenu.on('click', this.#handleTitulosMenu.bind(this));
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
|
||||
this.#cargarPresupuesto();
|
||||
@ -79,7 +83,7 @@ class PresupuestoCliente {
|
||||
}
|
||||
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -111,7 +115,7 @@ class PresupuestoCliente {
|
||||
|
||||
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
|
||||
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
|
||||
|
||||
|
||||
this.datosGenerales.formValidation.validateField('tirada');
|
||||
return !(noPOD && siPOD);
|
||||
}
|
||||
@ -149,16 +153,16 @@ class PresupuestoCliente {
|
||||
if (datos_to_check.posPaginasColor == "" || datos_to_check.posPaginasColor == null) {
|
||||
delete datos_to_check.posPaginasColor;
|
||||
}
|
||||
if(datos_to_check.cubierta.acabados.barniz == undefined){
|
||||
if (datos_to_check.cubierta.acabados.barniz == undefined) {
|
||||
delete datos_to_check.cubierta.acabados.barniz;
|
||||
}
|
||||
if(datos_to_check.cubierta.acabados.plastificado == undefined){
|
||||
if (datos_to_check.cubierta.acabados.plastificado == undefined) {
|
||||
delete datos_to_check.cubierta.acabados.plastificado;
|
||||
}
|
||||
if(datos_to_check.cubierta.acabados.estampado == undefined){
|
||||
if (datos_to_check.cubierta.acabados.estampado == undefined) {
|
||||
delete datos_to_check.cubierta.acabados.estampado;
|
||||
}
|
||||
if(datos_to_check.sobrecubierta.plastificado == undefined){
|
||||
if (datos_to_check.sobrecubierta.plastificado == undefined) {
|
||||
delete datos_to_check.sobrecubierta.plastificado;
|
||||
}
|
||||
|
||||
@ -242,6 +246,136 @@ class PresupuestoCliente {
|
||||
}*/
|
||||
|
||||
|
||||
#handleTitulosMenu(event) {
|
||||
|
||||
$('.titulos-menu').removeClass('crossed');
|
||||
|
||||
const nextElement = $(event.target).attr('data-target')
|
||||
const currentElement = $('.dstepper-block.active').attr('id');
|
||||
|
||||
if (currentElement === nextElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentElement !== 'resumen-libro') {
|
||||
this.#validateCurrentForm(currentElement, nextElement);
|
||||
}
|
||||
else {
|
||||
this.#goToForm(nextElement);
|
||||
}
|
||||
}
|
||||
|
||||
#goToForm(form) {
|
||||
|
||||
switch (form) {
|
||||
case '#datos-generales':
|
||||
this.validationStepper.to(1);
|
||||
break;
|
||||
|
||||
case '#interior-libro':
|
||||
this.validationStepper.to(2);
|
||||
break;
|
||||
|
||||
case '#cubierta-libro':
|
||||
this.validationStepper.to(3);
|
||||
break;
|
||||
|
||||
case '#direcciones-libro':
|
||||
this.validationStepper.to(4);
|
||||
break;
|
||||
|
||||
case '#resumen-libro':
|
||||
this.validationStepper.to(5);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#validateCurrentForm(form, nextForm) {
|
||||
|
||||
switch (form) {
|
||||
case 'datos-generales':
|
||||
this.datosGenerales.allowNext = false;
|
||||
validateForm(this.datosGenerales.formValidation).then((status) => {
|
||||
if (status !== 'Valid') {
|
||||
this.datosGenerales.allowNext = true;
|
||||
return false;
|
||||
}
|
||||
this.#goToForm(nextForm);
|
||||
this.datosGenerales.allowNext = true;
|
||||
return true;
|
||||
}).catch(error => {
|
||||
this.datosGenerales.allowNext = true;
|
||||
console.error('Error al validar:', error);
|
||||
return false;
|
||||
});
|
||||
break;
|
||||
|
||||
case 'interior-libro':
|
||||
this.disenioInterior.allowNext = false;
|
||||
validateForm(this.disenioInterior.formValidation).then((status) => {
|
||||
if (status !== 'Valid') {
|
||||
this.disenioInterior.allowNext = true;
|
||||
return false;
|
||||
}
|
||||
this.#goToForm(nextForm);
|
||||
this.disenioInterior.allowNext = true;
|
||||
return true;
|
||||
}
|
||||
).catch(error => {
|
||||
this.disenioInterior.allowNext = true;
|
||||
console.error('Error al validar:', error);
|
||||
return false;
|
||||
});
|
||||
break;
|
||||
|
||||
case 'cubierta-libro':
|
||||
this.disenioCubierta.allowNext = false;
|
||||
validateForm(this.disenioCubierta.formValidation).then((status) => {
|
||||
if (status !== 'Valid') {
|
||||
this.disenioCubierta.allowNext = true;
|
||||
return false;
|
||||
}
|
||||
this.#goToForm(nextForm);
|
||||
this.disenioCubierta.allowNext = true;
|
||||
return true;
|
||||
}
|
||||
).catch(error => {
|
||||
this.disenioCubierta.allowNext = true;
|
||||
console.error('Error al validar:', error);
|
||||
return false;
|
||||
});
|
||||
break;
|
||||
|
||||
case 'direcciones-libro':
|
||||
this.direcciones.allowNext = false;
|
||||
validateForm(this.direcciones.formValidation).then((status) => {
|
||||
if (status !== 'Valid') {
|
||||
this.direcciones.allowNext = true;
|
||||
return false;
|
||||
}
|
||||
this.#goToForm(nextForm);
|
||||
this.direcciones.allowNext = true;
|
||||
return true;
|
||||
}
|
||||
).catch(error => {
|
||||
this.direcciones.allowNext = true;
|
||||
console.error('Error al validar:', error);
|
||||
return false;
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
stepperHandler() {
|
||||
|
||||
const element = $('.fv-plugins-bootstrap5.fv-plugins-framework.active');
|
||||
@ -451,7 +585,7 @@ class PresupuestoCliente {
|
||||
},
|
||||
};
|
||||
let lomoRedondo = 0;
|
||||
if(this.disenioCubierta.disenioCubierta.filter('.selected').length > 0)
|
||||
if (this.disenioCubierta.disenioCubierta.filter('.selected').length > 0)
|
||||
lomoRedondo = this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0;
|
||||
this.datos.cubierta.lomoRedondo = lomoRedondo;
|
||||
|
||||
@ -546,6 +680,16 @@ class PresupuestoCliente {
|
||||
}
|
||||
|
||||
|
||||
async function validateForm(formValidation) {
|
||||
try {
|
||||
const validationResult = await formValidation.validate();
|
||||
return validationResult;
|
||||
} catch (error) {
|
||||
console.error('Error durante la validación:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function isValid(value) {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
|
||||
Reference in New Issue
Block a user