Commit e3968fae authored by Romain DELEAU's avatar Romain DELEAU

prerequires

parent 566ce1a6
...@@ -59,11 +59,11 @@ ...@@ -59,11 +59,11 @@
<div class="container-scenario-main-missions-mission-roles-role-tasks-inlineTasks" *ngFor="let tasks of role.tasks, let i = index" [style.z-index]="role.tasks.length+i"> <div class="container-scenario-main-missions-mission-roles-role-tasks-inlineTasks" *ngFor="let tasks of role.tasks, let i = index" [style.z-index]="role.tasks.length+i">
<div *ngFor="let task of tasks, let j = index" [style.z-index]="tasks.length-j"> <div *ngFor="let task of tasks, let j = index" [style.z-index]="tasks.length-j">
<div *ngIf="task != null"> <div *ngIf="task != null">
<app-task *ngIf="task.type == 'normal'" [task]="task" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-task> <app-task *ngIf="task.type == 'normal'" [task]="task" [scenario]="scenario" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-task>
<app-annexe-task *ngIf="task.type == 'annexe'" [task]="task" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-annexe-task> <app-annexe-task *ngIf="task.type == 'annexe'" [task]="task" [scenario]="scenario" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-annexe-task>
<app-random-event *ngIf="task.type == 'event'" [task]="task" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-random-event> <app-random-event *ngIf="task.type == 'event'" [task]="task" [scenario]="scenario" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-random-event>
<app-optionnal-task *ngIf="task.type == 'optionnal'" [task]="task" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-optionnal-task> <app-optionnal-task *ngIf="task.type == 'optionnal'" [task]="task" [scenario]="scenario" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-optionnal-task>
<app-final-task *ngIf="task.type == 'final'" [task]="task" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-final-task> <app-final-task *ngIf="task.type == 'final'" [task]="task" [scenario]="scenario" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-final-task>
<app-repeat-task *ngIf="task.type == 'repeat'" [task]="task" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-repeat-task> <app-repeat-task *ngIf="task.type == 'repeat'" [task]="task" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-repeat-task>
</div> </div>
<div class="container-scenario-main-missions-mission-buttonAdd" style="height: 400px;" *ngIf="task == null"> <div class="container-scenario-main-missions-mission-buttonAdd" style="height: 400px;" *ngIf="task == null">
......
...@@ -22,6 +22,8 @@ import { QuestReward } from './class/rewards/quest-reward/quest-reward'; ...@@ -22,6 +22,8 @@ import { QuestReward } from './class/rewards/quest-reward/quest-reward';
import { ObjectsReward } from './class/rewards/objects-reward/objects-reward'; import { ObjectsReward } from './class/rewards/objects-reward/objects-reward';
import { ObjectiveReward } from './class/rewards/objective-reward/objective-reward'; import { ObjectiveReward } from './class/rewards/objective-reward/objective-reward';
import { OtherReward } from './class/rewards/other-reward/other-reward'; import { OtherReward } from './class/rewards/other-reward/other-reward';
import { PrerequireRessource } from './class/prerequires/prerequire-ressource/prerequire-ressource';
import { elementAt } from 'rxjs';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
...@@ -165,6 +167,16 @@ export class AppComponent { ...@@ -165,6 +167,16 @@ export class AppComponent {
&& element.color == task.supplementaryRole.color && element.color == task.supplementaryRole.color
); );
task.supplementaryRole = role.supplementaryRoles[supplementaryRoleIndex]; task.supplementaryRole = role.supplementaryRoles[supplementaryRoleIndex];
task.prerequireRessources = task.prerequireRessources.map((prerequireData: any) => Object.assign(new PrerequireRessource(), prerequireData));
task.prerequireRessources.forEach((prerequire, index) => {
if (scenario.ressources.some(element => element.name == prerequire.ressource.name && element.number == prerequire.ressource.number)) {
let i: number = scenario.ressources.findIndex(element => element.name == prerequire.ressource.name && element.number == prerequire.ressource.number);
prerequire.ressource = scenario.ressources[i];
} else {
let i: number = role.ressources.findIndex(element => element.name == prerequire.ressource.name && element.number == prerequire.ressource.number);
prerequire.ressource = role.ressources[i];
}
})
} }
}); });
}); });
......
import { PrerequireRessource } from './prerequire-ressource';
describe('PrerequireRessource', () => {
it('should create an instance', () => {
expect(new PrerequireRessource()).toBeTruthy();
});
});
import { Ressource } from "../../ressource/ressource";
export class PrerequireRessource {
constructor(ressource?: Ressource) {
if (ressource) {
this.ressource = ressource;
}
}
ressource!: Ressource;
operator: string = '';
quantity: number = 1;
}
import { PrerequireTask } from './prerequire-task';
describe('PrerequireTask', () => {
it('should create an instance', () => {
expect(new PrerequireTask()).toBeTruthy();
});
});
export class PrerequireTask {
constructor(identifier: string) {
this.identifier = identifier;
}
identifier: string = '';
}
...@@ -12,6 +12,6 @@ export class Scenario { ...@@ -12,6 +12,6 @@ export class Scenario {
missions: Mission[] = [new Mission()]; missions: Mission[] = [new Mission()];
characters: Character[] = []; characters: Character[] = [];
gameRules: string = ''; gameRules: string = '';
ressources: Ressource[] = [new Ressource()]; ressources: Ressource[] = [];
comments: Comment[] = []; comments: Comment[] = [];
} }
\ No newline at end of file
import { Character } from "../character/character"; import { Character } from "../character/character";
import { Comment } from "../comment/comment"; import { Comment } from "../comment/comment";
import { PrerequireRessource } from "../prerequires/prerequire-ressource/prerequire-ressource";
import { PrerequireTask } from "../prerequires/prerequire-task/prerequire-task";
import { Repeat } from "../repeat/repeat"; import { Repeat } from "../repeat/repeat";
import { SupplementaryRole } from "../supplementary-role/supplementary-role"; import { SupplementaryRole } from "../supplementary-role/supplementary-role";
import { Symbol } from "../symbol/symbol"; import { Symbol } from "../symbol/symbol";
...@@ -10,7 +12,8 @@ export class Task { ...@@ -10,7 +12,8 @@ export class Task {
identifier: string = ''; identifier: string = '';
symbol: Symbol = new Symbol(); symbol: Symbol = new Symbol();
objective: string = ''; objective: string = '';
antecedents: Task[] = []; prerequireTasks: PrerequireTask[] = [];
prerequireRessources: PrerequireRessource[] = [];
duration: number = 1; duration: number = 1;
durationUnit: string = 'UT'; durationUnit: string = 'UT';
comments: Comment[] = []; comments: Comment[] = [];
......
...@@ -78,6 +78,15 @@ export class RoleComponent implements OnInit { ...@@ -78,6 +78,15 @@ export class RoleComponent implements OnInit {
} }
removeRessource(index: number): void { 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);
}
});
});
});
this.role.ressources.splice(index, 1); this.role.ressources.splice(index, 1);
} }
......
...@@ -25,51 +25,55 @@ ...@@ -25,51 +25,55 @@
<div class="piece-prerequires-prerequires"> <div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label> <label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element"> <ng-container *ngFor="let inlineTask of role.tasks">
<input name="antecedent" type="checkbox" value="true"/> <ng-container *ngFor="let element of inlineTask; let index = index">
<label for="antecedent">EX1</label> <div class="piece-prerequires-prerequires-element" *ngIf="element?.identifier && (task.identifier != element?.identifier) && index < j">
</div> <input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<div class="piece-prerequires-prerequires-element"> <label for="antecedent">{{element?.identifier}}</label>
<input name="antecedent" type="checkbox"/> </div>
<label for="antecedent">EX2</label> </ng-container>
</div> </ng-container>
</div> </div>
</div> </div>
<div class="piece-prerequires-ressources"> <div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label> <label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element"> <ng-container *ngFor="let ressource of scenario.ressources">
<div class="piece-prerequires-ressources-element-checkbox"> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<input name="ressource" type="checkbox"/> <div class="piece-prerequires-ressources-element-checkbox">
<label for="ressource">Pain</label> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<label for="ressource">{{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> </div>
<div class="piece-prerequires-ressources-element-quantity"> </ng-container>
<select name="ressource"> <ng-container *ngFor="let ressource of role.ressources">
<option><</option> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<option><=</option> <div class="piece-prerequires-ressources-element-checkbox">
<option>=</option> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<option>>=</option> <label for="ressource">{{ressource.name}}</label>
<option>></option> </div>
</select> <div class="piece-prerequires-ressources-element-quantity" *ngIf="isCheckedRessource(ressource)">
<input type="text" value="1"/> <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> </div>
</div> </ng-container>
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Citron</label>
</div>
<div class="piece-prerequires-ressources-element-quantity">
<select name="ressource">
<option><</option>
<option><=</option>
<option>=</option>
<option>>=</option>
<option>></option>
</select>
<input type="text" value="1"/>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
border-left: none; border-left: none;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding-left: 2px;
&-title { &-title {
margin-left: auto; margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
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 { PrerequireTask } from 'src/app/class/prerequires/prerequire-task/prerequire-task';
import { Ressource } from 'src/app/class/ressource/ressource';
import { Role } from 'src/app/class/role/role'; import { Role } from 'src/app/class/role/role';
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';
...@@ -18,6 +22,7 @@ export class AnnexeTaskComponent implements OnInit { ...@@ -18,6 +22,7 @@ export class AnnexeTaskComponent implements OnInit {
pieceWidth: string = '400px'; pieceWidth: string = '400px';
@Input() task: Task = new Task('normal'); @Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission!: Mission; @Input() mission!: Mission;
@Input() role!: Role; @Input() role!: Role;
@Input() i!: number; @Input() i!: number;
...@@ -60,6 +65,15 @@ export class AnnexeTaskComponent implements OnInit { ...@@ -60,6 +65,15 @@ export class AnnexeTaskComponent implements OnInit {
} }
onClickDelete(): void { 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);
}
});
});
});
this.role.removeTask(this.i, this.j); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths(); this.mission.equalizeLengths();
} }
...@@ -123,4 +137,83 @@ export class AnnexeTaskComponent implements OnInit { ...@@ -123,4 +137,83 @@ export class AnnexeTaskComponent implements OnInit {
} }
return [0, 0]; return [0, 0];
} }
changeIdentifier(event: any): void {
let value: string = event.target.value;
if (value != '') {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach(prerequire => {
if (prerequire.identifier == this.task.identifier) {
prerequire.identifier = value;
}
});
});
});
} else {
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.task.identifier = value;
}
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));
}
onUncheckTask(task: Task): void {
let i: number = this.task.prerequireTasks.findIndex(element => element.identifier == task.identifier);
this.task.prerequireTasks.splice(i,1);
}
checkboxChangedRessource(event: any, ressource: Ressource): void {
if (event.target.checked) {
this.onCheckRessource(ressource);
} else {
this.onUncheckRessource(ressource);
}
console.log(this.task.prerequireRessources);
}
isCheckedRessource(ressource: Ressource): boolean {
return this.task.prerequireRessources.some(element => element.ressource == ressource);
}
onCheckRessource(ressource: Ressource): void {
this.task.prerequireRessources.push(new PrerequireRessource(ressource));
}
onUncheckRessource(ressource: Ressource): void {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
this.task.prerequireRessources.splice(i, 1);
}
getAssociatePrerequireRessource(ressource: Ressource): PrerequireRessource {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
return this.task.prerequireRessources[i];
}
} }
...@@ -53,51 +53,55 @@ ...@@ -53,51 +53,55 @@
<div class="piece-prerequires-prerequires"> <div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label> <label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element"> <ng-container *ngFor="let inlineTask of role.tasks">
<input name="antecedent" type="checkbox" value="true"/> <ng-container *ngFor="let element of inlineTask; let index = index">
<label for="antecedent">EX1</label> <div class="piece-prerequires-prerequires-element" *ngIf="element?.identifier && (task.identifier != element?.identifier) && index < j">
</div> <input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<div class="piece-prerequires-prerequires-element"> <label for="antecedent">{{element?.identifier}}</label>
<input name="antecedent" type="checkbox"/> </div>
<label for="antecedent">EX2</label> </ng-container>
</div> </ng-container>
</div> </div>
</div> </div>
<div class="piece-prerequires-ressources"> <div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label> <label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element"> <ng-container *ngFor="let ressource of scenario.ressources">
<div class="piece-prerequires-ressources-element-checkbox"> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<input name="ressource" type="checkbox"/> <div class="piece-prerequires-ressources-element-checkbox">
<label for="ressource">Pain</label> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<label for="ressource">{{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> </div>
<div class="piece-prerequires-ressources-element-quantity"> </ng-container>
<select name="ressource"> <ng-container *ngFor="let ressource of role.ressources">
<option><</option> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<option><=</option> <div class="piece-prerequires-ressources-element-checkbox">
<option>=</option> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<option>>=</option> <label for="ressource">{{ressource.name}}</label>
<option>></option> </div>
</select> <div class="piece-prerequires-ressources-element-quantity" *ngIf="isCheckedRessource(ressource)">
<input type="text" value="1"/> <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> </div>
</div> </ng-container>
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Citron</label>
</div>
<div class="piece-prerequires-ressources-element-quantity">
<select name="ressource">
<option><</option>
<option><=</option>
<option>=</option>
<option>>=</option>
<option>></option>
</select>
<input type="text" value="1"/>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
border-left: none; border-left: none;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding-left: 2px;
&-title { &-title {
margin-left: auto; margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
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 { PrerequireTask } from 'src/app/class/prerequires/prerequire-task/prerequire-task';
import { Ressource } from 'src/app/class/ressource/ressource';
import { Role } from 'src/app/class/role/role'; import { Role } from 'src/app/class/role/role';
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';
...@@ -18,6 +22,7 @@ export class FinalTaskComponent implements OnInit { ...@@ -18,6 +22,7 @@ export class FinalTaskComponent implements OnInit {
pieceWidth: string = '400px'; pieceWidth: string = '400px';
@Input() task: Task = new Task('normal'); @Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission!: Mission; @Input() mission!: Mission;
@Input() role!: Role; @Input() role!: Role;
@Input() i!: number; @Input() i!: number;
...@@ -71,6 +76,15 @@ export class FinalTaskComponent implements OnInit { ...@@ -71,6 +76,15 @@ export class FinalTaskComponent implements OnInit {
} }
onClickDelete(): void { 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);
}
});
});
});
this.role.removeTask(this.i, this.j); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths(); this.mission.equalizeLengths();
} }
...@@ -125,4 +139,83 @@ export class FinalTaskComponent implements OnInit { ...@@ -125,4 +139,83 @@ export class FinalTaskComponent implements OnInit {
} }
return [0, 0]; return [0, 0];
} }
changeIdentifier(event: any): void {
let value: string = event.target.value;
if (value != '') {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach(prerequire => {
if (prerequire.identifier == this.task.identifier) {
prerequire.identifier = value;
}
});
});
});
} else {
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.task.identifier = value;
}
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));
}
onUncheckTask(task: Task): void {
let i: number = this.task.prerequireTasks.findIndex(element => element.identifier == task.identifier);
this.task.prerequireTasks.splice(i,1);
}
checkboxChangedRessource(event: any, ressource: Ressource): void {
if (event.target.checked) {
this.onCheckRessource(ressource);
} else {
this.onUncheckRessource(ressource);
}
console.log(this.task.prerequireRessources);
}
isCheckedRessource(ressource: Ressource): boolean {
return this.task.prerequireRessources.some(element => element.ressource == ressource);
}
onCheckRessource(ressource: Ressource): void {
this.task.prerequireRessources.push(new PrerequireRessource(ressource));
}
onUncheckRessource(ressource: Ressource): void {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
this.task.prerequireRessources.splice(i, 1);
}
getAssociatePrerequireRessource(ressource: Ressource): PrerequireRessource {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
return this.task.prerequireRessources[i];
}
} }
...@@ -54,51 +54,55 @@ ...@@ -54,51 +54,55 @@
<div class="piece-prerequires-prerequires"> <div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label> <label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element"> <ng-container *ngFor="let inlineTask of role.tasks">
<input name="antecedent" type="checkbox" value="true"/> <ng-container *ngFor="let element of inlineTask; let index = index">
<label for="antecedent">EX1</label> <div class="piece-prerequires-prerequires-element" *ngIf="element?.identifier && (task.identifier != element?.identifier) && index < j">
</div> <input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<div class="piece-prerequires-prerequires-element"> <label for="antecedent">{{element?.identifier}}</label>
<input name="antecedent" type="checkbox"/> </div>
<label for="antecedent">EX2</label> </ng-container>
</div> </ng-container>
</div> </div>
</div> </div>
<div class="piece-prerequires-ressources"> <div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label> <label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element"> <ng-container *ngFor="let ressource of scenario.ressources">
<div class="piece-prerequires-ressources-element-checkbox"> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<input name="ressource" type="checkbox"/> <div class="piece-prerequires-ressources-element-checkbox">
<label for="ressource">Pain</label> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<label for="ressource">{{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> </div>
<div class="piece-prerequires-ressources-element-quantity"> </ng-container>
<select name="ressource"> <ng-container *ngFor="let ressource of role.ressources">
<option><</option> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<option><=</option> <div class="piece-prerequires-ressources-element-checkbox">
<option>=</option> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<option>>=</option> <label for="ressource">{{ressource.name}}</label>
<option>></option> </div>
</select> <div class="piece-prerequires-ressources-element-quantity" *ngIf="isCheckedRessource(ressource)">
<input type="text" value="1"/> <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> </div>
</div> </ng-container>
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Citron</label>
</div>
<div class="piece-prerequires-ressources-element-quantity">
<select name="ressource">
<option><</option>
<option><=</option>
<option>=</option>
<option>>=</option>
<option>></option>
</select>
<input type="text" value="1"/>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
border-left: none; border-left: none;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding-left: 2px;
&-title { &-title {
margin-left: auto; margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
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 { PrerequireTask } from 'src/app/class/prerequires/prerequire-task/prerequire-task';
import { Ressource } from 'src/app/class/ressource/ressource';
import { Role } from 'src/app/class/role/role'; import { Role } from 'src/app/class/role/role';
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';
...@@ -18,6 +22,7 @@ export class OptionnalTaskComponent implements OnInit { ...@@ -18,6 +22,7 @@ export class OptionnalTaskComponent implements OnInit {
pieceWidth: string = '400px'; pieceWidth: string = '400px';
@Input() task: Task = new Task('normal'); @Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission!: Mission; @Input() mission!: Mission;
@Input() role!: Role; @Input() role!: Role;
@Input() i!: number; @Input() i!: number;
...@@ -70,6 +75,15 @@ export class OptionnalTaskComponent implements OnInit { ...@@ -70,6 +75,15 @@ export class OptionnalTaskComponent implements OnInit {
} }
onClickDelete(): void { 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);
}
});
});
});
this.role.removeTask(this.i, this.j); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths(); this.mission.equalizeLengths();
} }
...@@ -142,5 +156,84 @@ export class OptionnalTaskComponent implements OnInit { ...@@ -142,5 +156,84 @@ export class OptionnalTaskComponent implements OnInit {
} }
} }
return [0, 0]; return [0, 0];
} }
changeIdentifier(event: any): void {
let value: string = event.target.value;
if (value != '') {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach(prerequire => {
if (prerequire.identifier == this.task.identifier) {
prerequire.identifier = value;
}
});
});
});
} else {
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.task.identifier = value;
}
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));
}
onUncheckTask(task: Task): void {
let i: number = this.task.prerequireTasks.findIndex(element => element.identifier == task.identifier);
this.task.prerequireTasks.splice(i,1);
}
checkboxChangedRessource(event: any, ressource: Ressource): void {
if (event.target.checked) {
this.onCheckRessource(ressource);
} else {
this.onUncheckRessource(ressource);
}
console.log(this.task.prerequireRessources);
}
isCheckedRessource(ressource: Ressource): boolean {
return this.task.prerequireRessources.some(element => element.ressource == ressource);
}
onCheckRessource(ressource: Ressource): void {
this.task.prerequireRessources.push(new PrerequireRessource(ressource));
}
onUncheckRessource(ressource: Ressource): void {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
this.task.prerequireRessources.splice(i, 1);
}
getAssociatePrerequireRessource(ressource: Ressource): PrerequireRessource {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
return this.task.prerequireRessources[i];
}
} }
...@@ -46,51 +46,55 @@ ...@@ -46,51 +46,55 @@
<div class="piece-prerequires-prerequires"> <div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label> <label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element"> <ng-container *ngFor="let inlineTask of role.tasks">
<input name="antecedent" type="checkbox" value="true"/> <ng-container *ngFor="let element of inlineTask; let index = index">
<label for="antecedent">EX1</label> <div class="piece-prerequires-prerequires-element" *ngIf="element?.identifier && (task.identifier != element?.identifier) && index < j">
</div> <input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<div class="piece-prerequires-prerequires-element"> <label for="antecedent">{{element?.identifier}}</label>
<input name="antecedent" type="checkbox"/> </div>
<label for="antecedent">EX2</label> </ng-container>
</div> </ng-container>
</div> </div>
</div> </div>
<div class="piece-prerequires-ressources"> <div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label> <label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element"> <ng-container *ngFor="let ressource of scenario.ressources">
<div class="piece-prerequires-ressources-element-checkbox"> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<input name="ressource" type="checkbox"/> <div class="piece-prerequires-ressources-element-checkbox">
<label for="ressource">Pain</label> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<label for="ressource">{{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> </div>
<div class="piece-prerequires-ressources-element-quantity"> </ng-container>
<select name="ressource"> <ng-container *ngFor="let ressource of role.ressources">
<option><</option> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<option><=</option> <div class="piece-prerequires-ressources-element-checkbox">
<option>=</option> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<option>>=</option> <label for="ressource">{{ressource.name}}</label>
<option>></option> </div>
</select> <div class="piece-prerequires-ressources-element-quantity" *ngIf="isCheckedRessource(ressource)">
<input type="text" value="1"/> <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> </div>
</div> </ng-container>
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Citron</label>
</div>
<div class="piece-prerequires-ressources-element-quantity">
<select name="ressource">
<option><</option>
<option><=</option>
<option>=</option>
<option>>=</option>
<option>></option>
</select>
<input type="text" value="1"/>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
border-left: none; border-left: none;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding-left: 2px;
&-title { &-title {
margin-left: auto; margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
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 { PrerequireTask } from 'src/app/class/prerequires/prerequire-task/prerequire-task';
import { Ressource } from 'src/app/class/ressource/ressource';
import { Role } from 'src/app/class/role/role'; import { Role } from 'src/app/class/role/role';
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';
...@@ -18,6 +22,7 @@ export class RandomEventComponent implements OnInit { ...@@ -18,6 +22,7 @@ export class RandomEventComponent implements OnInit {
pieceWidth: string = '400px'; pieceWidth: string = '400px';
@Input() task: Task = new Task('normal'); @Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission!: Mission; @Input() mission!: Mission;
@Input() role!: Role; @Input() role!: Role;
@Input() i!: number; @Input() i!: number;
...@@ -62,6 +67,15 @@ export class RandomEventComponent implements OnInit { ...@@ -62,6 +67,15 @@ export class RandomEventComponent implements OnInit {
} }
onClickDelete(): void { 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);
}
});
});
});
this.role.removeTask(this.i, this.j); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths(); this.mission.equalizeLengths();
} }
...@@ -119,5 +133,84 @@ export class RandomEventComponent implements OnInit { ...@@ -119,5 +133,84 @@ export class RandomEventComponent implements OnInit {
} }
} }
return [0, 0]; return [0, 0];
} }
changeIdentifier(event: any): void {
let value: string = event.target.value;
if (value != '') {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach(prerequire => {
if (prerequire.identifier == this.task.identifier) {
prerequire.identifier = value;
}
});
});
});
} else {
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.task.identifier = value;
}
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));
}
onUncheckTask(task: Task): void {
let i: number = this.task.prerequireTasks.findIndex(element => element.identifier == task.identifier);
this.task.prerequireTasks.splice(i,1);
}
checkboxChangedRessource(event: any, ressource: Ressource): void {
if (event.target.checked) {
this.onCheckRessource(ressource);
} else {
this.onUncheckRessource(ressource);
}
console.log(this.task.prerequireRessources);
}
isCheckedRessource(ressource: Ressource): boolean {
return this.task.prerequireRessources.some(element => element.ressource == ressource);
}
onCheckRessource(ressource: Ressource): void {
this.task.prerequireRessources.push(new PrerequireRessource(ressource));
}
onUncheckRessource(ressource: Ressource): void {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
this.task.prerequireRessources.splice(i, 1);
}
getAssociatePrerequireRessource(ressource: Ressource): PrerequireRessource {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
return this.task.prerequireRessources[i];
}
} }
<div class="piece" [ngStyle]="{'width': pieceWidth}" (mouseover)="displayMenu='show'" (mouseleave)="displayMenu='hide'; displayPrequires='hide'; displaySymbolChoice='hide'" <div class="piece" [ngStyle]="{'width': pieceWidth}" (mouseover)="displayMenu='show'" (mouseleave)="displayMenu='hide'; displaySymbolChoice='hide'"
[style.background]="task.supplementaryRole ? [style.background]="task.supplementaryRole ?
'linear-gradient(140deg, var(--piece-background-color) 0%, var(--piece-background-color) 55%,'+task.supplementaryRole.color+' 55%,'+task.supplementaryRole.color+' 100%)' 'linear-gradient(140deg, var(--piece-background-color) 0%, var(--piece-background-color) 55%,'+task.supplementaryRole.color+' 55%,'+task.supplementaryRole.color+' 100%)'
: 'var(--piece-background-color)'"> : 'var(--piece-background-color)'">
...@@ -54,58 +54,62 @@ ...@@ -54,58 +54,62 @@
<div class="piece-prerequires-prerequires"> <div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label> <label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element"> <ng-container *ngFor="let inlineTask of role.tasks">
<input name="antecedent" type="checkbox" value="true"/> <ng-container *ngFor="let element of inlineTask; let index = index">
<label for="antecedent">EX1</label> <div class="piece-prerequires-prerequires-element" *ngIf="element?.identifier && (task.identifier != element?.identifier) && index < j">
</div> <input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<div class="piece-prerequires-prerequires-element"> <label for="antecedent">{{element?.identifier}}</label>
<input name="antecedent" type="checkbox"/> </div>
<label for="antecedent">EX2</label> </ng-container>
</div> </ng-container>
</div> </div>
</div> </div>
<div class="piece-prerequires-ressources"> <div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label> <label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form"> <div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element"> <ng-container *ngFor="let ressource of scenario.ressources">
<div class="piece-prerequires-ressources-element-checkbox"> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<input name="ressource" type="checkbox"/> <div class="piece-prerequires-ressources-element-checkbox">
<label for="ressource">Pain</label> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<label for="ressource">{{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> </div>
<div class="piece-prerequires-ressources-element-quantity"> </ng-container>
<select name="ressource"> <ng-container *ngFor="let ressource of role.ressources">
<option><</option> <div class="piece-prerequires-ressources-element" *ngIf="ressource.name">
<option><=</option> <div class="piece-prerequires-ressources-element-checkbox">
<option>=</option> <input name="ressource" type="checkbox" (change)="checkboxChangedRessource($event, ressource)" [checked]="isCheckedRessource(ressource)"/>
<option>>=</option> <label for="ressource">{{ressource.name}}</label>
<option>></option> </div>
</select> <div class="piece-prerequires-ressources-element-quantity" *ngIf="isCheckedRessource(ressource)">
<input type="text" value="1"/> <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> </div>
</div> </ng-container>
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Citron</label>
</div>
<div class="piece-prerequires-ressources-element-quantity">
<select name="ressource">
<option><</option>
<option><=</option>
<option>=</option>
<option>>=</option>
<option>></option>
</select>
<input type="text" value="1"/>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="piece-form"> <div class="piece-form">
<div class="piece-form-top"> <div class="piece-form-top">
<input class="piece-form-top-identifier" name="identifier" type="text" [(ngModel)]="task.identifier" placeholder="A" min="1" maxlength="5"/> <input class="piece-form-top-identifier" name="identifier" type="text" [value]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"/>
<div class="piece-form-top-title">Tâche</div> <div class="piece-form-top-title">Tâche</div>
<mat-icon class="piece-form-top-comment" fontIcon="comment" *ngIf="task.comments.length > 0"></mat-icon> <mat-icon class="piece-form-top-comment" fontIcon="comment" *ngIf="task.comments.length > 0"></mat-icon>
<mat-icon class="piece-form-top-repeat" fontIcon="refresh" *ngIf="task.repeat.iteration > 0 || task.repeat.while != ''"></mat-icon> <mat-icon class="piece-form-top-repeat" fontIcon="refresh" *ngIf="task.repeat.iteration > 0 || task.repeat.while != ''"></mat-icon>
......
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
border-left: none; border-left: none;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding-left: 2px;
&-title { &-title {
margin-left: auto; margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
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 { PrerequireTask } from 'src/app/class/prerequires/prerequire-task/prerequire-task';
import { Ressource } from 'src/app/class/ressource/ressource';
import { Role } from 'src/app/class/role/role'; import { Role } from 'src/app/class/role/role';
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';
...@@ -18,6 +22,7 @@ export class TaskComponent implements OnInit { ...@@ -18,6 +22,7 @@ export class TaskComponent implements OnInit {
pieceWidth: string = '400px'; pieceWidth: string = '400px';
@Input() task: Task = new Task('normal'); @Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission: Mission = new Mission(); @Input() mission: Mission = new Mission();
@Input() role!: Role; @Input() role!: Role;
@Input() i!: number; @Input() i!: number;
...@@ -70,6 +75,15 @@ export class TaskComponent implements OnInit { ...@@ -70,6 +75,15 @@ export class TaskComponent implements OnInit {
} }
onClickDelete(): void { 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);
}
});
});
});
this.role.removeTask(this.i, this.j); this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths(); this.mission.equalizeLengths();
} }
...@@ -143,6 +157,83 @@ export class TaskComponent implements OnInit { ...@@ -143,6 +157,83 @@ export class TaskComponent implements OnInit {
} }
return [0, 0]; return [0, 0];
} }
}
changeIdentifier(event: any): void {
let value: string = event.target.value;
if (value != '') {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach(prerequire => {
if (prerequire.identifier == this.task.identifier) {
prerequire.identifier = value;
}
});
});
});
} else {
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.task.identifier = value;
}
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));
}
onUncheckTask(task: Task): void {
let i: number = this.task.prerequireTasks.findIndex(element => element.identifier == task.identifier);
this.task.prerequireTasks.splice(i,1);
}
checkboxChangedRessource(event: any, ressource: Ressource): void {
if (event.target.checked) {
this.onCheckRessource(ressource);
} else {
this.onUncheckRessource(ressource);
}
console.log(this.task.prerequireRessources);
}
isCheckedRessource(ressource: Ressource): boolean {
return this.task.prerequireRessources.some(element => element.ressource == ressource);
}
onCheckRessource(ressource: Ressource): void {
this.task.prerequireRessources.push(new PrerequireRessource(ressource));
}
onUncheckRessource(ressource: Ressource): void {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
this.task.prerequireRessources.splice(i, 1);
}
getAssociatePrerequireRessource(ressource: Ressource): PrerequireRessource {
let i: number = this.task.prerequireRessources.findIndex(element => ressource == element.ressource);
return this.task.prerequireRessources[i];
}
}
\ No newline at end of file
...@@ -21,7 +21,19 @@ export class RulesComponent implements OnInit { ...@@ -21,7 +21,19 @@ export class RulesComponent implements OnInit {
} }
removeRessource(index: number): void { 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);
}
});
});
});
});
});
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