This commit is contained in:
schmelczerandras 2019-08-25 15:49:51 +02:00
parent e96ac49c8e
commit e992152a75
28 changed files with 289 additions and 79 deletions

View file

@ -0,0 +1,30 @@
import { Injectable } from '@angular/core';
interface Subscriber {
callback: () => void;
object: object;
}
@Injectable({
providedIn: 'root'
})
export class CancelService {
private subscribers: Subscriber[] = [];
constructor() {}
subscribe(object: object, callback: () => void) {
this.subscribers.push({
object,
callback
});
}
cancelAllExcept(except: object) {
this.subscribers.filter(s => s.object !== except).map(s => s.callback());
}
cancelAll() {
this.subscribers.map(s => s.callback());
}
}

View file

@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { Tower } from '../model/tower';
import { top } from '../utils/top';
import { CancelService } from './cancel.service';
export enum ModalType {
createBlock,
@ -25,8 +26,13 @@ interface Modal {
export class ModalService {
private modalStack: Modal[] = [];
showCreateBlock(options: string[]): Promise<{ selected: string; description: string; isDone: boolean }> {
return this.createPromiseAndPushToStack(options, ModalType.createBlock);
constructor(private cancelService: CancelService) {}
showCreateBlock(input: {
options: string[];
isTask: boolean;
}): Promise<{ selected: string; description: string; isDone: boolean }> {
return this.createPromiseAndPushToStack(input, ModalType.createBlock);
}
showEditBlock(data: {
@ -65,6 +71,8 @@ export class ModalService {
}
private createPromiseAndPushToStack(input: any, type: ModalType): Promise<any> {
this.cancelService.cancelAll();
const modal = {
input,
type,

View file

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Page } from '../model/page';
const LOCAL_STORAGE_KEY = 'life-towers.data.v.2.1';
const LOCAL_STORAGE_KEY = 'life-towers.data.v.2';
@Injectable({
providedIn: 'root'