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';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatDialogModule } from '@angular/material/dialog';
import { AppComponent } from './app.component';
import { EducationalObjectiveComponent } from './pieces/educational-objective/educational-objective.component';
......@@ -30,9 +31,12 @@ import { InteruptComponent } from './sider-pieces/interupt/interupt.component';
import { OptionnalTaskComponent } from './pieces/tasks/optionnal-task/optionnal-task.component';
import { RoleOccurenceComponent } from './sider-pieces/role-occurence/role-occurence.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 { 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({
declarations: [
......@@ -59,7 +63,10 @@ import { MouseWheelZoomDirective } from './directives/mouse-wheel-zoom.directive
InteruptComponent,
OptionnalTaskComponent,
RoleOccurenceComponent,
SupplementaryTaskComponent
SupplementaryTaskComponent,
SuppressDialogComponent,
CleanDialogComponent,
CreateDialogComponent
],
imports: [
BrowserModule,
......@@ -69,7 +76,8 @@ import { MouseWheelZoomDirective } from './directives/mouse-wheel-zoom.directive
MatIconModule,
MatButtonModule,
MatMenuModule,
MatTooltipModule
MatTooltipModule,
MatDialogModule
],
providers: [],
bootstrap: [AppComponent]
......
import { Component, Input, OnInit } from '@angular/core';
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({
selector: 'app-comment',
......@@ -15,7 +17,7 @@ export class CommentComponent implements OnInit {
isEditable: boolean = false;
newAnswer: string = '';
constructor() { }
constructor(public dialog: MatDialog) { }
ngOnInit(): void {
this.comment.answers.forEach(answer => {
......@@ -24,8 +26,13 @@ export class CommentComponent implements OnInit {
}
removeAnwer(index: number): void {
this.comment.answers.splice(index, 1);
this.answerEditables.splice(index, 1);
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Réponse' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.comment.answers.splice(index, 1);
this.answerEditables.splice(index, 1);
}
});
}
addAnswer(): void {
......@@ -37,6 +44,11 @@ export class CommentComponent implements OnInit {
}
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 { MatDialog } from '@angular/material/dialog';
import { EducationnalObjective } from 'src/app/class/educationnal-objective/educationnal-objective';
import { Mission } from 'src/app/class/mission/mission';
import { Scenario } from 'src/app/class/scenario/scenario';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-educational-objective',
......@@ -16,7 +20,7 @@ export class EducationalObjectiveComponent implements OnInit {
@Input() scenario: Scenario = new Scenario();
@Input() i: number = 0;
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { }
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void {
}
......@@ -28,15 +32,30 @@ export class EducationalObjectiveComponent implements OnInit {
}
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 {
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 {
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 {
......
......@@ -3,6 +3,8 @@ import { GameContext } from 'src/app/class/game-context/game-context';
import { Scenario } from 'src/app/class/scenario/scenario';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-game-context',
......@@ -14,7 +16,7 @@ export class GameContextComponent implements OnInit {
@Input() scenario: Scenario = new Scenario();
@Input() gameContext: GameContext = new GameContext();
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { }
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void {
}
......@@ -22,11 +24,16 @@ export class GameContextComponent implements OnInit {
displayMenu: string = 'hide';
onClickErase(): void {
this.gameContext.univers = '';
this.gameContext.support = '';
this.gameContext.duration = '';
this.gameContext.intrigue = '';
this.gameContext.other = '';
const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Contexte du jeu' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.gameContext.univers = '';
this.gameContext.support = '';
this.gameContext.duration = '';
this.gameContext.intrigue = '';
this.gameContext.other = '';
}
});
}
onClickDots(): void {
......
......@@ -3,6 +3,8 @@ import { GameEducationnalObjective } from 'src/app/class/game-educationnal-objec
import { Scenario } from 'src/app/class/scenario/scenario';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-game-educationnal-objective',
......@@ -14,7 +16,7 @@ export class GameEducationnalObjectiveComponent implements OnInit {
@Input() scenario: Scenario = new Scenario();
@Input() gameEducationnalObjective: GameEducationnalObjective = new GameEducationnalObjective();
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { }
constructor(private pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void {
}
......@@ -26,7 +28,11 @@ export class GameEducationnalObjectiveComponent implements OnInit {
}
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 { MatDialog } from '@angular/material/dialog';
import { MissionContext } from 'src/app/class/mission-context/mission-context';
import { Mission } from 'src/app/class/mission/mission';
import { Scenario } from 'src/app/class/scenario/scenario';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-mission-context',
......@@ -12,7 +16,7 @@ import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
})
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() scenario: Scenario = new Scenario();
......@@ -28,18 +32,33 @@ export class MissionContextComponent implements OnInit {
}
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 {
this.missionContext.duration = '';
this.missionContext.intrigue = '';
this.missionContext.communication = '';
this.missionContext.various = '';
const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Contexte de la mission '+(this.i+1) });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.missionContext.duration = '';
this.missionContext.intrigue = '';
this.missionContext.communication = '';
this.missionContext.various = '';
}
});
}
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 {
......
import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Mission } from 'src/app/class/mission/mission';
import { Ressource } from 'src/app/class/ressource/ressource';
import { CharacterReward } from 'src/app/class/rewards/character-reward/character-reward';
......@@ -13,6 +14,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { SupplementaryRole } from 'src/app/class/supplementary-role/supplementary-role';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-role',
......@@ -26,7 +30,7 @@ export class RoleComponent implements OnInit {
@Input() mission: Mission = new Mission();
@Input() i: number = 0;
constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService) { }
constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void {
this.mission.equalizeLengths();
......@@ -40,22 +44,37 @@ export class RoleComponent implements OnInit {
}
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 {
this.role.intitule = '';
this.role.questName = '';
this.role.description = '';
this.role.educationnalObjectives = [new RoleEducationnalObjective()];
this.role.rewards = [];
this.role.stuff = '';
this.role.ressources = [];
this.role.supplementaryRoles = [];
const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Role '+(this.role.intitule ? '<'+this.role.intitule+'>' : (this.i+1)) });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.role.intitule = '';
this.role.questName = '';
this.role.description = '';
this.role.educationnalObjectives = [new RoleEducationnalObjective()];
this.role.rewards = [];
this.role.stuff = '';
this.role.ressources = [];
this.role.supplementaryRoles = [];
}
});
}
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 {
......@@ -71,7 +90,12 @@ export class RoleComponent implements OnInit {
}
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 {
......@@ -79,16 +103,21 @@ export class RoleComponent implements OnInit {
}
removeRessource(index: number): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireRessources.forEach((prerequire, j) => {
if (prerequire.ressource == this.role.ressources[index]) {
task.prerequireRessources.splice(j, 1);
}
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Ressource' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.role.tasks.forEach(inlineTasks => {
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 {
......@@ -96,7 +125,12 @@ export class RoleComponent implements OnInit {
}
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 {
......@@ -115,7 +149,12 @@ export class RoleComponent implements OnInit {
}
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 {
......@@ -147,7 +186,12 @@ export class RoleComponent implements OnInit {
}
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) {
......
import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Mission } from 'src/app/class/mission/mission';
import { Role } from 'src/app/class/role/role';
import { Step } from 'src/app/class/step/step';
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({
selector: 'app-step',
......@@ -19,7 +22,7 @@ export class StepComponent implements OnInit {
displayMenu: string = 'hide';
pieceWidth = '400px';
constructor(private pieceDetailsService: PieceDetailsService) { }
constructor(private pieceDetailsService: PieceDetailsService, public dialog: MatDialog) { }
ngOnInit(): void {
this.durationChange();
......@@ -30,18 +33,28 @@ export class StepComponent implements OnInit {
}
onClickErase(): void {
this.step.description = '';
this.step.durationUnit = 'UT';
this.step.duration = 1;
const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Étape' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.step.description = '';
this.step.durationUnit = 'UT';
this.step.duration = 1;
}
});
}
onClickDelete(): void {
if (this.parent instanceof Mission) {
this.parent.removeChronologieStep(this.index);
} else if (this.parent instanceof Role) {
this.parent.removeChronologieStep(this.index);
}
this.mission.equalizeLengths();
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Étape de '+(this.parent instanceof Mission ? 'Mission' : 'Rôle') });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
if (this.parent instanceof Mission) {
this.parent.removeChronologieStep(this.index);
} else if (this.parent instanceof Role) {
this.parent.removeChronologieStep(this.index);
}
this.mission.equalizeLengths();
}
});
}
moveStep(direction: string) {
......
import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Mission } from 'src/app/class/mission/mission';
import { PrerequireRessource } from 'src/app/class/prerequires/prerequire-ressource/prerequire-ressource';
import { PrerequireTask } from 'src/app/class/prerequires/prerequire-task/prerequire-task';
......@@ -8,6 +9,8 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-annexe-task',
......@@ -31,7 +34,7 @@ export class AnnexeTaskComponent implements OnInit {
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 {
this.durationChange();
......@@ -54,10 +57,15 @@ export class AnnexeTaskComponent implements OnInit {
}
onClickErase(): void {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Tâche annexe' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
}
});
}
onClickDots(): void {
......@@ -66,17 +74,22 @@ export class AnnexeTaskComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Tâche annexe' });
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();
}
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
onClickChange(type: string): void {
......
......@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-final-task',
......@@ -31,7 +34,7 @@ export class FinalTaskComponent implements OnInit {
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 {
this.durationChange();
......@@ -54,12 +57,17 @@ export class FinalTaskComponent implements OnInit {
}
onClickErase(): void {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Tâche finale' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
}
});
}
onClickDots(): void {
......@@ -77,17 +85,22 @@ export class FinalTaskComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Tâche finale' });
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();
}
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
changeDisplaySymbolChoice(): void {
......
......@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-optionnal-task',
......@@ -31,7 +34,7 @@ export class OptionnalTaskComponent implements OnInit {
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 {
this.durationChange();
......@@ -54,12 +57,17 @@ export class OptionnalTaskComponent implements OnInit {
}
onClickErase(): void {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Tâche optionnelle' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
}
});
}
onClickDots(): void {
......@@ -76,17 +84,22 @@ export class OptionnalTaskComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Tâche optionnelle' });
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();
}
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
changeDisplaySymbolChoice(): void {
......
......@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-random-event',
......@@ -31,7 +34,7 @@ export class RandomEventComponent implements OnInit {
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 {
this.durationChange();
......@@ -54,12 +57,17 @@ export class RandomEventComponent implements OnInit {
}
onClickErase(): void {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Événement aléatoire' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
}
});
}
onClickDots(): void {
......@@ -68,17 +76,22 @@ export class RandomEventComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cet Événement aléatoire' });
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();
}
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
changeDisplaySymbolChoice(): void {
......
......@@ -4,6 +4,9 @@ import { Role } from 'src/app/class/role/role';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-repeat-task',
......@@ -23,13 +26,18 @@ export class RepeatTaskComponent implements OnInit {
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 {
}
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 {
......@@ -38,8 +46,22 @@ export class RepeatTaskComponent implements OnInit {
}
onClickDelete(): void {
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Répétition de tour' });
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 {
......
......@@ -8,6 +8,9 @@ import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.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({
selector: 'app-task',
......@@ -31,7 +34,7 @@ export class TaskComponent implements OnInit {
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 {
this.durationChange();
......@@ -54,12 +57,17 @@ export class TaskComponent implements OnInit {
}
onClickErase(): void {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
const dialogRef = this.dialog.open(CleanDialogComponent, { data: 'Tâche' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.task.duration = 1;
this.task.durationUnit = 'UT';
this.task.identifier = '';
this.task.objective = '';
this.task.symbol.color = '';
this.task.symbol.symbol = '';
}
});
}
onClickDots(): void {
......@@ -76,17 +84,22 @@ export class TaskComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Tâche' });
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();
}
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
changeDisplaySymbolChoice(): void {
......
import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Character } from 'src/app/class/character/character';
import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
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({
selector: 'app-characters',
......@@ -17,33 +20,43 @@ export class CharactersComponent implements OnInit {
selectedAssignCharacter!: Character | undefined;
selectedDeleteCharacterIndex!: number;
constructor(protected tooltipService: TooltipService) { }
constructor(protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void {
}
createCharacter(): void {
if (this.newCharacter.name != '') {
this.scenario.characters.push(this.newCharacter);
this.newCharacter = new Character();
const dialogRef = this.dialog.open(CreateDialogComponent, { data: 'un nouveau Personnage <'+this.newCharacter.name+'>' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.scenario.characters.push(this.newCharacter);
this.newCharacter = new Character();
}
});
}
}
deleteCharacter(): void {
if (this.selectedDeleteCharacterIndex != undefined) {
this.scenario.missions.forEach(mission => {
mission.roles.forEach(role => {
role.tasks.forEach(inlineTask => {
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);
}
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'ce Personnage <'+this.scenario.characters[this.selectedDeleteCharacterIndex].name+'>' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.scenario.missions.forEach(mission => {
mission.roles.forEach(role => {
role.tasks.forEach(inlineTask => {
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';
import { Ressource } from 'src/app/class/ressource/ressource';
import { Scenario } from 'src/app/class/scenario/scenario';
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({
selector: 'app-rules',
......@@ -12,7 +14,7 @@ export class RulesComponent implements OnInit {
@Input() scenario: Scenario = new Scenario();
constructor(protected tooltipService: TooltipService) { }
constructor(protected tooltipService: TooltipService, public dialog: MatDialog) { }
ngOnInit(): void {
}
......@@ -22,19 +24,24 @@ export class RulesComponent implements OnInit {
}
removeRessource(index: number): void {
this.scenario.missions.forEach(mission => {
mission.roles.forEach(role => {
role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireRessources.forEach((prerequire, j) => {
if (this.scenario.ressources[index] == prerequire.ressource) {
task.prerequireRessources.splice(j, 1);
}
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Ressource' });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.scenario.missions.forEach(mission => {
mission.roles.forEach(role => {
role.tasks.forEach(inlineTasks => {
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