Commit 04fdadf0 authored by Romain DELEAU's avatar Romain DELEAU

error on duplicated role title + fix on duplicated identifier tasks error

parent 80620d5b
......@@ -50,6 +50,7 @@ import { TutorialComponent } from './components/tutorial/tutorial.component';
import { FinishTutorialComponent } from './components/snackbars/finish-tutorial/finish-tutorial.component';
import { VerifyGameFailSnackbarComponent } from './components/snackbars/verify-game-fail-snackbar/verify-game-fail-snackbar.component';
import { VerifyDialogComponent } from './components/dialogs/verify-dialog/verify-dialog.component';
import { RoleNameDuplicateComponent } from './components/snackbars/role-name-duplicate/role-name-duplicate.component';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
......@@ -91,7 +92,8 @@ export function HttpLoaderFactory(http: HttpClient) {
TutorialComponent,
FinishTutorialComponent,
VerifyGameFailSnackbarComponent,
VerifyDialogComponent
VerifyDialogComponent,
RoleNameDuplicateComponent
],
imports: [
BrowserModule,
......
::ng-deep .mat-snack-bar-container {
background-color: #fec001;
color: black;
box-shadow: 0px 0px 15px 5px #fec001;
background-color: #de3e44;
color: white;
box-shadow: 0px 0px 15px 5px #de3e44;
text-align: center;
}
\ No newline at end of file
<span matSnackBarLabel>{{'snackbar_roleName' | translate}}</span>
::ng-deep .mat-snack-bar-container {
background-color: #de3e44;
color: white;
box-shadow: 0px 0px 15px 5px #de3e44;
text-align: center;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RoleNameDuplicateComponent } from './role-name-duplicate.component';
describe('RoleNameDuplicateComponent', () => {
let component: RoleNameDuplicateComponent;
let fixture: ComponentFixture<RoleNameDuplicateComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ RoleNameDuplicateComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(RoleNameDuplicateComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-role-name-duplicate',
templateUrl: './role-name-duplicate.component.html',
styleUrls: ['./role-name-duplicate.component.scss']
})
export class RoleNameDuplicateComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
......@@ -25,7 +25,7 @@ matTooltipPosition="left" [matTooltipDisabled]="!tooltipService.activatedTooltip
<img src="./assets/background-images/role2_opacity0.png" draggable="false" *ngIf="i == 1"/>
<div class="piece-form-intitule">
<label for="intitule">{{'role_intitule_label' | translate}}</label>
<input name="intitule" type="text" [(ngModel)]="role.intitule" (change)="editTrace($event,'name'); validTutorialPhase4();" [placeholder]="translate.instant('role_intitule_placeholder')"
<input name="intitule" type="text" [(ngModel)]="role.intitule" (change)="changeIntitule($event); validTutorialPhase4();" [placeholder]="translate.instant('role_intitule_placeholder')"
[matTooltip]="translate.instant('role_intitule_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"/>
</div>
......
......@@ -21,6 +21,8 @@ import { Trace } from 'src/app/class/trace/trace';
import { MinimapService } from 'src/app/services/minimap/minimap.service';
import { TranslateService } from '@ngx-translate/core';
import { TutorialService } from 'src/app/services/tutorial/tutorial.service';
import { MatSnackBar } from '@angular/material/snack-bar';
import { RoleNameDuplicateComponent } from 'src/app/components/snackbars/role-name-duplicate/role-name-duplicate.component';
@Component({
selector: 'app-role',
......@@ -35,7 +37,7 @@ export class RoleComponent implements OnInit {
@Input() i: number = 0;
@Input() missionIndex: number = 0;
constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog, private minimapService: MinimapService, protected translate: TranslateService, private tutorialService: TutorialService) { }
constructor(protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, public dialog: MatDialog, private minimapService: MinimapService, protected translate: TranslateService, private tutorialService: TutorialService, private _snackBar: MatSnackBar,) { }
ngOnInit(): void {
this.mission.equalizeLengths();
......@@ -293,4 +295,14 @@ export class RoleComponent implements OnInit {
this.tutorialService.validPhase();
}
}
changeIntitule(event: any): void {
this.mission.roles.forEach(role => {
if (role != this.role && role.intitule == this.role.intitule) {
this._snackBar.openFromComponent(RoleNameDuplicateComponent, { duration: 5000 });
this.role.intitule = '';
}
});
this.editTrace(event, 'name');
}
}
......@@ -113,7 +113,7 @@
<div class="piece-form">
<div class="piece-form-top">
<input class="piece-form-top-identifier" name="identifier" type="text" [value]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
<input class="piece-form-top-identifier" name="identifier" type="text" [(ngModel)]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
[matTooltip]="translate.instant('task_identifier_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"/>
<div class="piece-form-top-title">{{'annexeTask_title' | translate}}</div>
......
......@@ -265,7 +265,6 @@ export class AnnexeTaskComponent implements OnInit {
});
});
}
this.task.identifier = value;
if (this.role.isAlreadyUsedIdentifier(this.task.identifier)) {
this._snackBar.openFromComponent(IdentifierSnackbarComponent, { duration: 5000 });
this.task.identifier = '';
......
......@@ -141,7 +141,7 @@
<div class="piece-form">
<div class="piece-form-top">
<input class="piece-form-top-identifier" name="identifier" type="text" [value]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
<input class="piece-form-top-identifier" name="identifier" type="text" [(ngModel)]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
[matTooltip]="translate.instant('task_identifier_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"/>
<div class="piece-form-top-title">{{'finalTask_title' | translate}}</div>
......
......@@ -273,7 +273,6 @@ export class FinalTaskComponent implements OnInit {
});
});
}
this.task.identifier = value;
if (this.role.isAlreadyUsedIdentifier(this.task.identifier)) {
this._snackBar.openFromComponent(IdentifierSnackbarComponent, { duration: 5000 });
this.task.identifier = '';
......
......@@ -142,7 +142,7 @@
<div class="piece-form">
<div class="piece-form-top">
<input class="piece-form-top-identifier" name="identifier" type="text" [value]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
<input class="piece-form-top-identifier" name="identifier" type="text" [(ngModel)]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
[matTooltip]="translate.instant('task_identifier_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"/>
<div class="piece-form-top-title">{{'optionnalTask_title1' | translate}}<br>{{'optionnalTask_title2' | translate}}</div>
......
......@@ -290,7 +290,6 @@ export class OptionnalTaskComponent implements OnInit {
});
});
}
this.task.identifier = value;
if (this.role.isAlreadyUsedIdentifier(this.task.identifier)) {
this._snackBar.openFromComponent(IdentifierSnackbarComponent, { duration: 5000 });
this.task.identifier = '';
......
......@@ -130,7 +130,7 @@
<div class="piece-form">
<div class="piece-form-top">
<input class="piece-form-top-identifier" name="identifier" type="text" [value]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
<input class="piece-form-top-identifier" name="identifier" type="text" [(ngModel)]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
[matTooltip]="translate.instant('task_identifier_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"/>
<div class="piece-form-top-title">{{'randomEvent_title1' | translate}}<br>{{'randomEvent_title2' | translate}}</div>
......
......@@ -267,7 +267,6 @@ export class RandomEventComponent implements OnInit {
});
});
}
this.task.identifier = value;
if (this.role.isAlreadyUsedIdentifier(this.task.identifier)) {
this._snackBar.openFromComponent(IdentifierSnackbarComponent, { duration: 5000 });
this.task.identifier = '';
......
......@@ -140,7 +140,7 @@
<div class="piece-form">
<div class="piece-form-top">
<input class="piece-form-top-identifier" name="identifier" type="text" [value]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
<input class="piece-form-top-identifier" name="identifier" type="text" [(ngModel)]="task.identifier" (change)="changeIdentifier($event)" placeholder="A" min="1" maxlength="5"
[matTooltip]="translate.instant('task_identifier_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"/>
<div class="piece-form-top-title">{{'normalTask_title' | translate}}</div>
......
......@@ -307,7 +307,6 @@ export class TaskComponent implements OnInit {
});
});
}
this.task.identifier = value;
if (this.role.isAlreadyUsedIdentifier(this.task.identifier)) {
this._snackBar.openFromComponent(IdentifierSnackbarComponent, { duration: 5000 });
this.task.identifier = '';
......
......@@ -26,6 +26,7 @@
"snackbar_identifier": "Attention, this identifier is already used in this Role.",
"snackbar_loading_fail": "File upload failed.",
"snackbar_loading_success": "File upload successful.",
"snackbar_roleName": "Attention, this title is already used in this Mission",
"siderTitle_game": "Game",
"siderTitle_mission": "Mission",
......
......@@ -26,6 +26,7 @@
"snackbar_identifier": "Attention, cet identifiant est déjà utilisé dans ce Rôle",
"snackbar_loading_fail": "Chargement du fichier échoué",
"snackbar_loading_success": "Chargement du fichier réussi",
"snackbar_roleName": "Attention, cet intitulé est déjà utilisé dans cette Mission",
"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