Refactoring

This commit is contained in:
imnavajas
2025-04-22 09:06:11 +02:00
parent ddf02f73b8
commit ed5f73db25
3 changed files with 64 additions and 70 deletions

View File

@ -14,7 +14,7 @@ class Catalogo {
this.encuadernacion = new ClassSelect($("#encuadernacion"), '/importador/getencuadernacion', "Seleccione una encuadernación");
this.compPapelNegro = new ClassSelect($("#compPapelNegro"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
this.compPapelNegro = new ClassSelect($("#negro_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
@ -37,7 +37,7 @@ class Catalogo {
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
});
this.compGramajeNegro = new ClassSelect($('#compGramajeNegro'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
this.compGramajeNegro = new ClassSelect($('#negro_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.compPapelNegro.getVal(),
@ -49,7 +49,7 @@ class Catalogo {
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
});
this.compPapelColor = new ClassSelect($("#compPapelColor"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
this.compPapelColor = new ClassSelect($("#color_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
tirada: () => this.tirada_no_pod,
@ -60,7 +60,7 @@ class Catalogo {
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
});
this.compGramajeColor = new ClassSelect($('#compGramajeColor'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
this.compGramajeColor = new ClassSelect($('#color_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.compPapelColor.getVal(),
@ -72,29 +72,29 @@ class Catalogo {
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
});
this.compPapelCubierta = new ClassSelect($("#compPapelCubierta"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
this.compPapelCubierta = new ClassSelect($("#cubierta_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: this.encuadernacion.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#compSolapasCubierta').val(),
sopalas: () => $('#cubierta_solapas_ancho').val(),
lomo: () => 0,
tipo: 'colorhq',
uso: 'cubierta',
});
this.compGramajeCubierta = new ClassSelect($('#compGramajeCubierta'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
this.compGramajeCubierta = new ClassSelect($('#cubierta_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.compPapelCubierta.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#compSolapasCubierta').val(),
sopalas: () => $('#cubierta_solapas_ancho').val(),
lomo: 0,
tipo: 'colorhq',
});
this.compPapelSobrecubierta = new ClassSelect($("#compPapelSobrecubierta"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
this.compPapelSobrecubierta = new ClassSelect($("#sobrecubierta_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: this.encuadernacion.getVal(),
tirada: () => this.tirada_no_pod,
@ -105,7 +105,7 @@ class Catalogo {
tipo: 'colorhq',
uso: 'sobrecubierta',
});
this.compGramajeSobrecubierta = new ClassSelect($('#compGramajeSobrecubierta'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
this.compGramajeSobrecubierta = new ClassSelect($('#sobrecubierta_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.compPapelSobrecubierta.getVal(),
@ -117,25 +117,25 @@ class Catalogo {
tipo: 'colorhq',
});
this.acabadoCubierta = new ClassSelect($("#compAcabadoCubierta"),
this.acabadoCubierta = new ClassSelect($("#cubierta_acabado_id"),
'/serviciosacabados/getacabados',
'',
'Seleccione acabado',
false,
{
"cubierta": 1
}
);
this.acabadosSobrecubierta = new ClassSelect($("#compAcabadoSobrecubierta"),
this.acabadosSobrecubierta = new ClassSelect($("#sobrecubierta_acabado_id"),
'/serviciosacabados/getacabados',
'',
'Seleccione acabado',
false,
{
"sobrecubierta": 1
}
);
this.sobrecubiertaItems = $('.comp_sobrecubierta_items');
this.compPaginasSobrecubierta = $('#compSobrecubierta');
this.sobrecubiertaItems = $('.sobrecubierta_items');
this.paginasSobrecubierta = $('#sobrecubierta_paginas');
}
@ -151,7 +151,7 @@ class Catalogo {
this.cliente.init();
this.tipo_impresion.select2();
this.caras_cubierta.select2();
this.compPaginasSobrecubierta.select2();
this.paginasSobrecubierta.select2();
this.encuadernacion.init();
@ -184,7 +184,7 @@ class Catalogo {
this.tipo_impresion.on("change", this.updateOpcionesComparador.bind(this));
// Al cambiar el selector de paginas de sobrecubierta
this.compPaginasSobrecubierta.on('change', this.toggleSobrecubiertaFields.bind(this));
this.paginasSobrecubierta.on('change', this.toggleSobrecubiertaFields.bind(this));
this.updateOpcionesComparador();
@ -198,12 +198,12 @@ class Catalogo {
updateOpcionesComparador() {
$('.comp_negro_items').off('change');
$('.comp_color_items').off('change');
$('.negro_items').off('change');
$('.color_items').off('change');
const selValue = this.tipo_impresion.val();
const elements_negro = $('.comp-negro-selected');
const elements_color = $('.comp-color-selected');
const elements_negro = $('.negro-selected');
const elements_color = $('.color-selected');
if (selValue.includes('color')) {
Array.from(elements_color).forEach(element => {
@ -229,7 +229,7 @@ class Catalogo {
}
toggleSobrecubiertaFields() {
if (this.compPaginasSobrecubierta.val() === '1') {
if (this.paginasSobrecubierta.val() === '1') {
this.sobrecubiertaItems.prop('disabled', false).trigger('change.select2');
} else {
this.sobrecubiertaItems.prop('disabled', true).trigger('change.select2');