trbajando en los custom checks

This commit is contained in:
2024-10-05 19:17:52 +02:00
parent 13e3a69cd6
commit cece606bb1
25 changed files with 1801 additions and 80 deletions

View File

@ -1,26 +1,160 @@
import DatosGenerales from './datosGenerales.js';
import DisenioInterior from './disenioInterior.js';
import Ajax from '../../components/ajax.js';
class PresupuestoCliente {
function initPresupuesto(response){
constructor() {
this.clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente');
window.translations = JSON.parse(response);
this.validationStepper = new Stepper(this.clientePresupuestoWizard, {
linear: true
});
let datosGenerales = new DatosGenerales($("#datos-generales"));
datosGenerales.init();
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);
}
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.RELLENAR_PRESUPUESTO();
}
RELLENAR_PRESUPUESTO() {
$("#titulo").val("Titulo del libro");
const clienteId = $("#clienteId");
const newOption = new Option("Cliente 1", "1", 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("5");
$("#paginasColor").trigger('change');
$("#fresado").trigger("click");
$("#colorEstandar").trigger("click");
$("#offsetBlanco").trigger("click");
$("#gramaje80").prop("checked", true);
$("#gramaje80").trigger("change");
}
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:
FormValidation4.validate();
break;
case 3:
FormValidation5.validate();
break;
*/
default:
break;
}
}
#prevtStep() {
switch (this.validationStepper._currentIndex) {
case 4:
validationStepper.previous();
break;
case 3:
validationStepper.previous();
break;
case 2:
validationStepper.previous();
break;
case 1:
this.validationStepper.previous();
break;
default:
break;
}
}
}
function initialize(translations) {
window.translations = JSON.parse(translations);
let presupuestoCliente = new PresupuestoCliente();
presupuestoCliente.init();
}
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
new Ajax('/translate/getTranslation', {locale: locale, translationFile: 'Presupuestos'}, {},
initPresupuesto,
function(error){
new Ajax('/translate/getTranslation', { locale: locale, translationFile: 'Presupuestos' }, {},
initialize,
function (error) {
console.log("Error getting translations:", error);
}
).post();
});