life-towers/src/app/components/pages/pages.component.ts
schmelczerandras e992152a75 Fix bugs
2019-08-25 15:49:51 +02:00

42 lines
1 KiB
TypeScript

import { Component, ElementRef, ViewChild } from '@angular/core';
import { Page } from '../../model/page';
import { DataService } from '../../services/data.service';
import { ModalService } from '../../services/modal.service';
@Component({
selector: 'app-pages',
templateUrl: './pages.component.html',
styleUrls: ['./pages.component.scss']
})
export class PagesComponent {
@ViewChild('top') top: ElementRef;
@ViewChild('page') page: ElementRef;
@ViewChild('bottom') bottom: ElementRef;
isDragHappening = false;
constructor(public dataService: DataService, private modalService: ModalService) {}
async selectPage(selected: string) {
if (!this.dataService.pageNames.includes(selected)) {
const page = new Page({
name: selected,
towers: [],
userData: {}
});
this.dataService.push(page);
page.addTower();
}
await this.dataService.changeActiveByName(selected);
}
async openSettings() {
try {
await this.modalService.showSettings();
} catch {
// pass
}
}
}