bug fix creación de eventos

This commit is contained in:
onsaliyo 2021-05-27 17:32:56 +02:00
parent 376417165d
commit a03582e68d
2 changed files with 25 additions and 2 deletions

View File

@ -11,6 +11,8 @@ import { Eventoi } from '../interfaces/eventoi';
styleUrls: ['./prompt-evento.page.scss'], styleUrls: ['./prompt-evento.page.scss'],
}) })
export class PromptEventoPage implements OnInit{ export class PromptEventoPage implements OnInit{
evento: Eventoi;
submitted = false; submitted = false;
editarEvento = false; editarEvento = false;
eventoForm = new FormGroup({ eventoForm = new FormGroup({
@ -36,9 +38,14 @@ export class PromptEventoPage implements OnInit{
onSubmit(){ onSubmit(){
this.submitted = true; this.submitted = true;
if (this.eventoForm.valid){ if (this.eventoForm.valid){
this.asignarEvento(this.tab1Service.eventos[this.tab1Service.eventoIndex]); if (this.tab1Service.editarEvento == true){
this.asignarEvento(this.tab1Service.eventos[this.tab1Service.eventoIndex])}
else{
this.asignarEvento(this.initEventoVacio());
};
} }
} }
asignarEvento(evento: Eventoi){ asignarEvento(evento: Eventoi){
evento.nombre = this.eventoForm.get('nombre').value; evento.nombre = this.eventoForm.get('nombre').value;
evento.descripcion = this.eventoForm.get('descripcion').value; evento.descripcion = this.eventoForm.get('descripcion').value;
@ -49,7 +56,6 @@ export class PromptEventoPage implements OnInit{
if (!this.tab1Service.editarEvento){ if (!this.tab1Service.editarEvento){
hora = hora.split("T")[1];} hora = hora.split("T")[1];}
hora = hora.split(":")[0]+(":")+hora.split(":")[1]; hora = hora.split(":")[0]+(":")+hora.split(":")[1];
console.log(hora);
evento.hora = hora; evento.hora = hora;
evento.precio1 = this.eventoForm.get('precio1').value; evento.precio1 = this.eventoForm.get('precio1').value;
evento.precio2 = this.eventoForm.get('precio2').value; evento.precio2 = this.eventoForm.get('precio2').value;
@ -84,5 +90,19 @@ export class PromptEventoPage implements OnInit{
return this.eventoForm.get('descripcion'); return this.eventoForm.get('descripcion');
} }
initEventoVacio(): Eventoi{
let evento = {
id: 0,
discotecaID: this.tab1Service.discotecaI.discotecaID,
nombre: this.tab1Service.discotecaI.localizacion,
localizacion: '',
fecha: null,
hora: null,
precio1: 0,
precio2: 0,
descripcion: ''
}
return evento;
}
} }

View File

@ -15,6 +15,9 @@ export class ReservamodalPage implements OnInit {
ngOnInit() { ngOnInit() {
this.codigoReserva = this.navParams.get('codigo'); this.codigoReserva = this.navParams.get('codigo');
this.descuento = this.navParams.get('descuento'); this.descuento = this.navParams.get('descuento');
if(!this.descuento){
this.descuento = 0;
}
} }
} }