Commit d24990b5 authored by Romain DELEAU's avatar Romain DELEAU

confirm dialog (create, clear, delete)

parent b0fca0e9
...@@ -7,6 +7,7 @@ import { MatIconModule } from '@angular/material/icon'; ...@@ -7,6 +7,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu'; import { MatMenuModule } from '@angular/material/menu';
import { MatTooltipModule } from '@angular/material/tooltip'; import { MatTooltipModule } from '@angular/material/tooltip';
import { MatDialogModule } from '@angular/material/dialog';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { EducationalObjectiveComponent } from './pieces/educational-objective/educational-objective.component'; import { EducationalObjectiveComponent } from './pieces/educational-objective/educational-objective.component';
...@@ -30,9 +31,12 @@ import { InteruptComponent } from './sider-pieces/interupt/interupt.component'; ...@@ -30,9 +31,12 @@ import { InteruptComponent } from './sider-pieces/interupt/interupt.component';
import { OptionnalTaskComponent } from './pieces/tasks/optionnal-task/optionnal-task.component'; import { OptionnalTaskComponent } from './pieces/tasks/optionnal-task/optionnal-task.component';
import { RoleOccurenceComponent } from './sider-pieces/role-occurence/role-occurence.component'; import { RoleOccurenceComponent } from './sider-pieces/role-occurence/role-occurence.component';
import { SupplementaryTaskComponent } from './sider-pieces/supplementary-task/supplementary-task.component'; import { SupplementaryTaskComponent } from './sider-pieces/supplementary-task/supplementary-task.component';
import { SuppressDialogComponent } from './components/dialogs/suppress-dialog/suppress-dialog.component';
import { DragScrollDirective } from './directives/drag-scroll.directive'; import { DragScrollDirective } from './directives/drag-scroll.directive';
import { MouseWheelZoomDirective } from './directives/mouse-wheel-zoom.directive'; import { MouseWheelZoomDirective } from './directives/mouse-wheel-zoom.directive';
import { CleanDialogComponent } from './components/dialogs/clean-dialog/clean-dialog.component';
import { CreateDialogComponent } from './components/dialogs/create-dialog/create-dialog.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
...@@ -59,7 +63,10 @@ import { MouseWheelZoomDirective } from './directives/mouse-wheel-zoom.directive ...@@ -59,7 +63,10 @@ import { MouseWheelZoomDirective } from './directives/mouse-wheel-zoom.directive
InteruptComponent, InteruptComponent,
OptionnalTaskComponent, OptionnalTaskComponent,
RoleOccurenceComponent, RoleOccurenceComponent,
SupplementaryTaskComponent SupplementaryTaskComponent,
SuppressDialogComponent,
CleanDialogComponent,
CreateDialogComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
...@@ -69,7 +76,8 @@ import { MouseWheelZoomDirective } from './directives/mouse-wheel-zoom.directive ...@@ -69,7 +76,8 @@ import { MouseWheelZoomDirective } from './directives/mouse-wheel-zoom.directive
MatIconModule, MatIconModule,
MatButtonModule, MatButtonModule,
MatMenuModule, MatMenuModule,
MatTooltipModule MatTooltipModule,
MatDialogModule
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { Comment } from 'src/app/class/comment/comment'; import { Comment } from 'src/app/class/comment/comment';
import { MatDialog } from '@angular/material/dialog';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
@Component({ @Component({
selector: 'app-comment', selector: 'app-comment',
...@@ -15,7 +17,7 @@ export class CommentComponent implements OnInit { ...@@ -15,7 +17,7 @@ export class CommentComponent implements OnInit {
isEditable: boolean = false; isEditable: boolean = false;
newAnswer: string = ''; newAnswer: string = '';
constructor() { } constructor(public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
this.comment.answers.forEach(answer => { this.comment.answers.forEach(answer => {
...@@ -24,8 +26,13 @@ export class CommentComponent implements OnInit { ...@@ -24,8 +26,13 @@ export class CommentComponent implements OnInit {
} }
removeAnwer(index: number): void { removeAnwer(index: number): void {
this.comment.answers.splice(index, 1); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Réponse' });
this.answerEditables.splice(index, 1); dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.comment.answers.splice(index, 1);
this.answerEditables.splice(index, 1);
}
});
} }
addAnswer(): void { addAnswer(): void {
...@@ -37,6 +44,11 @@ export class CommentComponent implements OnInit { ...@@ -37,6 +44,11 @@ export class CommentComponent implements OnInit {
} }
removeComment(index: number): void { removeComment(index: number): void {
this.comments.splice(index, 1); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'ce Commentaire' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.comments.splice(index, 1);
}
});
} }
} }
<h2 mat-dialog-title>Purger le contenu</h2>
<mat-dialog-content>Êtes vous sûr de vouloir purger le contenu de cette tuile {{data}} ?</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button mat-dialog-close>Non</button>
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Oui</button>
</mat-dialog-actions>
button {
margin-top: 20px;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CleanDialogComponent } from './clean-dialog.component';
describe('CleanDialogComponent', () => {
let component: CleanDialogComponent;
let fixture: ComponentFixture<CleanDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CleanDialogComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(CleanDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
selector: 'app-clean-dialog',
templateUrl: './clean-dialog.component.html',
styleUrls: ['./clean-dialog.component.scss']
})
export class CleanDialogComponent implements OnInit {
constructor(@Inject(MAT_DIALOG_DATA) public data: string) { }
ngOnInit(): void {
}
}
<h2 mat-dialog-title>Créer un élément</h2>
<mat-dialog-content>Êtes vous sûr de vouloir créer {{data}} ?</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button mat-dialog-close>Non</button>
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Oui</button>
</mat-dialog-actions>
button {
margin-top: 20px;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CreateDialogComponent } from './create-dialog.component';
describe('CreateDialogComponent', () => {
let component: CreateDialogComponent;
let fixture: ComponentFixture<CreateDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CreateDialogComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(CreateDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
selector: 'app-create-dialog',
templateUrl: './create-dialog.component.html',
styleUrls: ['./create-dialog.component.scss']
})
export class CreateDialogComponent implements OnInit {
constructor(@Inject(MAT_DIALOG_DATA) public data: string) { }
ngOnInit(): void {
}
}
<h2 mat-dialog-title>Supprimer l'élément</h2>
<mat-dialog-content>Êtes vous sûr de vouloir supprimer {{data}} et tout ce que cela implique ?</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button mat-dialog-close>Non</button>
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Oui</button>
</mat-dialog-actions>
button {
margin-top: 20px;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SuppressDialogComponent } from './suppress-dialog.component';
describe('SuppressDialogComponent', () => {
let component: SuppressDialogComponent;
let fixture: ComponentFixture<SuppressDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SuppressDialogComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(SuppressDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
selector: 'app-suppress-dialog',
templateUrl: './suppress-dialog.component.html',
styleUrls: ['./suppress-dialog.component.scss']
})
export class SuppressDialogComponent implements OnInit {
constructor(@Inject(MAT_DIALOG_DATA) public data: string) { }
ngOnInit(): void {
}
}
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { EducationnalObjective } from 'src/app/class/educationnal-objective/educationnal-objective'; import { EducationnalObjective } from 'src/app/class/educationnal-objective/educationnal-objective';
import { Mission } from 'src/app/class/mission/mission'; import { Mission } from 'src/app/class/mission/mission';
import { Scenario } from 'src/app/class/scenario/scenario'; import { Scenario } from 'src/app/class/scenario/scenario';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
import { CreateDialogComponent } from 'src/app/components/dialogs/create-dialog/create-dialog.component';
@Component({ @Component({
selector: 'app-educational-objective', selector: 'app-educational-objective',
...@@ -16,7 +20,7 @@ export class EducationalObjectiveComponent implements OnInit { ...@@ -16,7 +20,7 @@ export class EducationalObjectiveComponent implements OnInit {
@Input() scenario: Scenario = new Scenario(); @Input() scenario: Scenario = new Scenario();
@Input() i: number = 0; @Input() i: number = 0;
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
} }
...@@ -28,15 +32,30 @@ export class EducationalObjectiveComponent implements OnInit { ...@@ -28,15 +32,30 @@ export class EducationalObjectiveComponent implements OnInit {
} }
onClickAdd(): void { onClickAdd(): void {
this.scenario.missions.push(new Mission()); const dialogRef = this.dialog.open(CreateDialogComponent, { data: 'une nouvelle Mission' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.scenario.missions.push(new Mission());
}
});
} }
onClickErase(): void { onClickErase(): void {
this.educationnalObjective.objective = ''; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Objectif pédagogique de la mission '+(this.i+1) });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.educationnalObjective.objective = '';
}
});
} }
onClickDelete(): void { onClickDelete(): void {
this.scenario.missions.splice(this.i, 1); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Mission '+(this.i+1) });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.scenario.missions.splice(this.i, 1);
}
});
} }
canDelete(): boolean { canDelete(): boolean {
......
...@@ -3,6 +3,8 @@ import { GameContext } from 'src/app/class/game-context/game-context'; ...@@ -3,6 +3,8 @@ import { GameContext } from 'src/app/class/game-context/game-context';
import { Scenario } from 'src/app/class/scenario/scenario'; import { Scenario } from 'src/app/class/scenario/scenario';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
import { MatDialog } from '@angular/material/dialog';
@Component({ @Component({
selector: 'app-game-context', selector: 'app-game-context',
...@@ -14,7 +16,7 @@ export class GameContextComponent implements OnInit { ...@@ -14,7 +16,7 @@ export class GameContextComponent implements OnInit {
@Input() scenario: Scenario = new Scenario(); @Input() scenario: Scenario = new Scenario();
@Input() gameContext: GameContext = new GameContext(); @Input() gameContext: GameContext = new GameContext();
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
} }
...@@ -22,11 +24,16 @@ export class GameContextComponent implements OnInit { ...@@ -22,11 +24,16 @@ export class GameContextComponent implements OnInit {
displayMenu: string = 'hide'; displayMenu: string = 'hide';
onClickErase(): void { onClickErase(): void {
this.gameContext.univers = ''; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Contexte du jeu' });
this.gameContext.support = ''; dialogRef.afterClosed().subscribe(result => {
this.gameContext.duration = ''; if (result == true) {
this.gameContext.intrigue = ''; this.gameContext.univers = '';
this.gameContext.other = ''; this.gameContext.support = '';
this.gameContext.duration = '';
this.gameContext.intrigue = '';
this.gameContext.other = '';
}
});
} }
onClickDots(): void { onClickDots(): void {
......
...@@ -3,6 +3,8 @@ import { GameEducationnalObjective } from 'src/app/class/game-educationnal-objec ...@@ -3,6 +3,8 @@ import { GameEducationnalObjective } from 'src/app/class/game-educationnal-objec
import { Scenario } from 'src/app/class/scenario/scenario'; import { Scenario } from 'src/app/class/scenario/scenario';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
import { MatDialog } from '@angular/material/dialog';
@Component({ @Component({
selector: 'app-game-educationnal-objective', selector: 'app-game-educationnal-objective',
...@@ -14,7 +16,7 @@ export class GameEducationnalObjectiveComponent implements OnInit { ...@@ -14,7 +16,7 @@ export class GameEducationnalObjectiveComponent implements OnInit {
@Input() scenario: Scenario = new Scenario(); @Input() scenario: Scenario = new Scenario();
@Input() gameEducationnalObjective: GameEducationnalObjective = new GameEducationnalObjective(); @Input() gameEducationnalObjective: GameEducationnalObjective = new GameEducationnalObjective();
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
} }
...@@ -26,7 +28,11 @@ export class GameEducationnalObjectiveComponent implements OnInit { ...@@ -26,7 +28,11 @@ export class GameEducationnalObjectiveComponent implements OnInit {
} }
onClickErase(): void { onClickErase(): void {
this.gameEducationnalObjective.objective = ''; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Objectif pédagogique' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.gameEducationnalObjective.objective = '';
}
});
} }
} }
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { MissionContext } from 'src/app/class/mission-context/mission-context'; import { MissionContext } from 'src/app/class/mission-context/mission-context';
import { Mission } from 'src/app/class/mission/mission'; import { Mission } from 'src/app/class/mission/mission';
import { Scenario } from 'src/app/class/scenario/scenario'; import { Scenario } from 'src/app/class/scenario/scenario';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
import { CreateDialogComponent } from 'src/app/components/dialogs/create-dialog/create-dialog.component';
@Component({ @Component({
selector: 'app-mission-context', selector: 'app-mission-context',
...@@ -12,7 +16,7 @@ import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; ...@@ -12,7 +16,7 @@ import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
}) })
export class MissionContextComponent implements OnInit { export class MissionContextComponent implements OnInit {
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
@Input() missionContext: MissionContext = new MissionContext(); @Input() missionContext: MissionContext = new MissionContext();
@Input() scenario: Scenario = new Scenario(); @Input() scenario: Scenario = new Scenario();
...@@ -28,18 +32,33 @@ export class MissionContextComponent implements OnInit { ...@@ -28,18 +32,33 @@ export class MissionContextComponent implements OnInit {
} }
onClickAdd(): void { onClickAdd(): void {
this.scenario.missions.push(new Mission()); const dialogRef = this.dialog.open(CreateDialogComponent, { data: 'une nouvelle Mission' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.scenario.missions.push(new Mission());
}
});
} }
onClickErase(): void { onClickErase(): void {
this.missionContext.duration = ''; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Contexte de la mission '+(this.i+1) });
this.missionContext.intrigue = ''; dialogRef.afterClosed().subscribe(result => {
this.missionContext.communication = ''; if (result == true) {
this.missionContext.various = ''; this.missionContext.duration = '';
this.missionContext.intrigue = '';
this.missionContext.communication = '';
this.missionContext.various = '';
}
});
} }
onClickDelete(): void { onClickDelete(): void {
this.scenario.missions.splice(this.i, 1); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Mission '+(this.i+1) });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.scenario.missions.splice(this.i, 1);
}
});
} }
canDelete(): boolean { canDelete(): boolean {
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Mission } from 'src/app/class/mission/mission'; import { Mission } from 'src/app/class/mission/mission';
import { Ressource } from 'src/app/class/ressource/ressource'; import { Ressource } from 'src/app/class/ressource/ressource';
import { CharacterReward } from 'src/app/class/rewards/character-reward/character-reward'; import { CharacterReward } from 'src/app/class/rewards/character-reward/character-reward';
...@@ -13,6 +14,9 @@ import { Scenario } from 'src/app/class/scenario/scenario'; ...@@ -13,6 +14,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { SupplementaryRole } from 'src/app/class/supplementary-role/supplementary-role'; import { SupplementaryRole } from 'src/app/class/supplementary-role/supplementary-role';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
import { CreateDialogComponent } from 'src/app/components/dialogs/create-dialog/create-dialog.component';
@Component({ @Component({
selector: 'app-role', selector: 'app-role',
...@@ -26,7 +30,7 @@ export class RoleComponent implements OnInit { ...@@ -26,7 +30,7 @@ export class RoleComponent implements OnInit {
@Input() mission: Mission = new Mission(); @Input() mission: Mission = new Mission();
@Input() i: number = 0; @Input() i: number = 0;
constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
this.mission.equalizeLengths(); this.mission.equalizeLengths();
...@@ -40,22 +44,37 @@ export class RoleComponent implements OnInit { ...@@ -40,22 +44,37 @@ export class RoleComponent implements OnInit {
} }
onClickAdd(): void { onClickAdd(): void {
this.mission.roles.push(new Role()); const dialogRef = this.dialog.open(CreateDialogComponent, { data: 'un nouveau Rôle pour la Mission '+(this.i+1) });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.mission.roles.push(new Role());
}
});
} }
onClickErase(): void { onClickErase(): void {
this.role.intitule = ''; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Role '+(this.role.intitule ? '<'+this.role.intitule+'>' : (this.i+1)) });
this.role.questName = ''; dialogRef.afterClosed().subscribe(result => {
this.role.description = ''; if (result == true) {
this.role.educationnalObjectives = [new RoleEducationnalObjective()]; this.role.intitule = '';
this.role.rewards = []; this.role.questName = '';
this.role.stuff = ''; this.role.description = '';
this.role.ressources = []; this.role.educationnalObjectives = [new RoleEducationnalObjective()];
this.role.supplementaryRoles = []; this.role.rewards = [];
this.role.stuff = '';
this.role.ressources = [];
this.role.supplementaryRoles = [];
}
});
} }
onClickDelete(): void { onClickDelete(): void {
this.mission.roles.splice(this.i, 1); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'ce Rôle '+(this.role.intitule ? '<'+this.role.intitule+'>' : this.i+1) });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.mission.roles.splice(this.i, 1);
}
});
} }
canDelete(): boolean { canDelete(): boolean {
...@@ -71,7 +90,12 @@ export class RoleComponent implements OnInit { ...@@ -71,7 +90,12 @@ export class RoleComponent implements OnInit {
} }
removeEducationnalObjective(index: number): void { removeEducationnalObjective(index: number): void {
this.role.educationnalObjectives.splice(index, 1); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Objectif Pédagogique' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.role.educationnalObjectives.splice(index, 1);
}
});
} }
addRessource(): void { addRessource(): void {
...@@ -79,16 +103,21 @@ export class RoleComponent implements OnInit { ...@@ -79,16 +103,21 @@ export class RoleComponent implements OnInit {
} }
removeRessource(index: number): void { removeRessource(index: number): void {
this.role.tasks.forEach(inlineTasks => { const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Ressource' });
inlineTasks.forEach(task => { dialogRef.afterClosed().subscribe(result => {
task?.prerequireRessources.forEach((prerequire, j) => { if (result == true) {
if (prerequire.ressource == this.role.ressources[index]) { this.role.tasks.forEach(inlineTasks => {
task.prerequireRessources.splice(j, 1); inlineTasks.forEach(task => {
} task?.prerequireRessources.forEach((prerequire, j) => {
if (prerequire.ressource == this.role.ressources[index]) {
task.prerequireRessources.splice(j, 1);
}
});
});
}); });
}); this.role.ressources.splice(index, 1);
}
}); });
this.role.ressources.splice(index, 1);
} }
addSupplementaryRole(): void { addSupplementaryRole(): void {
...@@ -96,7 +125,12 @@ export class RoleComponent implements OnInit { ...@@ -96,7 +125,12 @@ export class RoleComponent implements OnInit {
} }
removeSupplementaryRole(index: number) { removeSupplementaryRole(index: number) {
this.role.supplementaryRoles.splice(index, 1); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'ce Rôle Supplémentaire'+(this.role.supplementaryRoles[index].name ? ' <'+this.role.supplementaryRoles[index].name+'>' : '') });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.role.supplementaryRoles.splice(index, 1);
}
});
} }
addReward(): void { addReward(): void {
...@@ -115,7 +149,12 @@ export class RoleComponent implements OnInit { ...@@ -115,7 +149,12 @@ export class RoleComponent implements OnInit {
} }
removeReward(index: number): void { removeReward(index: number): void {
this.role.rewards.splice(index, 1); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Récompense' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.role.rewards.splice(index, 1);
}
});
} }
getObjectiveReward(index: number): ObjectiveReward { getObjectiveReward(index: number): ObjectiveReward {
...@@ -147,7 +186,12 @@ export class RoleComponent implements OnInit { ...@@ -147,7 +186,12 @@ export class RoleComponent implements OnInit {
} }
removeObject(i: number, j: number): void { removeObject(i: number, j: number): void {
this.getObjectsReward(i).objects.splice(j, 1); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cet Objet de la Récompense' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.getObjectsReward(i).objects.splice(j, 1);
}
});
} }
changeQuestReward(index: number, event: any) { changeQuestReward(index: number, event: any) {
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Mission } from 'src/app/class/mission/mission'; import { Mission } from 'src/app/class/mission/mission';
import { Role } from 'src/app/class/role/role'; import { Role } from 'src/app/class/role/role';
import { Step } from 'src/app/class/step/step'; import { Step } from 'src/app/class/step/step';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
@Component({ @Component({
selector: 'app-step', selector: 'app-step',
...@@ -19,7 +22,7 @@ export class StepComponent implements OnInit { ...@@ -19,7 +22,7 @@ export class StepComponent implements OnInit {
displayMenu: string = 'hide'; displayMenu: string = 'hide';
pieceWidth = '400px'; pieceWidth = '400px';
constructor(private pieceDetailsService: PieceDetailsService) { } constructor(private pieceDetailsService: PieceDetailsService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
this.durationChange(); this.durationChange();
...@@ -30,18 +33,28 @@ export class StepComponent implements OnInit { ...@@ -30,18 +33,28 @@ export class StepComponent implements OnInit {
} }
onClickErase(): void { onClickErase(): void {
this.step.description = ''; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Étape' });
this.step.durationUnit = 'UT'; dialogRef.afterClosed().subscribe(result => {
this.step.duration = 1; if (result == true) {
this.step.description = '';
this.step.durationUnit = 'UT';
this.step.duration = 1;
}
});
} }
onClickDelete(): void { onClickDelete(): void {
if (this.parent instanceof Mission) { const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Étape de '+(this.parent instanceof Mission ? 'Mission' : 'Rôle') });
this.parent.removeChronologieStep(this.index); dialogRef.afterClosed().subscribe(result => {
} else if (this.parent instanceof Role) { if (result == true) {
this.parent.removeChronologieStep(this.index); if (this.parent instanceof Mission) {
} this.parent.removeChronologieStep(this.index);
this.mission.equalizeLengths(); } else if (this.parent instanceof Role) {
this.parent.removeChronologieStep(this.index);
}
this.mission.equalizeLengths();
}
});
} }
moveStep(direction: string) { moveStep(direction: string) {
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Mission } from 'src/app/class/mission/mission'; import { Mission } from 'src/app/class/mission/mission';
import { PrerequireRessource } from 'src/app/class/prerequires/prerequire-ressource/prerequire-ressource'; import { PrerequireRessource } from 'src/app/class/prerequires/prerequire-ressource/prerequire-ressource';
import { PrerequireTask } from 'src/app/class/prerequires/prerequire-task/prerequire-task'; import { PrerequireTask } from 'src/app/class/prerequires/prerequire-task/prerequire-task';
...@@ -8,6 +9,8 @@ import { Scenario } from 'src/app/class/scenario/scenario'; ...@@ -8,6 +9,8 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task'; import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
@Component({ @Component({
selector: 'app-annexe-task', selector: 'app-annexe-task',
...@@ -31,7 +34,7 @@ export class AnnexeTaskComponent implements OnInit { ...@@ -31,7 +34,7 @@ export class AnnexeTaskComponent implements OnInit {
urlIcon: string = 'url("../../../../assets/background-images/annexe.png")'; urlIcon: string = 'url("../../../../assets/background-images/annexe.png")';
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
this.durationChange(); this.durationChange();
...@@ -54,10 +57,15 @@ export class AnnexeTaskComponent implements OnInit { ...@@ -54,10 +57,15 @@ export class AnnexeTaskComponent implements OnInit {
} }
onClickErase(): void { onClickErase(): void {
this.task.duration = 1; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Tâche annexe' });
this.task.durationUnit = 'UT'; dialogRef.afterClosed().subscribe(result => {
this.task.identifier = ''; if (result == true) {
this.task.objective = ''; this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
}
});
} }
onClickDots(): void { onClickDots(): void {
...@@ -66,17 +74,22 @@ export class AnnexeTaskComponent implements OnInit { ...@@ -66,17 +74,22 @@ export class AnnexeTaskComponent implements OnInit {
} }
onClickDelete(): void { onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => { const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Tâche annexe' });
inlineTasks.forEach(task => { dialogRef.afterClosed().subscribe(result => {
task?.prerequireTasks.forEach((prerequire, index) => { if (result == true) {
if (prerequire.identifier == this.task.identifier) { this.role.tasks.forEach(inlineTasks => {
task.prerequireTasks.splice(index, 1); inlineTasks.forEach(task => {
} task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
}); });
}); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
}); });
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
} }
onClickChange(type: string): void { onClickChange(type: string): void {
......
...@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario'; ...@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task'; import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { MatDialog } from '@angular/material/dialog';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
@Component({ @Component({
selector: 'app-final-task', selector: 'app-final-task',
...@@ -31,7 +34,7 @@ export class FinalTaskComponent implements OnInit { ...@@ -31,7 +34,7 @@ export class FinalTaskComponent implements OnInit {
urlIcon: string = 'url("../../../../assets/background-images/final.png")'; urlIcon: string = 'url("../../../../assets/background-images/final.png")';
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
this.durationChange(); this.durationChange();
...@@ -54,12 +57,17 @@ export class FinalTaskComponent implements OnInit { ...@@ -54,12 +57,17 @@ export class FinalTaskComponent implements OnInit {
} }
onClickErase(): void { onClickErase(): void {
this.task.duration = 1; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Tâche finale' });
this.task.durationUnit = 'UT'; dialogRef.afterClosed().subscribe(result => {
this.task.identifier = ''; if (result == true) {
this.task.objective = ''; this.task.duration = 1;
this.task.symbol.color = ''; this.task.durationUnit = 'UT';
this.task.symbol.symbol = ''; this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
}
});
} }
onClickDots(): void { onClickDots(): void {
...@@ -77,17 +85,22 @@ export class FinalTaskComponent implements OnInit { ...@@ -77,17 +85,22 @@ export class FinalTaskComponent implements OnInit {
} }
onClickDelete(): void { onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => { const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Tâche finale' });
inlineTasks.forEach(task => { dialogRef.afterClosed().subscribe(result => {
task?.prerequireTasks.forEach((prerequire, index) => { if (result == true) {
if (prerequire.identifier == this.task.identifier) { this.role.tasks.forEach(inlineTasks => {
task.prerequireTasks.splice(index, 1); inlineTasks.forEach(task => {
} task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
}); });
}); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
}); });
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
} }
changeDisplaySymbolChoice(): void { changeDisplaySymbolChoice(): void {
......
...@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario'; ...@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task'; import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { MatDialog } from '@angular/material/dialog';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
@Component({ @Component({
selector: 'app-optionnal-task', selector: 'app-optionnal-task',
...@@ -31,7 +34,7 @@ export class OptionnalTaskComponent implements OnInit { ...@@ -31,7 +34,7 @@ export class OptionnalTaskComponent implements OnInit {
urlIcon: string = 'url("../../../../assets/background-images/optionnal.png")'; urlIcon: string = 'url("../../../../assets/background-images/optionnal.png")';
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
this.durationChange(); this.durationChange();
...@@ -54,12 +57,17 @@ export class OptionnalTaskComponent implements OnInit { ...@@ -54,12 +57,17 @@ export class OptionnalTaskComponent implements OnInit {
} }
onClickErase(): void { onClickErase(): void {
this.task.duration = 1; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Tâche optionnelle' });
this.task.durationUnit = 'UT'; dialogRef.afterClosed().subscribe(result => {
this.task.identifier = ''; if (result == true) {
this.task.objective = ''; this.task.duration = 1;
this.task.symbol.color = ''; this.task.durationUnit = 'UT';
this.task.symbol.symbol = ''; this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
}
});
} }
onClickDots(): void { onClickDots(): void {
...@@ -76,17 +84,22 @@ export class OptionnalTaskComponent implements OnInit { ...@@ -76,17 +84,22 @@ export class OptionnalTaskComponent implements OnInit {
} }
onClickDelete(): void { onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => { const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Tâche optionnelle' });
inlineTasks.forEach(task => { dialogRef.afterClosed().subscribe(result => {
task?.prerequireTasks.forEach((prerequire, index) => { if (result == true) {
if (prerequire.identifier == this.task.identifier) { this.role.tasks.forEach(inlineTasks => {
task.prerequireTasks.splice(index, 1); inlineTasks.forEach(task => {
} task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
}); });
}); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
}); });
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
} }
changeDisplaySymbolChoice(): void { changeDisplaySymbolChoice(): void {
......
...@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario'; ...@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task'; import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { MatDialog } from '@angular/material/dialog';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
@Component({ @Component({
selector: 'app-random-event', selector: 'app-random-event',
...@@ -31,7 +34,7 @@ export class RandomEventComponent implements OnInit { ...@@ -31,7 +34,7 @@ export class RandomEventComponent implements OnInit {
urlIcon: string = 'url("../../../../assets/background-images/event.png")'; urlIcon: string = 'url("../../../../assets/background-images/event.png")';
constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
this.durationChange(); this.durationChange();
...@@ -54,12 +57,17 @@ export class RandomEventComponent implements OnInit { ...@@ -54,12 +57,17 @@ export class RandomEventComponent implements OnInit {
} }
onClickErase(): void { onClickErase(): void {
this.task.duration = 1; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Événement aléatoire' });
this.task.durationUnit = 'UT'; dialogRef.afterClosed().subscribe(result => {
this.task.identifier = ''; if (result == true) {
this.task.objective = ''; this.task.duration = 1;
this.task.symbol.color = ''; this.task.durationUnit = 'UT';
this.task.symbol.symbol = ''; this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
}
});
} }
onClickDots(): void { onClickDots(): void {
...@@ -68,17 +76,22 @@ export class RandomEventComponent implements OnInit { ...@@ -68,17 +76,22 @@ export class RandomEventComponent implements OnInit {
} }
onClickDelete(): void { onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => { const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cet Événement aléatoire' });
inlineTasks.forEach(task => { dialogRef.afterClosed().subscribe(result => {
task?.prerequireTasks.forEach((prerequire, index) => { if (result == true) {
if (prerequire.identifier == this.task.identifier) { this.role.tasks.forEach(inlineTasks => {
task.prerequireTasks.splice(index, 1); inlineTasks.forEach(task => {
} task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
}); });
}); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
}); });
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
} }
changeDisplaySymbolChoice(): void { changeDisplaySymbolChoice(): void {
......
...@@ -4,6 +4,9 @@ import { Role } from 'src/app/class/role/role'; ...@@ -4,6 +4,9 @@ import { Role } from 'src/app/class/role/role';
import { Task } from 'src/app/class/task/task'; import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { MatDialog } from '@angular/material/dialog';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
@Component({ @Component({
selector: 'app-repeat-task', selector: 'app-repeat-task',
...@@ -23,13 +26,18 @@ export class RepeatTaskComponent implements OnInit { ...@@ -23,13 +26,18 @@ export class RepeatTaskComponent implements OnInit {
urlIcon: string = 'url("../../../../assets/background-images/repeatTask.png")'; urlIcon: string = 'url("../../../../assets/background-images/repeatTask.png")';
constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
} }
onClickErase(): void { onClickErase(): void {
this.task.objective = ''; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Répétition de tour' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.task.objective = '';
}
});
} }
onClickDots(): void { onClickDots(): void {
...@@ -38,8 +46,22 @@ export class RepeatTaskComponent implements OnInit { ...@@ -38,8 +46,22 @@ export class RepeatTaskComponent implements OnInit {
} }
onClickDelete(): void { onClickDelete(): void {
this.role.removeTask(this.i, this.j); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Répétition de tour' });
this.mission.equalizeLengths(); dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
});
} }
moveTask(direction: string): void { moveTask(direction: string): void {
......
...@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario'; ...@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task'; import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { MatDialog } from '@angular/material/dialog';
import { CleanDialogComponent } from 'src/app/components/dialogs/clean-dialog/clean-dialog.component';
@Component({ @Component({
selector: 'app-task', selector: 'app-task',
...@@ -31,7 +34,7 @@ export class TaskComponent implements OnInit { ...@@ -31,7 +34,7 @@ export class TaskComponent implements OnInit {
urlIcon: string = 'url("../../../../assets/background-images/tache.png")'; urlIcon: string = 'url("../../../../assets/background-images/tache.png")';
constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { } constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
this.durationChange(); this.durationChange();
...@@ -54,12 +57,17 @@ export class TaskComponent implements OnInit { ...@@ -54,12 +57,17 @@ export class TaskComponent implements OnInit {
} }
onClickErase(): void { onClickErase(): void {
this.task.duration = 1; const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Tâche' });
this.task.durationUnit = 'UT'; dialogRef.afterClosed().subscribe(result => {
this.task.identifier = ''; if (result == true) {
this.task.objective = ''; this.task.duration = 1;
this.task.symbol.color = ''; this.task.durationUnit = 'UT';
this.task.symbol.symbol = ''; this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
}
});
} }
onClickDots(): void { onClickDots(): void {
...@@ -76,17 +84,22 @@ export class TaskComponent implements OnInit { ...@@ -76,17 +84,22 @@ export class TaskComponent implements OnInit {
} }
onClickDelete(): void { onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => { const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Tâche' });
inlineTasks.forEach(task => { dialogRef.afterClosed().subscribe(result => {
task?.prerequireTasks.forEach((prerequire, index) => { if (result == true) {
if (prerequire.identifier == this.task.identifier) { this.role.tasks.forEach(inlineTasks => {
task.prerequireTasks.splice(index, 1); inlineTasks.forEach(task => {
} task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
}); });
}); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
}); });
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
} }
changeDisplaySymbolChoice(): void { changeDisplaySymbolChoice(): void {
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Character } from 'src/app/class/character/character'; import { Character } from 'src/app/class/character/character';
import { Scenario } from 'src/app/class/scenario/scenario'; import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task'; import { Task } from 'src/app/class/task/task';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { CreateDialogComponent } from 'src/app/components/dialogs/create-dialog/create-dialog.component';
@Component({ @Component({
selector: 'app-characters', selector: 'app-characters',
...@@ -17,33 +20,43 @@ export class CharactersComponent implements OnInit { ...@@ -17,33 +20,43 @@ export class CharactersComponent implements OnInit {
selectedAssignCharacter!: Character | undefined; selectedAssignCharacter!: Character | undefined;
selectedDeleteCharacterIndex!: number; selectedDeleteCharacterIndex!: number;
constructor(protected tooltipService: TooltipService) { } constructor(protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
} }
createCharacter(): void { createCharacter(): void {
if (this.newCharacter.name != '') { if (this.newCharacter.name != '') {
this.scenario.characters.push(this.newCharacter); const dialogRef = this.dialog.open(CreateDialogComponent, { data: 'un nouveau Personnage <'+this.newCharacter.name+'>' });
this.newCharacter = new Character(); dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.scenario.characters.push(this.newCharacter);
this.newCharacter = new Character();
}
});
} }
} }
deleteCharacter(): void { deleteCharacter(): void {
if (this.selectedDeleteCharacterIndex != undefined) { if (this.selectedDeleteCharacterIndex != undefined) {
this.scenario.missions.forEach(mission => { const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'ce Personnage <'+this.scenario.characters[this.selectedDeleteCharacterIndex].name+'>' });
mission.roles.forEach(role => { dialogRef.afterClosed().subscribe(result => {
role.tasks.forEach(inlineTask => { if (result == true) {
inlineTask.forEach(task => { this.scenario.missions.forEach(mission => {
let index: number | undefined = task?.characters.findIndex(character => character == this.scenario.characters[this.selectedDeleteCharacterIndex]); mission.roles.forEach(role => {
if (typeof index !== 'undefined' && index !== -1) { role.tasks.forEach(inlineTask => {
task?.characters.splice(index, 1); inlineTask.forEach(task => {
} let index: number | undefined = task?.characters.findIndex(character => character == this.scenario.characters[this.selectedDeleteCharacterIndex]);
if (typeof index !== 'undefined' && index !== -1) {
task?.characters.splice(index, 1);
}
});
});
}); });
}); });
}); this.scenario.characters.splice(this.selectedDeleteCharacterIndex, 1);
}
}); });
this.scenario.characters.splice(this.selectedDeleteCharacterIndex, 1);
} }
} }
......
...@@ -2,6 +2,8 @@ import { Component, Input, OnInit } from '@angular/core'; ...@@ -2,6 +2,8 @@ import { Component, Input, OnInit } from '@angular/core';
import { Ressource } from 'src/app/class/ressource/ressource'; import { Ressource } from 'src/app/class/ressource/ressource';
import { Scenario } from 'src/app/class/scenario/scenario'; import { Scenario } from 'src/app/class/scenario/scenario';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { MatDialog } from '@angular/material/dialog';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
@Component({ @Component({
selector: 'app-rules', selector: 'app-rules',
...@@ -12,7 +14,7 @@ export class RulesComponent implements OnInit { ...@@ -12,7 +14,7 @@ export class RulesComponent implements OnInit {
@Input() scenario: Scenario = new Scenario(); @Input() scenario: Scenario = new Scenario();
constructor(protected tooltipService: TooltipService) { } constructor(protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void { ngOnInit(): void {
} }
...@@ -22,19 +24,24 @@ export class RulesComponent implements OnInit { ...@@ -22,19 +24,24 @@ export class RulesComponent implements OnInit {
} }
removeRessource(index: number): void { removeRessource(index: number): void {
this.scenario.missions.forEach(mission => { const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Ressource' });
mission.roles.forEach(role => { dialogRef.afterClosed().subscribe(result => {
role.tasks.forEach(inlineTasks => { if (result == true) {
inlineTasks.forEach(task => { this.scenario.missions.forEach(mission => {
task?.prerequireRessources.forEach((prerequire, j) => { mission.roles.forEach(role => {
if (this.scenario.ressources[index] == prerequire.ressource) { role.tasks.forEach(inlineTasks => {
task.prerequireRessources.splice(j, 1); inlineTasks.forEach(task => {
} task?.prerequireRessources.forEach((prerequire, j) => {
if (this.scenario.ressources[index] == prerequire.ressource) {
task.prerequireRessources.splice(j, 1);
}
});
});
}); });
}); });
}); });
}); this.scenario.ressources.splice(index, 1);
}
}); });
this.scenario.ressources.splice(index, 1);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment