From 50a47172e3cc7f248bd961d7bc105992994ba067 Mon Sep 17 00:00:00 2001 From: Sylvain Jermini Date: Thu, 4 Apr 2019 16:12:34 +0200 Subject: [PATCH] #1 ui/ux for ticket categories --- .../event-display.component.html | 60 +++++++++---------- .../event-display/event-display.component.ts | 9 +-- src/app/model/ticket-categories.ts | 11 ++++ src/app/shared/event.service.ts | 5 +- 4 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 src/app/model/ticket-categories.ts diff --git a/src/app/event-display/event-display.component.html b/src/app/event-display/event-display.component.html index df7a89f8..9d68682e 100644 --- a/src/app/event-display/event-display.component.html +++ b/src/app/event-display/event-display.component.html @@ -33,35 +33,35 @@

- -
- -
-
-
    -
  • -
    -
    - -
    -
    {{category.description}}
    -
    -
    -
    - -
    -
    -
  • -
-
- -
-
-
-
-
-
+
+
+
+
    +
  • +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
  • +
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/app/event-display/event-display.component.ts b/src/app/event-display/event-display.component.ts index 87be97cb..cc8caa5f 100644 --- a/src/app/event-display/event-display.component.ts +++ b/src/app/event-display/event-display.component.ts @@ -5,6 +5,7 @@ import { FormGroup, FormBuilder } from '@angular/forms'; import { ReservationService } from '../shared/reservation.service'; import { Event } from '../model/event'; import { TranslateService } from '@ngx-translate/core'; +import { TicketCategories } from '../model/ticket-categories'; @Component({ selector: 'app-event-display', @@ -14,7 +15,7 @@ import { TranslateService } from '@ngx-translate/core'; export class EventDisplayComponent implements OnInit { event: Event; - tmpEvent: any; + ticketCategories: TicketCategories; reservationForm: FormGroup; //https://alligator.io/angular/reactive-forms-formarray-dynamic-fields/ @@ -40,13 +41,13 @@ export class EventDisplayComponent implements OnInit { this.reservationForm = this.formBuilder.group({ reservation: this.formBuilder.array(this.createItems(e)) }); - this.tmpEvent = e; + this.ticketCategories = e; }); }) } - createItems(event): FormGroup[] { - return event.ticketCategories.map(category => this.formBuilder.group({ticketCategoryId: category.id, amount: 0})); + createItems(ticketCategories: TicketCategories): FormGroup[] { + return ticketCategories.categories.map(category => this.formBuilder.group({ticketCategoryId: category.id, amount: 0})); } submitForm(eventShortName, reservation) { diff --git a/src/app/model/ticket-categories.ts b/src/app/model/ticket-categories.ts new file mode 100644 index 00000000..c74a901f --- /dev/null +++ b/src/app/model/ticket-categories.ts @@ -0,0 +1,11 @@ +export class TicketCategories { + categories: TicketCategory[]; +} + + +export class TicketCategory { + id: number; + name: string; + amountOfTickets: number[]; + description: {[key:string]: string} +} \ No newline at end of file diff --git a/src/app/shared/event.service.ts b/src/app/shared/event.service.ts index a5ed5996..2bbe310f 100644 --- a/src/app/shared/event.service.ts +++ b/src/app/shared/event.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from "@angular/common/http"; import { Observable } from 'rxjs'; import { Event } from '../model/event' +import { TicketCategories } from '../model/ticket-categories' @Injectable({ providedIn: 'root' @@ -18,7 +19,7 @@ export class EventService { return this.http.get(`/api/v2/public/event/${eventShortName}`); } - public getEventTicketsInfo(eventShortName: string) : Observable { - return this.http.get(`/api/v2/public/tmp/event/${eventShortName}`); + public getEventTicketsInfo(eventShortName: string) : Observable { + return this.http.get(`/api/v2/public/event/${eventShortName}/ticket-categories`); } }