import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { ScrollToService } from '@nicky-lenaers/ngx-scroll-to'; import { Tournament } from 'tournee.businesslogic'; import { UtilityService } from 'src/app/shared/services/utility.service'; @Component({ selector: 'app-tournament-builder-step-three', templateUrl: './tournament-builder-step-three.component.html', styleUrls: ['./tournament-builder-step-three.component.css'] }) export class TournamentBuilderStepThreeComponent implements OnInit { display: boolean = false; competitionFormShown: boolean = false; @Output() OnStepped = new EventEmitter(); @Output() OnSteppedBack = new EventEmitter(); @Output() OnCancelled = new EventEmitter(); @Output() OnDone = new EventEmitter(); @Output() OnSave = new EventEmitter(); EditModel: Tournament; original_state: string; constructor(private _scrollToService: ScrollToService) { } ngOnInit() { } next() { this.OnStepped.emit(this.EditModel); this.display = false; } stepBack() { this.OnSteppedBack.emit(this.EditModel); this.display = false; } done() { this.OnDone.emit(this.EditModel); this.display = false; } save() { this.OnSave.emit(this.EditModel); } cancel() { this.OnCancelled.emit(); } enter(editModel: Tournament, original: string) { this.EditModel = editModel; this.display = true; this.original_state = original; } IsDirty() { return this.original_state != JSON.stringify(this.EditModel); } hideCompetition() { this.competitionFormShown = false; this._scrollToService.scrollTo(UtilityService.scroll_to_head); } showCompetition() { this.competitionFormShown = true; } }