Se muestran los eventos asociados a la disco en la BD. No se muestran, y deberían, los recién añadidos
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { Tab1Service } from '../tab1/tab1.service';
|
||||
import { Evento } from '../evento';
|
||||
import { Router } from '@angular/router';
|
||||
import { Eventoi } from '../interfaces/eventoi';
|
||||
import { DatePipe } from '@angular/common'
|
||||
@@ -37,37 +36,47 @@ export class PromptEventoPage implements OnInit{
|
||||
onSubmit(){
|
||||
this.submitted = true;
|
||||
if (this.eventoForm.valid){
|
||||
let evento = new Evento();
|
||||
let evento: Eventoi = {
|
||||
id: null,
|
||||
discotecaID: this.tab1Service.discotecaI.discotecaID,
|
||||
nombre: '',
|
||||
localizacion: this.tab1Service.discotecaI.localizacion,
|
||||
fecha: null,
|
||||
hora: null,
|
||||
descripcion: '',
|
||||
precio1: null,
|
||||
precio2: null
|
||||
|
||||
|
||||
};
|
||||
this.asignarEvento(evento);
|
||||
|
||||
}
|
||||
}
|
||||
asignarEvento(evento: Evento){
|
||||
evento.setNombre(this.eventoForm.get('nombre').value);
|
||||
evento.setDesc(this.eventoForm.get('descripcion').value);
|
||||
asignarEvento(evento: Eventoi){
|
||||
evento.nombre = this.eventoForm.get('nombre').value;
|
||||
evento.descripcion = this.eventoForm.get('descripcion').value;
|
||||
var fecha = this.eventoForm.get('fecha').value;
|
||||
fecha = fecha.split("T")[0];
|
||||
evento.setFecha(fecha);
|
||||
var hora = this.eventoForm.get('hora').value;
|
||||
evento.fecha = fecha;
|
||||
let hora = this.eventoForm.get('hora').value;
|
||||
hora = hora.split("T")[1];
|
||||
hora = hora.split(":")[0]+(":")+hora.split(":")[1];
|
||||
evento.setHora(hora);
|
||||
evento.setPrecio1(this.eventoForm.get('precio1').value);
|
||||
evento.setPrecio2(this.eventoForm.get('precio2').value);
|
||||
evento.hora = hora;
|
||||
evento.precio1 = this.eventoForm.get('precio1').value;
|
||||
evento.precio2 = this.eventoForm.get('precio2').value;
|
||||
//evento.setDia(evento.getFecha()); el datetime de Ion devuelve un String, no se puede
|
||||
if (!this.tab1Service.eventos){
|
||||
this.tab1Service.initEventos();}
|
||||
if(!this.tab1Service.eventoForms){
|
||||
this.tab1Service.initEventoForms();}
|
||||
let eventoInterface = this.interfaceEvento(evento);
|
||||
if(this.tab1Service.editarEvento==true){
|
||||
this.tab1Service.updateEvento(eventoInterface);
|
||||
this.tab1Service.updateEvento(evento);
|
||||
//this.tab1Service.eventos[this.tab1Service.eventoIndex] = evento;
|
||||
//this.tab1Service.eventoForms[this.tab1Service.eventoIndex] = this.eventoForm;
|
||||
}
|
||||
else{
|
||||
this.tab1Service.eventos.push(evento);
|
||||
this.tab1Service.postEvento(eventoInterface);
|
||||
this.tab1Service.postEvento(evento);
|
||||
//this.tab1Service.eventos.push(evento);
|
||||
//this.tab1Service.eventoForms.push(this.eventoForm);
|
||||
}
|
||||
@@ -98,22 +107,5 @@ export class PromptEventoPage implements OnInit{
|
||||
return this.eventoForm.get('descripcion');
|
||||
}
|
||||
|
||||
interfaceEvento(evento: Evento): Eventoi{
|
||||
let eventoInterface: Eventoi;
|
||||
eventoInterface = {
|
||||
discotecaID: this.tab1Service.discotecaI.discotecaID,
|
||||
nombre: evento.nombre,
|
||||
localizacion: this.tab1Service.discotecaI.localizacion,
|
||||
fecha: evento.fecha,
|
||||
hora: evento.hora,
|
||||
descripcion: evento.descripcion,
|
||||
precio1: evento.precio1,
|
||||
precio2: evento.precio2,
|
||||
}
|
||||
|
||||
return eventoInterface;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user