Skip to content

Commit

Permalink
add confirm on team edit
Browse files Browse the repository at this point in the history
  • Loading branch information
IceMaD committed Feb 18, 2016
1 parent 0e53f95 commit 3bdac75
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions app/ts/Services/TeamHolderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ export class TeamHolderService {
}

static get tree():NodeModel {
if (!(this._tree instanceof NodeModel)) {
if (!this.hasTree()) {
this._tree = TreeManager.buildTree(this._teamList);
}

return this._tree;
}

static addTeam(name: string): TeamHolderService {
if (!this.hasConfirmed()) {
return;
}

this._teamList.push(new TeamModel(name));

return TeamHolderService;
}

static isFilled(): boolean {
let l = this._teamList.length;

// Is power of 2
return l && (l & (l - 1)) === 0;
}

static removeTeam(team: TeamModel): TeamHolderService {
if (!this.hasConfirmed()) {
return;
}

for (let i:number = 0; i < this._teamList.length; i++) {

Expand Down Expand Up @@ -82,4 +82,23 @@ export class TeamHolderService {
node.highlighted = false;
})
}

static isFilled(): boolean {
let l = this._teamList.length;

// Is power of 2
return l && (l & (l - 1)) === 0;
}

private static hasTree(): boolean {
return this._tree instanceof NodeModel;
}

private static hasConfirmed(): boolean {
if (this.hasTree() && confirm('Cette action aura pour effet de supprimer l\'arbre existant')) {
this._tree = null;
}

return true
}
}

0 comments on commit 3bdac75

Please sign in to comment.