mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
158 lines
4.7 KiB
JavaScript
158 lines
4.7 KiB
JavaScript
import DatosGenerales from './datosGenerales.js';
|
|
import DisenioInterior from './disenioInterior.js';
|
|
import DisenioCubierta from './disenioCubierta.js';
|
|
import Direcciones from './direcciones.js';
|
|
import Ajax from '../../components/ajax.js';
|
|
|
|
class PresupuestoCliente {
|
|
|
|
constructor() {
|
|
this.clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente');
|
|
|
|
this.validationStepper = new Stepper(this.clientePresupuestoWizard, {
|
|
linear: true
|
|
});
|
|
|
|
this.btnNext = $('#btnNext');
|
|
this.btnPrev = $('#btnPrev');
|
|
this.btnPrint = $('#btnPrint');
|
|
this.btnSave = $('#btnSave');
|
|
this.btnConfirm = $('#btnConfirm');
|
|
|
|
this.datosGenerales = new DatosGenerales($("#datos-generales"), this.clientePresupuestoWizard, this.validationStepper);
|
|
this.disenioInterior = new DisenioInterior($("#interior-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
|
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
|
this.direcciones = new Direcciones($("#direcciones-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
|
}
|
|
|
|
|
|
init() {
|
|
|
|
this.btnNext.on('click', this.#nextStep.bind(this));
|
|
this.btnPrev.on('click', this.#prevtStep.bind(this));
|
|
|
|
// Fuerza el foco en el campo de búsqueda de select2
|
|
$(document).on('select2:open', () => {
|
|
document.querySelector('.select2-search__field').focus();
|
|
});
|
|
|
|
this.validationStepper._element.addEventListener('shown.bs-stepper', this.buttonsHandler.bind(this));
|
|
|
|
this.datosGenerales.init();
|
|
this.disenioInterior.init();
|
|
this.disenioCubierta.init();
|
|
this.direcciones.init();
|
|
|
|
this.RELLENAR_PRESUPUESTO();
|
|
|
|
}
|
|
|
|
|
|
RELLENAR_PRESUPUESTO() {
|
|
|
|
$("#titulo").val("Titulo del libro");
|
|
$("#titulo").trigger('change');
|
|
|
|
const clienteId = $("#clienteId");
|
|
const newOption = new Option("Cliente Potencial", "1817", true, true);
|
|
clienteId.append(newOption).trigger('change');
|
|
|
|
const papelFormatoId = $("#papelFormatoId");
|
|
const newOption2 = new Option("Formato 1", "1", true, true);
|
|
papelFormatoId.append(newOption2).trigger('change');
|
|
|
|
$("#paginasColor").val("6");
|
|
$("#paginasColor").trigger('change');
|
|
|
|
$("#fresado").trigger("click");
|
|
|
|
|
|
$("#colorEstandar").trigger("click");
|
|
$("#offsetBlanco").trigger("click");
|
|
|
|
setTimeout(function() {
|
|
$("#gramaje80").trigger("click");
|
|
}, 0);
|
|
|
|
setTimeout(function() {
|
|
$("#tapaDura").trigger("click");
|
|
}, 0);
|
|
|
|
}
|
|
|
|
|
|
buttonsHandler() {
|
|
switch (this.validationStepper._currentIndex + 1) {
|
|
case 0:
|
|
this.btnPrev.addClass('d-none');
|
|
this.btnNext.removeClass('d-none');
|
|
this.btnPrint.addClass('d-none');
|
|
this.btnSave.addClass('d-none');
|
|
this.btnConfirm.addClass('d-none');
|
|
break;
|
|
|
|
case 1:
|
|
this.btnPrev.removeClass('d-none');
|
|
this.btnNext.removeClass('d-none');
|
|
this.btnPrint.addClass('d-none');
|
|
this.btnSave.addClass('d-none');
|
|
this.btnConfirm.addClass('d-none');
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
#nextStep() {
|
|
|
|
switch (this.validationStepper._currentIndex) {
|
|
case 0:
|
|
this.datosGenerales.formValidation.validate();
|
|
break;
|
|
|
|
case 1:
|
|
this.disenioInterior.formValidation.validate();
|
|
break;
|
|
|
|
|
|
case 2:
|
|
this.disenioCubierta.formValidation.validate();
|
|
break;
|
|
/*
|
|
case 3:
|
|
FormValidation5.validate();
|
|
break;
|
|
*/
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
#prevtStep() {
|
|
if(this.validationStepper._currentIndex >= 1 && this.validationStepper._currentIndex <= 4)
|
|
this.validationStepper.previous();
|
|
}
|
|
}
|
|
|
|
function initialize(translations) {
|
|
|
|
window.translations = JSON.parse(translations);
|
|
|
|
let presupuestoCliente = new PresupuestoCliente();
|
|
presupuestoCliente.init();
|
|
}
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
|
|
|
new Ajax('/translate/getTranslation', { locale: locale, translationFile: 'Presupuestos' }, {},
|
|
initialize,
|
|
function (error) {
|
|
console.log("Error getting translations:", error);
|
|
}
|
|
).post();
|
|
|
|
});
|
|
|