muchos cambios (y no los papeles)

This commit is contained in:
2024-11-14 20:43:13 +01:00
parent 923c283c22
commit c19d1ffae8
11 changed files with 277 additions and 207 deletions

View File

@ -11,6 +11,38 @@ import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js';
class PresupuestoCliente {
constructor() {
/*
// Seleccionar el header y el contenedor del offcanvas
var stepperHeader = document.querySelector('#sharedStepper');
var offcanvasBody = document.querySelector('#menu-offcanvas .offcanvas-body');
// Función para verificar el tamaño de la pantalla y mover el contenido
function adjustStepperLocation() {
if (window.innerWidth < 768) {
// Si es un dispositivo móvil o tablet, mover el stepper al offcanvas
if (offcanvasBody && stepperHeader) {
// Verificar si el stepper ya está en el offcanvas
if (!offcanvasBody.contains(stepperHeader)) {
offcanvasBody.appendChild(stepperHeader); // Mover al offcanvas
}
}
} else {
// Si es un dispositivo grande, dejar el stepper en su lugar original
var originalContainer = document.querySelector('.bs-stepper-header').parentNode;
if (originalContainer && !originalContainer.contains(stepperHeader)) {
originalContainer.appendChild(stepperHeader); // Mover de vuelta al contenedor original
}
}
}
// Llamar a la función para ajustar la ubicación al cargar
adjustStepperLocation();
// También ejecutar la función cuando cambie el tamaño de la ventana
window.addEventListener('resize', function () {
adjustStepperLocation();
});
*/
this.clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente');
this.validationStepper = new Stepper(this.clientePresupuestoWizard, {
@ -37,7 +69,7 @@ class PresupuestoCliente {
this.direcciones = new Direcciones($("#direcciones-libro"), this.clientePresupuestoWizard, this.validationStepper);
this.resumen = new Resumen($("#resumen-libro"), this.datosGenerales, this.disenioInterior, this.disenioCubierta, this.direcciones);
this.divTiradasPrecios = $("#divTiradasPrecio");
this.divTiradasPrecios = $(".divTiradasPrecio");
this.titulosMenu = $(".titulos-menu");
@ -50,7 +82,7 @@ class PresupuestoCliente {
this.actualizarTiradasEnvio = false;
this.calcularPresupuesto = false;
if(!window.location.href.includes("edit")) {
if (!window.location.href.includes("edit")) {
this.#processResumenLateral();
}
}
@ -167,7 +199,7 @@ class PresupuestoCliente {
this.actualizarTiradasEnvio = false;
if (!this.direcciones.calcularPresupuesto) {
$('#loader').modal('hide');
return;
}
@ -226,9 +258,9 @@ class PresupuestoCliente {
else {
this.#goToForm(nextElement);
}
if(!nextElement.includes('resumen-libro'))
if (!nextElement.includes('resumen-libro'))
this.#processResumenLateral();
else{
else {
$(".rl-item").addClass('d-none');
}
}
@ -259,7 +291,6 @@ class PresupuestoCliente {
default:
break;
}
$('html, body').animate({ scrollTop: 0 }, 'slow');
}
@ -380,7 +411,7 @@ class PresupuestoCliente {
}
}
#printPresupuesto(){
#printPresupuesto() {
window.open('/printpresupuestos/generar/' + window.location.href.split("/").pop(), '_blank');
}
@ -392,7 +423,7 @@ class PresupuestoCliente {
total_unidades += parseInt(element.tirada.val());
});
if(total_unidades != parseInt(this.direcciones.getSelectedTirada())){
if (total_unidades != parseInt(this.direcciones.getSelectedTirada())) {
popErrorAlert("No se puede confirmar el presupuesto. La suma de las unidades enviadas no coincide con la tirada seleccionada.");
return;
}
@ -500,7 +531,7 @@ class PresupuestoCliente {
response.precio_u[i]
);
if (this.actualizarTiradasEnvio){
if (this.actualizarTiradasEnvio) {
this.direcciones.insertTirada(tiradas[i]);
}
@ -595,7 +626,13 @@ class PresupuestoCliente {
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
prototipo: this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
ferro: this.datosGenerales.ferro.is(':checked') ? 1 : 0,
ferroDigital: this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0,
marcapaginas: this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0,
retractilado: this.datosGenerales.retractilado.is(':checked') ? 1 : 0,
retractilado5: this.datosGenerales.retractilado5.is(':checked') ? 1 : 0,
isColor: this.datosGenerales.getIsColor() ? 1 : 0,
isHq: this.disenioInterior.getIsHq() ? 1 : 0,
@ -623,6 +660,11 @@ class PresupuestoCliente {
ivaReducido: this.datosGenerales.ivaReducido.find('option:selected').val(),
servicios: {
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
'ferro': this.datosGenerales.ferro.is(':checked') ? 1 : 0,
'ferroDigital': this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0,
'marcapaginas': this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0,
'retractilado': this.datosGenerales.retractilado.is(':checked') ? 1 : 0,
'retractilado5': this.datosGenerales.retractilado5.is(':checked') ? 1 : 0,
},
};
let lomoRedondo = 0;
@ -766,9 +808,40 @@ function initialize(translations) {
presupuestoCliente.init();
}
document.addEventListener('DOMContentLoaded', function () {
function moveStepperHeader() {
if ($(window).width() < 768) { // Dispositivos pequeños (menos de 768px)
if (!$('.bs-stepper-header').parent().hasClass('offcanvas-body')) {
$('.bs-stepper-header').appendTo('.offcanvas-body');
}
} else { // Dispositivos medianos y grandes (768px o más)
if ($('.bs-stepper-header').parent().hasClass('offcanvas-body')) {
$('.bs-stepper-header').insertBefore('.offcanvas-body');
}
}
}
// Ejecutar la función al cargar la página
moveStepperHeader();
// Ejecutar la función al cambiar el tamaño de la ventana
window.addEventListener('resize', function () {
moveStepperHeader();
});
function moveStepperHeader() {
if ($(window).width() < 768) { // Dispositivos pequeños (menos de 768px)
if (!$('.bs-stepper-header').parent().hasClass('offcanvas-body')) {
$('.bs-stepper-header').appendTo('.offcanvas-body');
}
} else { // Dispositivos medianos y grandes (768px o más)
if ($('.bs-stepper-header').parent().hasClass('offcanvas-body')) {
$('.bs-stepper-header').insertAfter('#menu-offcanvas');
}
}
}
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
new Ajax('/translate/getTranslation', { locale: locale, translationFile: 'Presupuestos' }, {},
@ -780,3 +853,4 @@ document.addEventListener('DOMContentLoaded', function () {
});