Commit b223b132 authored by Romain DELEAU's avatar Romain DELEAU

Traces on comments

parent 2757521d
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
<app-repeat class="container-sider-elements-element" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()"></app-repeat> <app-repeat class="container-sider-elements-element" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()"></app-repeat>
<app-interupt class="container-sider-elements-element" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()"></app-interupt> <app-interupt class="container-sider-elements-element" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()"></app-interupt>
<app-characters class="container-sider-elements-element" [scenario]="scenario" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()"></app-characters> <app-characters class="container-sider-elements-element" [scenario]="scenario" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()"></app-characters>
<app-comments class="container-sider-elements-element" [piece]="pieceDetailsService.piece"></app-comments> <app-comments class="container-sider-elements-element" [piece]="pieceDetailsService.piece" [scenario]="scenario"></app-comments>
</div> </div>
</div> </div>
......
...@@ -276,11 +276,11 @@ export class AppComponent { ...@@ -276,11 +276,11 @@ export class AppComponent {
role.addTask(i, j, type); role.addTask(i, j, type);
switch(type) { switch(type) {
case 'normal': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Task_['+i+';'+j+']', '#B9DFE3')); break; case 'normal': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Task_['+i+';'+j+']', '#B9DFE3')); break;
case 'annexe': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Task_['+i+';'+j+']', '#BCCECC')); break; case 'annexe': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Side_task_['+i+';'+j+']', '#BCCECC')); break;
case 'optionnal': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Task_['+i+';'+j+']', '#E8E3B3')); break; case 'optionnal': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Opt_task_['+i+';'+j+']', '#E8E3B3')); break;
case 'final': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Task_['+i+';'+j+']', '#B28386')); break; case 'final': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Final_task_['+i+';'+j+']', '#B28386')); break;
case 'event': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Task_['+i+';'+j+']', '#BFDAA3')); break; case 'event': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Event_task_['+i+';'+j+']', '#BFDAA3')); break;
case 'reppeat': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Task_['+i+';'+j+']', '#ABBCC6')); break; case 'repeat': this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',missionIndex,roleIndex,'all','Repeat_task_['+i+';'+j+']', '#ABBCC6')); break;
} }
mission.equalizeLengths(); mission.equalizeLengths();
} }
......
<div class="form"> <div class="form">
<div class="form-comment"> <div class="form-comment">
<textarea [disabled]="!isEditable" [(ngModel)]="comment.content"></textarea> <textarea [disabled]="!isEditable" [(ngModel)]="comment.content" (change)="editTrace($event, 'comment')"></textarea>
<div class="form-comment-buttons"> <div class="form-comment-buttons">
<button mat-button (click)="isEditable = !isEditable">Modifier</button> <button mat-button (click)="isEditable = !isEditable">Modifier</button>
<button mat-button (click)="removeComment(index)">Supprimer</button> <button mat-button (click)="removeComment(index)">Supprimer</button>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<textarea [disabled]="!answerEditables[i]" [(ngModel)]="comment.answers[i]">Une réponse</textarea> <textarea [disabled]="!answerEditables[i]" [(ngModel)]="comment.answers[i]">Une réponse</textarea>
<div class="form-comment-buttons"> <div class="form-comment-buttons">
<button mat-button (click)="this.answerEditables[i] = !this.answerEditables[i]">Modifier</button> <button mat-button (click)="this.answerEditables[i] = !this.answerEditables[i]">Modifier</button>
<button mat-button (click)="removeAnwer(i)">Supprimer</button> <button mat-button (click)="removeAnswer(i)">Supprimer</button>
</div> </div>
</div> </div>
<div class="form-newanswer"> <div class="form-newanswer">
......
...@@ -2,6 +2,13 @@ import { Component, Input, OnInit } from '@angular/core'; ...@@ -2,6 +2,13 @@ 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 { MatDialog } from '@angular/material/dialog';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component'; import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { Scenario } from 'src/app/class/scenario/scenario';
import { Mission } from 'src/app/class/mission/mission';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { Task } from 'src/app/class/task/task';
import { Role } from 'src/app/class/role/role';
import { Step } from 'src/app/class/step/step';
import { Trace } from 'src/app/class/trace/trace';
@Component({ @Component({
selector: 'app-comment', selector: 'app-comment',
...@@ -10,6 +17,7 @@ import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dia ...@@ -10,6 +17,7 @@ import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dia
}) })
export class CommentComponent implements OnInit { export class CommentComponent implements OnInit {
@Input() scenario: Scenario = new Scenario();
@Input() comments: Comment[] = []; @Input() comments: Comment[] = [];
@Input() index: number = 0; @Input() index: number = 0;
@Input() comment: Comment = new Comment(); @Input() comment: Comment = new Comment();
...@@ -17,7 +25,7 @@ export class CommentComponent implements OnInit { ...@@ -17,7 +25,7 @@ export class CommentComponent implements OnInit {
isEditable: boolean = false; isEditable: boolean = false;
newAnswer: string = ''; newAnswer: string = '';
constructor(public dialog: MatDialog) { } constructor(public dialog: MatDialog, private pieceDetailsService: PieceDetailsService) { }
ngOnInit(): void { ngOnInit(): void {
this.comment.answers.forEach(answer => { this.comment.answers.forEach(answer => {
...@@ -25,12 +33,15 @@ export class CommentComponent implements OnInit { ...@@ -25,12 +33,15 @@ export class CommentComponent implements OnInit {
}); });
} }
removeAnwer(index: number): void { removeAnswer(index: number): void {
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Réponse' }); const dialogRef = this.dialog.open(SuppressDialogComponent, { data: 'cette Réponse' });
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result == true) { if (result == true) {
this.comment.answers.splice(index, 1); this.comment.answers.splice(index, 1);
this.answerEditables.splice(index, 1); this.answerEditables.splice(index, 1);
this.scenario.traces.push(new Trace(this.scenario.traces.length,'delete',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,'answer_['+index+']',this.formatTraceTarget(),'#F3ED97'));
} else {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'cancel_delete',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,'answer_['+index+']',this.formatTraceTarget(),'#F3ED97'));
} }
}); });
} }
...@@ -39,7 +50,8 @@ export class CommentComponent implements OnInit { ...@@ -39,7 +50,8 @@ export class CommentComponent implements OnInit {
if (this.newAnswer.length > 0) { if (this.newAnswer.length > 0) {
this.comment.answers.push(this.newAnswer); this.comment.answers.push(this.newAnswer);
this.answerEditables.push(false); this.answerEditables.push(false);
this.newAnswer = ''; this.newAnswer = '';
this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,'answer_['+(this.comment.answers.length-1)+']',this.formatTraceTarget(),'#F3ED97'));
} }
} }
...@@ -48,7 +60,51 @@ export class CommentComponent implements OnInit { ...@@ -48,7 +60,51 @@ export class CommentComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result == true) { if (result == true) {
this.comments.splice(index, 1); this.comments.splice(index, 1);
this.scenario.traces.push(new Trace(this.scenario.traces.length,'delete',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,'all',this.formatTraceTarget(),'#F3ED97'));
} else {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'cancel_delete',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,'all',this.formatTraceTarget(),'#F3ED97'));
} }
}); });
} }
formatTraceTarget(): string {
let res: string = '';
if (this.pieceDetailsService.piece instanceof Scenario) {
res = 'Scenario';
}
if (this.pieceDetailsService.piece instanceof Mission) {
res = 'Mission_['+this.pieceDetailsService.missionIndex+']';
}
if (this.pieceDetailsService.piece instanceof Role) {
res = 'Role_['+this.pieceDetailsService.roleIndex+']';
}
if (this.pieceDetailsService.piece instanceof Step) {
if (this.pieceDetailsService.roleIndex == undefined) {
res = 'Step_m_['+this.pieceDetailsService.pieceIndex+']';
} else {
res = 'Step_r_['+this.pieceDetailsService.pieceIndex+']';
}
}
if (this.pieceDetailsService.piece instanceof Task) {
switch(this.pieceDetailsService.piece.type) {
case 'normal': res = 'Task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'annexe': res = 'Side_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'final': res = 'Final_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'optionnal': res = 'Opt_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'event': res = 'Event_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'repeat': res = 'Repeat_task_['+this.pieceDetailsService.pieceIndex+']'; break;
}
}
return res+'_comment_['+this.index+']';
}
editTrace(event: any, source: string): void {
if (event.target.value != '') {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'write',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,source,this.formatTraceTarget(), '#F3ED97'));
} else {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'erase',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,source,this.formatTraceTarget(), '#F3ED97'));
}
}
} }
...@@ -30,6 +30,9 @@ export class EducationalObjectiveComponent implements OnInit { ...@@ -30,6 +30,9 @@ export class EducationalObjectiveComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.scenario.missions[this.i]; this.pieceDetailsService.piece = this.scenario.missions[this.i];
this.pieceDetailsService.missionIndex = this.i;
this.pieceDetailsService.roleIndex = undefined;
this.pieceDetailsService.pieceIndex = this.i;
} }
onClickAdd(): void { onClickAdd(): void {
......
...@@ -27,6 +27,9 @@ export class GameCharactersComponent implements OnInit { ...@@ -27,6 +27,9 @@ export class GameCharactersComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.scenario; this.pieceDetailsService.piece = this.scenario;
this.pieceDetailsService.missionIndex = undefined;
this.pieceDetailsService.roleIndex = undefined;
this.pieceDetailsService.pieceIndex = undefined;
} }
onClickErase(): void { onClickErase(): void {
......
...@@ -42,6 +42,9 @@ export class GameContextComponent implements OnInit { ...@@ -42,6 +42,9 @@ export class GameContextComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.scenario; this.pieceDetailsService.piece = this.scenario;
this.pieceDetailsService.missionIndex = undefined,
this.pieceDetailsService.roleIndex = undefined;
this.pieceDetailsService.pieceIndex = undefined;
} }
editTrace(event: any, source: string): void { editTrace(event: any, source: string): void {
......
...@@ -26,6 +26,9 @@ export class GameEducationnalObjectiveComponent implements OnInit { ...@@ -26,6 +26,9 @@ export class GameEducationnalObjectiveComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.scenario; this.pieceDetailsService.piece = this.scenario;
this.pieceDetailsService.missionIndex = undefined;
this.pieceDetailsService.roleIndex = undefined;
this.pieceDetailsService.pieceIndex = undefined;
} }
onClickErase(): void { onClickErase(): void {
......
...@@ -30,6 +30,9 @@ export class MissionContextComponent implements OnInit { ...@@ -30,6 +30,9 @@ export class MissionContextComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.scenario.missions[this.i]; this.pieceDetailsService.piece = this.scenario.missions[this.i];
this.pieceDetailsService.missionIndex = this.i;
this.pieceDetailsService.roleIndex = undefined;
this.pieceDetailsService.pieceIndex = this.i;
} }
onClickAdd(): void { onClickAdd(): void {
......
...@@ -43,6 +43,9 @@ export class RoleComponent implements OnInit { ...@@ -43,6 +43,9 @@ export class RoleComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.role; this.pieceDetailsService.piece = this.role;
this.pieceDetailsService.missionIndex = this.missionIndex;
this.pieceDetailsService.roleIndex = this.i;
this.pieceDetailsService.pieceIndex = this.i;
} }
onClickAdd(): void { onClickAdd(): void {
......
...@@ -26,6 +26,9 @@ export class RulesComponent implements OnInit { ...@@ -26,6 +26,9 @@ export class RulesComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.scenario; this.pieceDetailsService.piece = this.scenario;
this.pieceDetailsService.missionIndex = undefined;
this.pieceDetailsService.roleIndex = undefined;
this.pieceDetailsService.pieceIndex = undefined;
} }
onClickErase(): void { onClickErase(): void {
......
...@@ -86,6 +86,13 @@ export class StepComponent implements OnInit { ...@@ -86,6 +86,13 @@ export class StepComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.step; this.pieceDetailsService.piece = this.step;
this.pieceDetailsService.missionIndex = this.missionIndex;
if (this.parent instanceof Mission) {
this.pieceDetailsService.roleIndex = undefined;
} else {
this.pieceDetailsService.roleIndex = this.roleIndex;
}
this.pieceDetailsService.pieceIndex = this.index;
} }
onClickErase(): void { onClickErase(): void {
......
...@@ -115,6 +115,9 @@ export class AnnexeTaskComponent implements OnInit { ...@@ -115,6 +115,9 @@ export class AnnexeTaskComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.task; this.pieceDetailsService.piece = this.task;
this.pieceDetailsService.parent = this.role; this.pieceDetailsService.parent = this.role;
this.pieceDetailsService.missionIndex = this.missionIndex;
this.pieceDetailsService.roleIndex = this.roleIndex;
this.pieceDetailsService.pieceIndex = [this.i,this.j];
} }
onClickDelete(): void { onClickDelete(): void {
......
...@@ -117,6 +117,9 @@ export class FinalTaskComponent implements OnInit { ...@@ -117,6 +117,9 @@ export class FinalTaskComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.task; this.pieceDetailsService.piece = this.task;
this.pieceDetailsService.parent = this.role; this.pieceDetailsService.parent = this.role;
this.pieceDetailsService.missionIndex = this.missionIndex;
this.pieceDetailsService.roleIndex = this.roleIndex;
this.pieceDetailsService.pieceIndex = [this.i,this.j];
} }
onClickChange(type: string): void { onClickChange(type: string): void {
......
...@@ -117,6 +117,9 @@ export class OptionnalTaskComponent implements OnInit { ...@@ -117,6 +117,9 @@ export class OptionnalTaskComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.task; this.pieceDetailsService.piece = this.task;
this.pieceDetailsService.parent = this.role; this.pieceDetailsService.parent = this.role;
this.pieceDetailsService.missionIndex = this.missionIndex;
this.pieceDetailsService.roleIndex = this.roleIndex;
this.pieceDetailsService.pieceIndex = [this.i,this.j];
} }
onClickChange(type: string): void { onClickChange(type: string): void {
......
...@@ -117,6 +117,9 @@ export class RandomEventComponent implements OnInit { ...@@ -117,6 +117,9 @@ export class RandomEventComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.task; this.pieceDetailsService.piece = this.task;
this.pieceDetailsService.parent = this.role; this.pieceDetailsService.parent = this.role;
this.pieceDetailsService.missionIndex = this.missionIndex;
this.pieceDetailsService.roleIndex = this.roleIndex;
this.pieceDetailsService.pieceIndex = [this.i,this.j];
} }
onClickDelete(): void { onClickDelete(): void {
......
...@@ -41,9 +41,9 @@ export class RepeatTaskComponent implements OnInit { ...@@ -41,9 +41,9 @@ export class RepeatTaskComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result == true) { if (result == true) {
this.task.objective = ''; this.task.objective = '';
this.scenario.traces.push(new Trace(this.scenario.traces.length,'erase',this.missionIndex,this.roleIndex,'all','Task_['+this.i+';'+this.j+']', '#B9DFE3')); this.scenario.traces.push(new Trace(this.scenario.traces.length,'erase',this.missionIndex,this.roleIndex,'all','Repeat_task_['+this.i+';'+this.j+']', '#B9DFE3'));
} else { } else {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'cancel_erase',this.missionIndex,this.roleIndex,'all','Task_['+this.i+';'+this.j+']', '#B9DFE3')); this.scenario.traces.push(new Trace(this.scenario.traces.length,'cancel_erase',this.missionIndex,this.roleIndex,'all','Repeat_task_['+this.i+';'+this.j+']', '#B9DFE3'));
} }
}); });
} }
...@@ -51,6 +51,9 @@ export class RepeatTaskComponent implements OnInit { ...@@ -51,6 +51,9 @@ export class RepeatTaskComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.task; this.pieceDetailsService.piece = this.task;
this.pieceDetailsService.parent = this.role; this.pieceDetailsService.parent = this.role;
this.pieceDetailsService.missionIndex = this.missionIndex;
this.pieceDetailsService.roleIndex = this.roleIndex;
this.pieceDetailsService.pieceIndex = [this.i,this.j];
} }
onClickDelete(): void { onClickDelete(): void {
...@@ -68,9 +71,9 @@ export class RepeatTaskComponent implements OnInit { ...@@ -68,9 +71,9 @@ export class RepeatTaskComponent implements OnInit {
}); });
this.role.removeTask(this.i, this.j); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths(); this.mission.equalizeLengths();
this.scenario.traces.push(new Trace(this.scenario.traces.length,'delete',this.missionIndex,this.roleIndex,'all','Task_['+this.i+';'+this.j+']', '#B9DFE3')); this.scenario.traces.push(new Trace(this.scenario.traces.length,'delete',this.missionIndex,this.roleIndex,'all','Repeat_task_['+this.i+';'+this.j+']', '#B9DFE3'));
} else { } else {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'cancel_delete',this.missionIndex,this.roleIndex,'all','Task_['+this.i+';'+this.j+']', '#B9DFE3')); this.scenario.traces.push(new Trace(this.scenario.traces.length,'cancel_delete',this.missionIndex,this.roleIndex,'all','Repeat_task_['+this.i+';'+this.j+']', '#B9DFE3'));
} }
}); });
} }
...@@ -134,13 +137,13 @@ export class RepeatTaskComponent implements OnInit { ...@@ -134,13 +137,13 @@ export class RepeatTaskComponent implements OnInit {
editTrace(event: any, source: string): void { editTrace(event: any, source: string): void {
if (event.target.value != '') { if (event.target.value != '') {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'write',this.missionIndex,this.roleIndex,source,'Task_['+this.i+';'+this.j+']', '#B9DFE3')); this.scenario.traces.push(new Trace(this.scenario.traces.length,'write',this.missionIndex,this.roleIndex,source,'Repeat_task_['+this.i+';'+this.j+']', '#B9DFE3'));
} else { } else {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'erase',this.missionIndex,this.roleIndex,source,'Task_['+this.i+';'+this.j+']', '#B9DFE3')); this.scenario.traces.push(new Trace(this.scenario.traces.length,'erase',this.missionIndex,this.roleIndex,source,'Repeat_task_['+this.i+';'+this.j+']', '#B9DFE3'));
} }
} }
editMoveTrace(event: any, source: string): void { editMoveTrace(event: any, source: string): void {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'move',this.missionIndex,this.roleIndex,source,'Task_['+this.i+';'+this.j+']', '#B9DFE3')); this.scenario.traces.push(new Trace(this.scenario.traces.length,'move',this.missionIndex,this.roleIndex,source,'Repeat_task_['+this.i+';'+this.j+']', '#B9DFE3'));
} }
} }
...@@ -117,6 +117,9 @@ export class TaskComponent implements OnInit { ...@@ -117,6 +117,9 @@ export class TaskComponent implements OnInit {
onClickPiece(): void { onClickPiece(): void {
this.pieceDetailsService.piece = this.task; this.pieceDetailsService.piece = this.task;
this.pieceDetailsService.parent = this.role; this.pieceDetailsService.parent = this.role;
this.pieceDetailsService.missionIndex = this.missionIndex;
this.pieceDetailsService.roleIndex = this.roleIndex;
this.pieceDetailsService.pieceIndex = [this.i,this.j];
} }
onClickChange(type: string): void { onClickChange(type: string): void {
......
...@@ -12,6 +12,9 @@ export class PieceDetailsService { ...@@ -12,6 +12,9 @@ export class PieceDetailsService {
piece!: (Task | Role | Mission | Step | Scenario); piece!: (Task | Role | Mission | Step | Scenario);
parent!: (Role | Mission | Scenario); parent!: (Role | Mission | Scenario);
missionIndex: number|undefined = undefined;
roleIndex: number|undefined = undefined;
pieceIndex: number|number[]|undefined = undefined;
constructor() { } constructor() { }
......
...@@ -5,13 +5,13 @@ matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedToolt ...@@ -5,13 +5,13 @@ matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedToolt
<div class="piece-form-title">Commentaires</div> <div class="piece-form-title">Commentaires</div>
<div class="piece-form-comments"> <div class="piece-form-comments">
<app-comment *ngFor="let comment of piece.comments, let i = index" [comment]="comment" [comments]="piece.comments" [index]="i"></app-comment> <app-comment *ngFor="let comment of piece.comments, let i = index" [comment]="comment" [comments]="piece.comments" [index]="i" [scenario]="scenario"></app-comment>
</div> </div>
<div class="piece-form-newcomment"> <div class="piece-form-newcomment">
<div class="piece-form-newcomment-form"> <div class="piece-form-newcomment-form">
<label>Nouveau commentaire</label> <label>Nouveau commentaire</label>
<textarea [(ngModel)]="newComment"></textarea> <textarea [(ngModel)]="newComment" (change)="editTrace($event,'newComment')"></textarea>
</div> </div>
<button mat-button (click)="addComment()">Ajouter un commentaire</button> <button mat-button (click)="addComment()">Ajouter un commentaire</button>
</div> </div>
......
...@@ -6,6 +6,8 @@ import { Step } from 'src/app/class/step/step'; ...@@ -6,6 +6,8 @@ import { Step } from 'src/app/class/step/step';
import { Task } from 'src/app/class/task/task'; import { Task } from 'src/app/class/task/task';
import { Comment } from 'src/app/class/comment/comment'; import { Comment } from 'src/app/class/comment/comment';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { Trace } from 'src/app/class/trace/trace';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
@Component({ @Component({
selector: 'app-comments', selector: 'app-comments',
...@@ -15,9 +17,10 @@ import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; ...@@ -15,9 +17,10 @@ import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
export class CommentsComponent implements OnInit { export class CommentsComponent implements OnInit {
@Input() piece!: (Role | Task | Mission | Step | Scenario); @Input() piece!: (Role | Task | Mission | Step | Scenario);
@Input() scenario: Scenario = new Scenario();
newComment: string = ''; newComment: string = '';
constructor(protected tooltipService: TooltipService) { } constructor(protected tooltipService: TooltipService, private pieceDetailsService: PieceDetailsService) { }
ngOnInit(): void { ngOnInit(): void {
} }
...@@ -27,7 +30,55 @@ export class CommentsComponent implements OnInit { ...@@ -27,7 +30,55 @@ export class CommentsComponent implements OnInit {
let comment = new Comment(); let comment = new Comment();
comment.content = this.newComment; comment.content = this.newComment;
this.newComment = ''; this.newComment = '';
this.piece.comments.push(comment); this.piece.comments.push(comment);
this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',
this.pieceDetailsService.missionIndex,
this.pieceDetailsService.roleIndex,
'all',
this.formatTraceTarget(),
'#F3ED97'
));
}
}
formatTraceTarget(): string {
let res: string = '';
if (this.piece instanceof Scenario) {
res = 'Scenario';
}
if (this.piece instanceof Mission) {
res = 'Mission_['+this.pieceDetailsService.missionIndex+']';
}
if (this.piece instanceof Role) {
res = 'Role_['+this.pieceDetailsService.roleIndex+']';
}
if (this.piece instanceof Step) {
if (this.pieceDetailsService.roleIndex == undefined) {
res = 'Step_m_['+this.pieceDetailsService.pieceIndex+']';
} else {
res = 'Step_r_['+this.pieceDetailsService.pieceIndex+']';
}
}
if (this.piece instanceof Task) {
switch(this.piece.type) {
case 'normal': res = 'Task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'annexe': res = 'Side_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'final': res = 'Final_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'optionnal': res = 'Opt_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'event': res = 'Event_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'repeat': res = 'Repeat_task_['+this.pieceDetailsService.pieceIndex+']'; break;
}
}
return res+'_comment_['+(this.piece.comments.length-1)+']';
}
editTrace(event: any, source: string): void {
if (event.target.value != '') {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'write',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,source,this.formatTraceTarget(), '#F3ED97'));
} else {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'erase',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,source,this.formatTraceTarget(), '#F3ED97'));
} }
} }
} }
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