mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into refactor/sk-21
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
|
||||
export const alertConfirmationDelete = (title,type="primary") => {
|
||||
return Swal.fire({
|
||||
title: '¿Estás seguro?',
|
||||
title: '¿Está seguro?',
|
||||
text: "Esta acción es irreversible.",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
@ -28,4 +28,16 @@ export const alertSuccessMessage = (title,type="primary") => {
|
||||
icon: "success",
|
||||
timer : 2000
|
||||
})
|
||||
}
|
||||
|
||||
export const alertWarningMessage = (title,message,type="primary") => {
|
||||
return Swal.fire({
|
||||
title: title,
|
||||
text: message,
|
||||
icon: "warning",
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary'
|
||||
},
|
||||
buttonsStyling: false
|
||||
})
|
||||
}
|
||||
@ -4,6 +4,7 @@ import DisenioCubierta from './disenioCubierta.js';
|
||||
import Direcciones from './direcciones.js';
|
||||
import Resumen from './resumen.js';
|
||||
import Ajax from '../../components/ajax.js';
|
||||
import { alertWarningMessage } from '../../components/alerts/sweetAlert.js';
|
||||
|
||||
|
||||
import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js';
|
||||
@ -22,6 +23,7 @@ class PresupuestoCliente {
|
||||
this.btnPrev = $('#btnPrev');
|
||||
this.btnPrint = $('#btnPrint');
|
||||
this.btnSave = $('#btnSave');
|
||||
this.btnDuplicate = $('#cloneForm');
|
||||
this.btnConfirm = $('#btnConfirm');
|
||||
this.btnUploadFile = $('#btnUploadFile')
|
||||
|
||||
@ -90,6 +92,7 @@ class PresupuestoCliente {
|
||||
this.btnNext.on('click', this.#nextStep.bind(this));
|
||||
this.btnPrev.on('click', this.#prevtStep.bind(this));
|
||||
this.btnSave.on('click', this.#savePresupuesto.bind(this));
|
||||
this.btnDuplicate.on('click', this.#clonePresupuesto.bind(this));
|
||||
this.btnConfirm.on('click', this.#confirmPresupuesto.bind(this));
|
||||
this.btnPrint.on('click', this.#printPresupuesto.bind(this));
|
||||
this.btnUploadFile.on('click', () => {
|
||||
@ -288,6 +291,10 @@ class PresupuestoCliente {
|
||||
|
||||
if (currentElement !== 'resumen-libro') {
|
||||
this.#validateCurrentForm(currentElement, nextElement);
|
||||
if (currentElement === 'cubierta-libro' && this.disenioCubierta.acabadoCubierta.getVal() == 0) {
|
||||
alertWarningMessage(window.translations.cubiertaSinAcabado, window.translations.cubiertaSinAcabadoText);
|
||||
}
|
||||
this.#goToForm(nextElement);
|
||||
}
|
||||
else {
|
||||
this.#goToForm(nextElement);
|
||||
@ -417,6 +424,7 @@ class PresupuestoCliente {
|
||||
this.btnPrev.addClass('d-none');
|
||||
this.btnNext.removeClass('d-none');
|
||||
this.btnSave.addClass('d-none');
|
||||
this.btnDuplicate.addClass('d-none');
|
||||
this.btnPrint.addClass('d-none');
|
||||
this.btnConfirm.addClass('d-none');
|
||||
break;
|
||||
@ -427,6 +435,7 @@ class PresupuestoCliente {
|
||||
this.btnPrev.removeClass('d-none');
|
||||
this.btnNext.removeClass('d-none');
|
||||
this.btnSave.removeClass('d-none');
|
||||
this.btnDuplicate.addClass('d-none');
|
||||
this.btnPrint.addClass('d-none');
|
||||
this.btnConfirm.addClass('d-none');
|
||||
break;
|
||||
@ -434,6 +443,7 @@ class PresupuestoCliente {
|
||||
case 'resumen-libro':
|
||||
this.btnPrev.removeClass('d-none');
|
||||
this.btnNext.addClass('d-none');
|
||||
this.btnDuplicate.removeClass('d-none');
|
||||
this.btnSave.removeClass('d-none');
|
||||
this.btnPrint.removeClass('d-none');
|
||||
this.btnConfirm.removeClass('d-none');
|
||||
@ -469,6 +479,33 @@ class PresupuestoCliente {
|
||||
this.#solicitudGuardarPresupuesto(true);
|
||||
}
|
||||
|
||||
#clonePresupuesto() {
|
||||
|
||||
const id = window.location.href.split("/").pop();
|
||||
new Ajax('/presupuestoadmin/clone',
|
||||
{
|
||||
tipo: 'duplicar',
|
||||
presupuesto_id: id
|
||||
},
|
||||
{},
|
||||
(response) => {
|
||||
// check if response object has a property named 'id'
|
||||
if (response.id) {
|
||||
|
||||
const new_location = window.location.href.replace(id, response.id);
|
||||
window.location.href = new_location;
|
||||
}
|
||||
else {
|
||||
popErrorAlert("No se ha podido duplicar el presupuesto");
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.error('Error al duplicar el presupuesto:', error);
|
||||
}
|
||||
).post();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#savePresupuesto() {
|
||||
|
||||
@ -573,7 +610,7 @@ class PresupuestoCliente {
|
||||
popAlert2Hide();
|
||||
|
||||
for (let i = 0; i < response.tiradas.length; i++) {
|
||||
if(i==0){
|
||||
if (i == 0) {
|
||||
$('#eb').val(response.eb[i]);
|
||||
}
|
||||
new tarjetaTiradasPrecio(
|
||||
@ -586,7 +623,7 @@ class PresupuestoCliente {
|
||||
|
||||
if (this.actualizarTiradasEnvio) {
|
||||
this.direcciones.insertTirada(response.tiradas[i]);
|
||||
if(i==0){
|
||||
if (i == 0) {
|
||||
$('#tiradaEnvios-' + response.tiradas[i]).trigger('click');
|
||||
}
|
||||
}
|
||||
@ -618,6 +655,9 @@ class PresupuestoCliente {
|
||||
|
||||
|
||||
case 2:
|
||||
if (this.disenioCubierta.acabadoCubierta.getVal() == 0) {
|
||||
alertWarningMessage(window.translations.cubiertaSinAcabado, window.translations.cubiertaSinAcabadoText);
|
||||
}
|
||||
this.disenioCubierta.formValidation.validate();
|
||||
break;
|
||||
|
||||
@ -634,6 +674,11 @@ class PresupuestoCliente {
|
||||
|
||||
#prevtStep() {
|
||||
if (this.validationStepper._currentIndex >= 1 && this.validationStepper._currentIndex <= 4) {
|
||||
if(this.validationStepper._currentIndex == 2){
|
||||
if (this.disenioCubierta.acabadoCubierta.getVal() == 0) {
|
||||
alertWarningMessage(window.translations.cubiertaSinAcabado, window.translations.cubiertaSinAcabadoText);
|
||||
}
|
||||
}
|
||||
this.validationStepper.previous();
|
||||
}
|
||||
$('html, body').animate({ scrollTop: 0 }, 'slow');
|
||||
@ -687,7 +732,7 @@ class PresupuestoCliente {
|
||||
},
|
||||
}
|
||||
|
||||
if(this.direcciones.getSelectedTirada() != null && this.direcciones.getSelectedTirada() != undefined && this.direcciones.getSelectedTirada() > 0){
|
||||
if (this.direcciones.getSelectedTirada() != null && this.direcciones.getSelectedTirada() != undefined && this.direcciones.getSelectedTirada() > 0) {
|
||||
this.datos.selectedTirada = this.direcciones.getSelectedTirada();
|
||||
}
|
||||
|
||||
@ -717,7 +762,7 @@ class PresupuestoCliente {
|
||||
carasImpresion: this.disenioCubierta.carasCubierta.val(),
|
||||
};
|
||||
|
||||
|
||||
|
||||
this.datos.sobrecubierta = this.disenioCubierta.getSobrecubierta();
|
||||
this.datos.faja = this.disenioCubierta.getFaja();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user