Commit e3968fae authored by Romain DELEAU's avatar Romain DELEAU

prerequires

parent 566ce1a6
......@@ -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 *ngFor="let task of tasks, let j = index" [style.z-index]="tasks.length-j">
<div *ngIf="task != null">
<app-task *ngIf="task.type == 'normal'" [task]="task" [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-random-event *ngIf="task.type == 'event'" [task]="task" [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-final-task *ngIf="task.type == 'final'" [task]="task" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-final-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" [scenario]="scenario" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-annexe-task>
<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" [scenario]="scenario" [mission]="mission" [role]="role" [i]="i" [j]="j"></app-optionnal-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>
</div>
<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';
import { ObjectsReward } from './class/rewards/objects-reward/objects-reward';
import { ObjectiveReward } from './class/rewards/objective-reward/objective-reward';
import { OtherReward } from './class/rewards/other-reward/other-reward';
import { PrerequireRessource } from './class/prerequires/prerequire-ressource/prerequire-ressource';
import { elementAt } from 'rxjs';
@Component({
selector: 'app-root',
......@@ -165,6 +167,16 @@ export class AppComponent {
&& element.color == task.supplementaryRole.color
);
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 {
missions: Mission[] = [new Mission()];
characters: Character[] = [];
gameRules: string = '';
ressources: Ressource[] = [new Ressource()];
ressources: Ressource[] = [];
comments: Comment[] = [];
}
\ No newline at end of file
import { Character } from "../character/character";
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 { SupplementaryRole } from "../supplementary-role/supplementary-role";
import { Symbol } from "../symbol/symbol";
......@@ -10,7 +12,8 @@ export class Task {
identifier: string = '';
symbol: Symbol = new Symbol();
objective: string = '';
antecedents: Task[] = [];
prerequireTasks: PrerequireTask[] = [];
prerequireRessources: PrerequireRessource[] = [];
duration: number = 1;
durationUnit: string = 'UT';
comments: Comment[] = [];
......
......@@ -78,6 +78,15 @@ export class RoleComponent implements OnInit {
}
removeRessource(index: number): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireRessources.forEach((prerequire, j) => {
if (prerequire.ressource == this.role.ressources[index]) {
task.prerequireRessources.splice(j, 1);
}
});
});
});
this.role.ressources.splice(index, 1);
}
......
......@@ -25,51 +25,55 @@
<div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox" value="true"/>
<label for="antecedent">EX1</label>
</div>
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox"/>
<label for="antecedent">EX2</label>
</div>
<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) && index < j">
<input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<label for="antecedent">{{element?.identifier}}</label>
</div>
</ng-container>
</ng-container>
</div>
</div>
<div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Pain</label>
<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">{{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 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"/>
</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">{{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">
<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>
</ng-container>
</div>
</div>
</div>
......
......@@ -65,6 +65,7 @@
border-left: none;
display: flex;
flex-direction: row;
padding-left: 2px;
&-title {
margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core';
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 { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
......@@ -18,6 +22,7 @@ export class AnnexeTaskComponent implements OnInit {
pieceWidth: string = '400px';
@Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission!: Mission;
@Input() role!: Role;
@Input() i!: number;
......@@ -60,6 +65,15 @@ export class AnnexeTaskComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
......@@ -123,4 +137,83 @@ export class AnnexeTaskComponent implements OnInit {
}
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 @@
<div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox" value="true"/>
<label for="antecedent">EX1</label>
</div>
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox"/>
<label for="antecedent">EX2</label>
</div>
<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) && index < j">
<input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<label for="antecedent">{{element?.identifier}}</label>
</div>
</ng-container>
</ng-container>
</div>
</div>
<div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Pain</label>
<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">{{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 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"/>
</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">{{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">
<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>
</ng-container>
</div>
</div>
</div>
......
......@@ -111,6 +111,7 @@
border-left: none;
display: flex;
flex-direction: row;
padding-left: 2px;
&-title {
margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core';
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 { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
......@@ -18,6 +22,7 @@ export class FinalTaskComponent implements OnInit {
pieceWidth: string = '400px';
@Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission!: Mission;
@Input() role!: Role;
@Input() i!: number;
......@@ -71,6 +76,15 @@ export class FinalTaskComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
......@@ -125,4 +139,83 @@ export class FinalTaskComponent implements OnInit {
}
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 @@
<div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox" value="true"/>
<label for="antecedent">EX1</label>
</div>
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox"/>
<label for="antecedent">EX2</label>
</div>
<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) && index < j">
<input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<label for="antecedent">{{element?.identifier}}</label>
</div>
</ng-container>
</ng-container>
</div>
</div>
<div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Pain</label>
<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">{{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 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"/>
</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">{{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">
<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>
</ng-container>
</div>
</div>
</div>
......
......@@ -111,6 +111,7 @@
border-left: none;
display: flex;
flex-direction: row;
padding-left: 2px;
&-title {
margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core';
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 { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
......@@ -18,6 +22,7 @@ export class OptionnalTaskComponent implements OnInit {
pieceWidth: string = '400px';
@Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission!: Mission;
@Input() role!: Role;
@Input() i!: number;
......@@ -70,6 +75,15 @@ export class OptionnalTaskComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
......@@ -142,5 +156,84 @@ export class OptionnalTaskComponent implements OnInit {
}
}
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 @@
<div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox" value="true"/>
<label for="antecedent">EX1</label>
</div>
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox"/>
<label for="antecedent">EX2</label>
</div>
<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) && index < j">
<input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<label for="antecedent">{{element?.identifier}}</label>
</div>
</ng-container>
</ng-container>
</div>
</div>
<div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Pain</label>
<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">{{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 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"/>
</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">{{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">
<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>
</ng-container>
</div>
</div>
</div>
......
......@@ -102,6 +102,7 @@
border-left: none;
display: flex;
flex-direction: row;
padding-left: 2px;
&-title {
margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core';
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 { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
......@@ -18,6 +22,7 @@ export class RandomEventComponent implements OnInit {
pieceWidth: string = '400px';
@Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission!: Mission;
@Input() role!: Role;
@Input() i!: number;
......@@ -62,6 +67,15 @@ export class RandomEventComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
......@@ -119,5 +133,84 @@ export class RandomEventComponent implements OnInit {
}
}
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 ?
'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)'">
......@@ -54,58 +54,62 @@
<div class="piece-prerequires-prerequires">
<label class="piece-prerequires-title">Antécédents</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox" value="true"/>
<label for="antecedent">EX1</label>
</div>
<div class="piece-prerequires-prerequires-element">
<input name="antecedent" type="checkbox"/>
<label for="antecedent">EX2</label>
</div>
<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) && index < j">
<input name="antecedent" type="checkbox" [checked]="isCheckedTask(element)" (change)="checkboxChangedTask($event, element)"/>
<label for="antecedent">{{element?.identifier}}</label>
</div>
</ng-container>
</ng-container>
</div>
</div>
<div class="piece-prerequires-ressources">
<label class="piece-prerequires-title">Ressources & attributs</label>
<div class="piece-prerequires-form">
<div class="piece-prerequires-ressources-element">
<div class="piece-prerequires-ressources-element-checkbox">
<input name="ressource" type="checkbox"/>
<label for="ressource">Pain</label>
<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">{{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 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"/>
</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">{{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">
<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>
</ng-container>
</div>
</div>
</div>
<div class="piece-form">
<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>
<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>
......
......@@ -111,6 +111,7 @@
border-left: none;
display: flex;
flex-direction: row;
padding-left: 2px;
&-title {
margin-left: auto;
......
import { Component, Input, OnInit } from '@angular/core';
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 { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
......@@ -18,6 +22,7 @@ export class TaskComponent implements OnInit {
pieceWidth: string = '400px';
@Input() task: Task = new Task('normal');
@Input() scenario: Scenario = new Scenario();
@Input() mission: Mission = new Mission();
@Input() role!: Role;
@Input() i!: number;
......@@ -70,6 +75,15 @@ export class TaskComponent implements OnInit {
}
onClickDelete(): void {
this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => {
task?.prerequireTasks.forEach((prerequire, index) => {
if (prerequire.identifier == this.task.identifier) {
task.prerequireTasks.splice(index, 1);
}
});
});
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
}
......@@ -143,6 +157,83 @@ export class TaskComponent implements OnInit {
}
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 {
}
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);
}
}
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