Commit 7193a725 authored by Romain DELEAU's avatar Romain DELEAU

add prerequires on repeat-tasks

parent d77be140
...@@ -35,13 +35,72 @@ ...@@ -35,13 +35,72 @@
</div> </div>
</div> </div>
<div class="piece-prerequires" [class]="pieceDetailsService.piece == task ? displayPrequires : 'hide'">
<div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">{{'task_prerequire_antecedents_title' | translate}}</label>
<div class="piece-prerequires-form">
<ng-container *ngIf="hasPossibleAntecedents()">
<ng-container *ngFor="let inlineTask of role.tasks">
<ng-container *ngFor="let element of inlineTask; let index = index">
<div class="piece-prerequires-prerequires-element" *ngIf="element?.identifier && (task.identifier != element?.identifier) && element?.type != 'annexe'">
<input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<label for="antecedent">{{element?.identifier}}</label>
</div>
</ng-container>
</ng-container>
</ng-container>
<div style="text-align: center;" *ngIf="!hasPossibleAntecedents()">{{'task_prerequire_antecedents_err2' | translate}}</div>
</div>
</div>
<div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">{{'task_prerequire_ressource_title' | translate}}</label>
<div class="piece-prerequires-form">
<ng-container *ngFor="let ressource of scenario.ressources">
<div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<label for="ressource" [title]="ressource.name">{{ressource.name}}</label>
</div>
<div class="piece-prerequires-ressources-element-quantity" *ngIf="isCheckedRessource(ressource)">
<select name="ressource" [(ngModel)]="getAssociatePrerequireRessource(ressource).operator">
<option><</option>
<option><=</option>
<option>=</option>
<option>>=</option>
<option>></option>
</select>
<input type="text" value="1" [(ngModel)]="getAssociatePrerequireRessource(ressource).quantity"/>
</div>
</div>
</ng-container>
<ng-container *ngFor="let ressource of role.ressources">
<div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<label for="ressource" [title]="ressource.name">{{ressource.name}}</label>
</div>
<div class="piece-prerequires-ressources-element-quantity" *ngIf="isCheckedRessource(ressource)">
<select name="ressource" [(ngModel)]="getAssociatePrerequireRessource(ressource).operator">
<option><</option>
<option><=</option>
<option>=</option>
<option>>=</option>
<option>></option>
</select>
<input type="text" value="1" [(ngModel)]="getAssociatePrerequireRessource(ressource).quantity"/>
</div>
</div>
</ng-container>
</div>
</div>
</div>
<div class="piece-form"> <div class="piece-form">
<label>{{'repeatTask_title' | translate}}<br>{{'repeatTask_while' | translate}}</label> <label>{{'repeatTask_title' | translate}}<br>{{'repeatTask_while' | translate}}</label>
<textarea [(ngModel)]="task.objective" [(ngModel)]="task.objective" (change)="editTrace($event,'Task_action')" [style.background-image]="(i == findFirstIndexOfTaskType('repeat')[0] && j == findFirstIndexOfTaskType('repeat')[1]) ? urlIcon : ''" <textarea [(ngModel)]="task.objective" [(ngModel)]="task.objective" (change)="editTrace($event,'Task_action')" [style.background-image]="(i == findFirstIndexOfTaskType('repeat')[0] && j == findFirstIndexOfTaskType('repeat')[1]) ? urlIcon : ''"
[placeholder]="translate.instant('repeatTask_action_placeholder')" [placeholder]="translate.instant('repeatTask_action_placeholder')"
[matTooltip]="translate.instant('task_action_tooltip')" [matTooltip]="translate.instant('task_action_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"></textarea> matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"></textarea>
</div>
<mat-icon class="piece-form-comment" fontIcon="comment" *ngIf="task.comments.length > 0"></mat-icon> <mat-icon class="piece-form-comment" fontIcon="comment" *ngIf="task.comments.length > 0"></mat-icon>
<mat-icon class="piece-form-repeat" fontIcon="refresh" *ngIf="(task.repeat.iteration > 0 || task.repeat.while != '') && !unityService.unity_isActive"></mat-icon> <mat-icon class="piece-form-repeat" fontIcon="refresh" *ngIf="(task.repeat.iteration > 0 || task.repeat.while != '') && !unityService.unity_isActive"></mat-icon>
<span class="piece-form-repeat-off" *ngIf="(task.repeat.iteration > 0 || task.repeat.while != '') && !unityService.unity_isActive && task.repeat.limitMissionRepeat == 1"></span> <span class="piece-form-repeat-off" *ngIf="(task.repeat.iteration > 0 || task.repeat.while != '') && !unityService.unity_isActive && task.repeat.limitMissionRepeat == 1"></span>
...@@ -49,4 +108,10 @@ ...@@ -49,4 +108,10 @@
[style.color]="task.characters.length == 1 ? task.characters[0].color : 'black'" [style.color]="task.characters.length == 1 ? task.characters[0].color : 'black'"
[style.background]="task.characters.length > 1 ? 'linear-gradient('+ task.characters[0].color +','+ task.characters[task.characters.length-1].color +')' : 'white'"></mat-icon> [style.background]="task.characters.length > 1 ? 'linear-gradient('+ task.characters[0].color +','+ task.characters[task.characters.length-1].color +')' : 'white'"></mat-icon>
<mat-icon class="piece-form-interrupt" fontIcon="front_hand" *ngIf="task.interrupt != '' && !unityService.unity_isActive"></mat-icon> <mat-icon class="piece-form-interrupt" fontIcon="front_hand" *ngIf="task.interrupt != '' && !unityService.unity_isActive"></mat-icon>
<button mat-button class="piece-form-prerequires" (click)="changeDisplayPrerequires()"
[matTooltip]="translate.instant('task_prerequire_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
{{'task_prerequire_label' | translate}}
</button>
</div>
</div> </div>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
} }
mat-icon:hover { mat-icon:hover {
opacity: 0.75; opacity: 0.65;
} }
&-directioncross { &-directioncross {
...@@ -77,7 +77,6 @@ ...@@ -77,7 +77,6 @@
} }
&-form { &-form {
height: 100%;
padding: 0px 10px 0px 35px; padding: 0px 10px 0px 35px;
position: relative; position: relative;
display: flex; display: flex;
...@@ -99,7 +98,7 @@ ...@@ -99,7 +98,7 @@
border: none; border: none;
border-radius: 20px; border-radius: 20px;
resize: none; resize: none;
height: 50%; height: 155px;
padding: 10px; padding: 10px;
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
...@@ -109,7 +108,7 @@ ...@@ -109,7 +108,7 @@
&-comment { &-comment {
transform: scale(1.2); transform: scale(1.2);
position: absolute; position: absolute;
bottom: 35px; bottom: 65px;
left: 50px; left: 50px;
background-color: white; background-color: white;
padding: 4px; padding: 4px;
...@@ -119,7 +118,7 @@ ...@@ -119,7 +118,7 @@
&-repeat { &-repeat {
transform: scale(1.2); transform: scale(1.2);
position: absolute; position: absolute;
bottom: 35px; bottom: 65px;
left: 100px; left: 100px;
background-color: white; background-color: white;
padding: 4px; padding: 4px;
...@@ -129,7 +128,7 @@ ...@@ -129,7 +128,7 @@
height: 3px; height: 3px;
width: 35px; width: 35px;
background-color: black; background-color: black;
bottom: 50px; bottom: 80px;
left: 99px; left: 99px;
position: absolute; position: absolute;
transform: rotateZ(45deg); transform: rotateZ(45deg);
...@@ -139,7 +138,7 @@ ...@@ -139,7 +138,7 @@
&-character { &-character {
transform: scale(1.2); transform: scale(1.2);
position: absolute; position: absolute;
bottom: 35px; bottom: 65px;
left: 150px; left: 150px;
padding: 4px; padding: 4px;
border-radius: 50%; border-radius: 50%;
...@@ -148,12 +147,121 @@ ...@@ -148,12 +147,121 @@
&-interrupt { &-interrupt {
transform: scale(1.2); transform: scale(1.2);
position: absolute; position: absolute;
bottom: 35px; bottom: 65px;
left: 200px; left: 200px;
background-color: white; background-color: white;
padding: 4px; padding: 4px;
border-radius: 50%; border-radius: 50%;
} }
&-prerequires {
width: 100px;
height: 50px;
background-color: white;
border-radius: 10px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
margin-top: 62px;
}
}
&-prerequires {
position: absolute;
width: 375px;
height: 150px;
background-color: #f7f7f7;
z-index: -1;
bottom: 120px;
right: 20px;
border: solid black 1px;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
transition: transform 0.5s ease;
border-left: none;
display: flex;
flex-direction: row;
padding-left: 2px;
&-title {
margin-left: auto;
margin-right: auto;
font-family: 'Glacial Indifference Bold';
font-size: 13px;
}
&-form {
display: flex;
flex-direction: column;
overflow-x: hidden;
overflow-y: auto;
}
&-prerequires {
position: relative;
border-right: solid #a3a3a3 1px;
top: 50%;
transform: translateY(-50%);
width: 50%;
height: 90%;
display: flex;
flex-direction: column;
}
&-ressources {
width: 50%;
height: 90%;
border-bottom-right-radius: 10px;
position: relative;
top: 50%;
transform: translateY(-50%);
border-bottom-left-radius: 10px;
display: flex;
flex-direction: column;
&-element {
display: flex;
flex-direction: row;
margin-top: 5px;
&-checkbox {
position: relative;
width: 50%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&-quantity {
position: relative;
width: 50%;
display: flex;
margin-right: 10px;
justify-content: flex-end;
input {
width: 20px;
border: none;
border-radius: 10px;
text-align: center;
}
select {
width: 40px;
background-color: white;
border: none;
border-radius: 10px;
margin-right: 5px;
}
}
}
}
}
&-prerequires.show {
transform: translateX(100%);
padding-left: 27px;
} }
} }
......
...@@ -12,6 +12,10 @@ import { Trace } from 'src/app/class/trace/trace'; ...@@ -12,6 +12,10 @@ import { Trace } from 'src/app/class/trace/trace';
import { MinimapService } from 'src/app/services/minimap/minimap.service'; import { MinimapService } from 'src/app/services/minimap/minimap.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { UnityService } from 'src/app/services/unity/unity.service'; import { UnityService } from 'src/app/services/unity/unity.service';
import { PrerequireTask } from 'src/app/class/prerequires/prerequire-task/prerequire-task';
import { TutorialService } from 'src/app/services/tutorial/tutorial.service';
import { Ressource } from 'src/app/class/ressource/ressource';
import { PrerequireRessource } from 'src/app/class/prerequires/prerequire-ressource/prerequire-ressource';
@Component({ @Component({
selector: 'app-repeat-task', selector: 'app-repeat-task',
...@@ -21,6 +25,7 @@ import { UnityService } from 'src/app/services/unity/unity.service'; ...@@ -21,6 +25,7 @@ import { UnityService } from 'src/app/services/unity/unity.service';
export class RepeatTaskComponent implements OnInit { export class RepeatTaskComponent implements OnInit {
displayMenu: string = 'hide'; displayMenu: string = 'hide';
displayPrequires: string = 'hide';
@Input() scenario: Scenario = new Scenario(); @Input() scenario: Scenario = new Scenario();
@Input() task: Task = new Task('normal'); @Input() task: Task = new Task('normal');
...@@ -35,7 +40,7 @@ export class RepeatTaskComponent implements OnInit { ...@@ -35,7 +40,7 @@ export class RepeatTaskComponent implements OnInit {
constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog, private minimapService: MinimapService, protected translate: TranslateService, constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog, private minimapService: MinimapService, protected translate: TranslateService,
protected unityService: UnityService) { } protected unityService: UnityService, private tutorialService: TutorialService) { }
ngOnInit(): void { ngOnInit(): void {
this.mission.equalizeLengths(); this.mission.equalizeLengths();
...@@ -152,4 +157,96 @@ export class RepeatTaskComponent implements OnInit { ...@@ -152,4 +157,96 @@ export class RepeatTaskComponent implements OnInit {
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,'Repeat_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'));
} }
changeDisplayPrerequires(): void {
if(this.displayPrequires == 'show') {
this.displayPrequires = 'hide';
this.scenario.traces.push(new Trace(this.scenario.traces.length,'hide',this.missionIndex,this.roleIndex,'prerequires','Task_['+this.i+';'+this.j+']', '#B9DFE3'));
} else {
this.displayPrequires = 'show';
this.scenario.traces.push(new Trace(this.scenario.traces.length,'show',this.missionIndex,this.roleIndex,'prerequires','Task_['+this.i+';'+this.j+']', '#B9DFE3'));
}
}
checkboxChangedTask(event: any, task:(Task|null)): void {
if (task instanceof Task) {
if (event.target.checked) {
this.onCheckTask(task);
} else {
this.onUncheckTask(task);
}
}
}
isCheckedTask(task: (Task|null)): boolean {
if (task instanceof Task) {
return this.task.prerequireTasks.some(element => element.identifier == task.identifier);
}
return false;
}
onCheckTask(task: Task): void {
this.task.prerequireTasks.push(new PrerequireTask(task.identifier));
this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',this.missionIndex,this.roleIndex,'prerequire_task','Task_['+this.i+';'+this.j+']', '#B9DFE3'));
this.validTutorialPhase7();
}
onUncheckTask(task: Task): void {
let i: number = this.task.prerequireTasks.findIndex(element => element.identifier == task.identifier);
this.task.prerequireTasks.splice(i,1);
this.scenario.traces.push(new Trace(this.scenario.traces.length,'delete',this.missionIndex,this.roleIndex,'prerequire_task','Task_['+this.i+';'+this.j+']', '#B9DFE3'));
}
checkboxChangedRessource(event: any, ressource: Ressource): void {
if (event.target.checked) {
this.onCheckRessource(ressource);
} else {
this.onUncheckRessource(ressource);
}
}
isCheckedRessource(ressource: Ressource): boolean {
return this.task.prerequireRessources.some(element => element.ressource == ressource);
}
onCheckRessource(ressource: Ressource): void {
this.task.prerequireRessources.push(new PrerequireRessource(ressource));
this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',this.missionIndex,this.roleIndex,'prerequire_ressource','Task_['+this.i+';'+this.j+']', '#B9DFE3'));
this.validTutorialPhase7();
}
onUncheckRessource(ressource: Ressource): void {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
this.task.prerequireRessources.splice(i, 1);
this.scenario.traces.push(new Trace(this.scenario.traces.length,'delete',this.missionIndex,this.roleIndex,'prerequire_ressource','Task_['+this.i+';'+this.j+']', '#B9DFE3'));
}
getAssociatePrerequireRessource(ressource: Ressource): PrerequireRessource {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
return this.task.prerequireRessources[i];
}
hasPossibleAntecedents(): boolean {
let res = false;
this.role.tasks.forEach(inlineTask => {
for(let i = 0; i < inlineTask.length; i++) {
if (inlineTask[i]?.identifier && (this.task.identifier != inlineTask[i]?.identifier)) {
res = true;
}
}
});
return res;
}
validTutorialPhase7(): void {
if (!this.tutorialService.optionnalPhase && !this.tutorialService.phaseDone[this.tutorialService.phase-1] && this.tutorialService.isActive && this.tutorialService.phase == 7
&& this.task.symbol.symbol && (this.task.prerequireTasks.length > 0 || this.task.prerequireRessources.length > 0)
&& this.scenario.missions[0].roles[0].tasks[0].some(task => task?.symbol.symbol && (task.prerequireTasks.length > 0 || task.prerequireRessources.length > 0))
&& this.scenario.missions[0].roles[1].tasks[0].some(task => task?.symbol.symbol && (task.prerequireTasks.length > 0 || task.prerequireRessources.length > 0))) {
this.scenario.traces.push(new Trace(this.scenario.traces.length, 'valid_phase', undefined, undefined, 'phase_'+this.tutorialService.phase, 'Tutorial'));
this.tutorialService.validPhase();
}
}
} }
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