Start refactoring state management
This commit is contained in:
parent
ca0bf943f7
commit
a9ad628488
2 changed files with 410 additions and 360 deletions
|
|
@ -8,12 +8,12 @@
|
|||
<app-toggle
|
||||
[beforeText]="'Hide create tower button'"
|
||||
[afterText]="'Show create tower button'"
|
||||
[default]="!dataService.active.userData?.hideCreateTowerButton"
|
||||
(value)="dataService.active.userData.hideCreateTowerButton = !$event"
|
||||
[default]="!page.userData.hideCreateTowerButton"
|
||||
(value)="page?.setHideCreateTowerButton(!$event)"
|
||||
></app-toggle>
|
||||
</div>
|
||||
<!-- wrapper for easier styling -->
|
||||
|
||||
<p *ngIf="dataService.active?.towers.length == 5">There can be a maximum of <strong>5</strong> towers on each page.</p>
|
||||
<p *ngIf="page.towers?.length == 5">There can be a maximum of <strong>5</strong> towers on each page.</p>
|
||||
|
||||
<button (click)="deletePage()">Delete current page</button>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { ModalService } from '../../../../services/modal.service';
|
||||
import { DataService } from '../../../../services/data.service';
|
||||
import { Page } from '../../../../model/page';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
|
|
@ -8,12 +9,16 @@ import { DataService } from '../../../../services/data.service';
|
|||
styleUrls: ['./settings.component.scss']
|
||||
})
|
||||
export class SettingsComponent {
|
||||
constructor(public modalService: ModalService, public dataService: DataService) {}
|
||||
constructor(public modalService: ModalService, public dataService: DataService) {
|
||||
this.modalService.active.input.subscribe(p => (this.page = p));
|
||||
}
|
||||
|
||||
page: Page;
|
||||
|
||||
async deletePage() {
|
||||
try {
|
||||
await this.modalService.showRemovePage(this.dataService.active.name);
|
||||
this.dataService.remove();
|
||||
await this.modalService.showRemovePage(this.page.name);
|
||||
this.dataService.removePage(this.page);
|
||||
this.modalService.submit();
|
||||
} catch {
|
||||
// pass
|
||||
|
|
|
|||
Loading…
Reference in a new issue