import { Component, OnInit, Input, ViewChild, Output, EventEmitter } from '@angular/core'; import { Tournament, TournamentRoomLayout } from 'tournee.businesslogic'; import { TournamentLayoutFormComponent } from '../../forms/tournament-layout-form/tournament-layout-form.component'; import { ScrollToService } from '@nicky-lenaers/ngx-scroll-to'; import { UtilityService } from 'src/app/shared/services/utility.service'; @Component({ selector: 'app-selectable-listing-layout', templateUrl: './selectable-listing-layout.component.html', styleUrls: ['./selectable-listing-layout.component.css'] }) export class SelectableListingLayoutComponent implements OnInit { @Input() EditModel: Tournament; @ViewChild('Form') Form:TournamentLayoutFormComponent; @Output() OnShown = new EventEmitter(); @Output() OnHidden = new EventEmitter(); Selected: TournamentRoomLayout; constructor(private _scrollToService: ScrollToService) { } ngOnInit() { } add() { this.edit(TournamentRoomLayout.create(), true); } store(layout: TournamentRoomLayout) { this.EditModel.storeRoomLayout(layout); this.hide(); } hide() { this.Selected = null; this.Form.reset(); this.OnHidden.emit(); } edit(layout: TournamentRoomLayout, isNew = false) { this.Selected = layout; this.Form.initiate(this.Selected, this.EditModel, isNew); this.OnShown.emit(); this._scrollToService.scrollTo(UtilityService.scroll_to_head); } delete(layout: TournamentRoomLayout) { this.EditModel.removeRoomLayout(layout); } }