para editar eventos. No funciona la asignación de hora (undefined).

This commit is contained in:
onsaliyo 2021-04-03 14:06:39 +02:00
parent 4ee33458dc
commit b163dee4b7
6 changed files with 45 additions and 78 deletions

View File

@ -6,7 +6,7 @@ export interface Eventoi {
nombre: string, nombre: string,
localizacion: string, localizacion: string,
fecha: Date, fecha: Date,
hora: Time, hora: Date,
descripcion: string, descripcion: string,
precio1: number, precio1: number,
precio2: number, precio2: number,

View File

@ -32,10 +32,10 @@
<ion-item> <ion-item>
<label> <label>
Hora Hora
<ion-datetime displayFormat="HH:MM"placeholder="Elegir Hora" formControlName="hora"></ion-datetime> <ion-datetime displayFormat="HH:mm"placeholder="Elegir Hora" formControlName="hora"></ion-datetime>
</label> </label>
<span <span
*ngIf="hora.errors.required && submitted"> *ngIf="hora?.errors?.required && submitted">
Tu evento necesita una hora Tu evento necesita una hora
</span> </span>
</ion-item> </ion-item>

View File

@ -48,7 +48,6 @@ export class PromptEventoPage implements OnInit{
precio1: null, precio1: null,
precio2: null precio2: null
}; };
this.asignarEvento(evento); this.asignarEvento(evento);
@ -66,24 +65,13 @@ export class PromptEventoPage implements OnInit{
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;
//evento.setDia(evento.getFecha()); el datetime de Ion devuelve un String, no se puede
if (!this.tab1Service.eventos){ if (!this.tab1Service.eventos){
this.tab1Service.initEventos();} this.tab1Service.initEventos();}
if(!this.tab1Service.eventoForms){ if(!this.tab1Service.eventoForms){
this.tab1Service.initEventoForms();} this.tab1Service.initEventoForms();}
if(this.tab1Service.editarEvento==true){ this.tab1Service.postEvento(evento);
this.tab1Service.updateEvento(evento);
//this.tab1Service.eventos[this.tab1Service.eventoIndex] = evento;
//this.tab1Service.eventoForms[this.tab1Service.eventoIndex] = this.eventoForm;
}
else{
this.tab1Service.postEvento(evento);
//this.tab1Service.eventos.push(evento);
//this.tab1Service.eventoForms.push(this.eventoForm);
} }
}
get nombre(){ get nombre(){
return this.eventoForm.get('nombre'); return this.eventoForm.get('nombre');
} }

View File

@ -86,12 +86,7 @@ export class Tab1Service implements OnInit{
precio2: new FormControl(null, Validators.required), precio2: new FormControl(null, Validators.required),
descripcion: new FormControl(null, Validators.required), descripcion: new FormControl(null, Validators.required),
}); });
thisForm.controls['nombre'].setValue(evento.nombre); thisForm.patchValue(evento);
thisForm.controls['fecha'].setValue(evento.fecha);
thisForm.controls['hora'].setValue(evento.hora);
thisForm.controls['precio1'].setValue(evento.precio1);
thisForm.controls['precio2'].setValue(evento.precio2);
thisForm.controls['descripcion'].setValue(evento.descripcion);
this.eventoForms.push(thisForm); this.eventoForms.push(thisForm);
}) })
} }
@ -122,7 +117,7 @@ getDiscoteca(discotecaId: number){
} }
updateEvento(evento: Eventoi){ updateEvento(evento: Eventoi){
} }

View File

@ -1,56 +1,33 @@
<head> <ion-header>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <ion-toolbar>
<meta charset="utf-8"> <ion-title>Eventos Próximos</ion-title>
<meta name="keywords" content=""> </ion-toolbar>
<meta name="description" content=""> </ion-header>
<meta name="page_type" content="np-template-header-footer-from-plugin">
<title>Página 1</title> <ion-content>
<link rel="stylesheet" href="nicepage.css" media="screen"> <ion-grid>
<link rel="stylesheet" href="Página-1.css" media="screen"> <ion-row>
<script class="u-script" type="text/javascript" src="jquery.js" defer=""></script> <ion-col size="12">
<script class="u-script" type="text/javascript" src="nicepage.js" defer=""></script> <div *ngIf="eventos.length>0" class="eventos">
<meta name="generator" content="Nicepage 3.0.9, nicepage.com"> <ion-list>
<link id="u-theme-google-font" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i|Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i"> <ion-item *ngFor="let evento of eventos" button (click)="mostrarEvento(evento)">
<div class="evento">
<div class="eventoHeader">
{{evento.nombre}} ·
<meta property="og:title" content="Página 1"> <ion-icon name="calendar-outline"></ion-icon>
<meta property="og:type" content="website"> {{evento.fecha}} ·
<meta name="theme-color" content="#478ac9"> <ion-icon name="cash-outline"></ion-icon>
<link rel="canonical" href="index.html"> {{evento.precio1}},{{evento.precio2}}
<meta property="og:url" content="index.html"> <ion-button (click)="editarEvento(evento);$event.stopPropagation();"><ion-icon name="pencil-outline"></ion-icon></ion-button>
</head>
<body class="u-body">
<section class="u-clearfix u-section-1" id="sec-6396">
<div class="u-clearfix u-sheet u-sheet-1">
<div class="u-clearfix u-expanded-width u-layout-wrap u-layout-wrap-1">
<div class="u-layout">
<div class="u-layout-row">
<div class="u-size-30">
<div class="u-layout-col">
<div class="u-container-style u-layout-cell u-size-60 u-layout-cell-1">
<div class="u-container-layout u-container-layout-1"></div>
</div>
</div>
</div> </div>
<div class="u-size-30"> <div class="eventoDesc">
<div class="u-layout-col"> {{evento.descripcion}}
<div class="u-container-style u-layout-cell u-size-30 u-layout-cell-2">
<div class="u-container-layout u-container-layout-2"></div>
</div>
<div class="u-container-style u-layout-cell u-size-30 u-layout-cell-3">
<div class="u-container-layout u-container-layout-3"></div>
</div>
</div>
</div> </div>
</div> </div>
</div> </ion-item>
</div> </ion-list>
</div> </div>
</section> </ion-col>
</ion-row>
</ion-grid>
</ion-content>
</body>

View File

@ -1,12 +1,19 @@
import { Component } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Eventoi } from '../interfaces/eventoi';
import { FeedService } from '../services/feed.service';
@Component({ @Component({
selector: 'app-tab2', selector: 'app-tab2',
templateUrl: 'tab2.page.html', templateUrl: 'tab2.page.html',
styleUrls: ['tab2.page.scss'] styleUrls: ['tab2.page.scss']
}) })
export class Tab2Page { export class Tab2Page implements OnInit{
constructor() {} eventos: Eventoi[];
constructor(private feedService: FeedService) {}
ngOnInit(){
this.eventos = this.feedService.eventos;
}
} }