Commit a11ce600 authored by Romain DELEAU's avatar Romain DELEAU

fix bug on multiple creation of alternative tasks + snackbar alert on...

fix bug on multiple creation of alternative tasks + snackbar alert on transform and delete alternative tasks
parent 35b63f2b
......@@ -393,7 +393,7 @@ export class AppComponent {
if (type == 'optionnal') {
let quantity: number;
let minquantity: number;
if (role.countOptionnalTasksInClolumn(role.getRealIndex(i,j)) > 1) {
if (role.countOptionnalTasksInColumn(role.getRealIndex(i,j)) > 1) {
minquantity = 1;
quantity = 1;
} else {
......@@ -407,6 +407,7 @@ export class AppComponent {
quantity = (result as CreateOptionnalTaskDialogData).quantity;
if ((result as CreateOptionnalTaskDialogData).result == true) {
role.addOptionnalTask(i, j, type, quantity);
this.cdr.detectChanges();
}
});
} else {
......
......@@ -56,6 +56,7 @@ import { LegalDialogComponent } from './components/dialogs/legal-dialog/legal-di
import { RewardsComponent } from './sider-pieces/rewards/rewards.component';
import { MoveOptionnalTasksComponent } from './components/snackbars/move-optionnal-tasks/move-optionnal-tasks.component';
import { CreateOptionnalTaskDialogComponent } from './components/dialogs/create-optionnal-task-dialog/create-optionnal-task-dialog.component';
import { DeleteOptionnalTasksComponent } from './components/snackbars/delete-optionnal-tasks/delete-optionnal-tasks.component';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
......@@ -103,7 +104,8 @@ export function HttpLoaderFactory(http: HttpClient) {
LegalDialogComponent,
RewardsComponent,
MoveOptionnalTasksComponent,
CreateOptionnalTaskDialogComponent
CreateOptionnalTaskDialogComponent,
DeleteOptionnalTasksComponent
],
imports: [
BrowserModule,
......
......@@ -251,7 +251,7 @@ export class Role {
return res;
}
public countOptionnalTasksInClolumn(realColumn: number): number {
public countOptionnalTasksInColumn(realColumn: number): number {
let cpt: number = 0;
this.tasks.forEach((inlineTasks, i) => {
......
<span matSnackBarLabel>{{'snackbar_deleteOptionnalTask' | translate}}</span>
::ng-deep .mat-snack-bar-container {
background-color: #ffa808;
color: white;
box-shadow: 0px 0px 15px 5px #ffa808;
text-align: center;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DeleteOptionnalTasksComponent } from './delete-optionnal-tasks.component';
describe('DeleteOptionnalTasksComponent', () => {
let component: DeleteOptionnalTasksComponent;
let fixture: ComponentFixture<DeleteOptionnalTasksComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DeleteOptionnalTasksComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(DeleteOptionnalTasksComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-delete-optionnal-tasks',
templateUrl: './delete-optionnal-tasks.component.html',
styleUrls: ['./delete-optionnal-tasks.component.scss']
})
export class DeleteOptionnalTasksComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
......@@ -17,6 +17,7 @@ import { Trace } from 'src/app/class/trace/trace';
import { MinimapService } from 'src/app/services/minimap/minimap.service';
import { TranslateService } from '@ngx-translate/core';
import { MoveOptionnalTasksComponent } from 'src/app/components/snackbars/move-optionnal-tasks/move-optionnal-tasks.component';
import { DeleteOptionnalTasksComponent } from 'src/app/components/snackbars/delete-optionnal-tasks/delete-optionnal-tasks.component';
@Component({
selector: 'app-optionnal-task',
......@@ -133,6 +134,9 @@ export class OptionnalTaskComponent implements OnInit {
this.task.symbol.symbol = '';
}
this.task.changeType(type);
if (this.role.countOptionnalTasksInColumn(this.role.getRealIndex(this.i,this.j)) < 2) {
this._snackBar.openFromComponent(DeleteOptionnalTasksComponent, { duration: 5000 });
}
this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform_into_['+type+']',this.missionIndex,this.roleIndex,'all','Opt_task_['+this.i+';'+this.j+']', '#E8E3B3'));
}
......@@ -151,6 +155,9 @@ export class OptionnalTaskComponent implements OnInit {
});
this.role.removeTask(this.i, this.j);
this.mission.equalizeLengths();
if (this.role.countOptionnalTasksInColumn(this.role.getRealIndex(this.i,this.j)) < 2) {
this._snackBar.openFromComponent(DeleteOptionnalTasksComponent, { duration: 5000 });
}
this.scenario.traces.push(new Trace(this.scenario.traces.length,'delete',this.missionIndex,this.roleIndex,'all','Opt_task_['+this.i+';'+this.j+']', '#E8E3B3'));
} else {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'cancel_delete',this.missionIndex,this.roleIndex,'all','Opt_task_['+this.i+';'+this.j+']', '#E8E3B3'));
......
......@@ -38,6 +38,7 @@
"snackbar_loading_success": "File upload successful.",
"snackbar_roleName": "Attention, this title is already used in this Mission",
"snackbar_moveOptionnalTask": "Make sure to keep alternative tasks grouped in the same column",
"snackbar_deleteOptionnalTask": "Attention, alternative tasks go in pairs at minimum, ensure that the user always has a choice between several of these tasks",
"siderTitle_game": "Game",
"siderTitle_mission": "Mission",
......
......@@ -38,6 +38,7 @@
"snackbar_loading_success": "Chargement du fichier réussi",
"snackbar_roleName": "Attention, cet intitulé est déjà utilisé dans cette Mission",
"snackbar_moveOptionnalTask": "Veillez à garder les tâches alternatives groupées dans la même colonne",
"snackbar_deleteOptionnalTask": "Attention, les tâches alternatives vont au minimum par deux, veillez à ce que l'utilisateur ait toujours le choix entre plusieurs de ces tâches",
"siderTitle_game": "Jeu",
"siderTitle_mission": "Mission",
......
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