Commit cdc263aa authored by Romain DELEAU's avatar Romain DELEAU

Discussions (without results)

parent 34f8d656
......@@ -130,7 +130,8 @@
<app-repeat class="container-sider-elements-element" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()" [scenario]="scenario"></app-repeat>
<app-interupt class="container-sider-elements-element" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()" [scenario]="scenario"></app-interupt>
<app-characters class="container-sider-elements-element" [scenario]="scenario" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()"></app-characters>
<app-comments class="container-sider-elements-element" [piece]="pieceDetailsService.piece" [scenario]="scenario"></app-comments>
<app-comments class="container-sider-elements-element" [piece]="pieceDetailsService.piece" [scenario]="scenario"></app-comments>
<app-discussions class="container-sider-elements-element" [scenario]="scenario" [role]="pieceDetailsService.pieceAsRole()" *ngIf="unityService.unity_isActive && pieceDetailsService.pieceIsRole()"></app-discussions>
</div>
</div>
......
......@@ -343,4 +343,9 @@
.mat-icon-no-color {
color: black;
}
}
::ng-deep .mat-expansion-panel-content {
font-family: 'Glacial Indifference', sans-serif;
font-size: 16px;
}
\ No newline at end of file
......@@ -42,6 +42,11 @@ import { VerifyDialogComponent } from './components/dialogs/verify-dialog/verify
import { LegalDialogComponent } from './components/dialogs/legal-dialog/legal-dialog.component';
import { CreateOptionnalTaskDialogComponent } from './components/dialogs/create-optionnal-task-dialog/create-optionnal-task-dialog.component';
import { UnityService } from './services/unity/unity.service';
import { Discussion } from './class/discussion/discussion';
import { Response } from './class/response/response';
import { Sentence } from './class/sentence/sentence';
import { InterrogativeSentence } from './class/sentence/interrogativeSentence/interrogative-sentence';
import { DeclarativeSentence } from './class/sentence/declarativeSentence/declarative-sentence';
@Component({
selector: 'app-root',
......@@ -286,6 +291,28 @@ export class AppComponent {
}
});
role.discussions = role.discussions.map((discussionData: any) => {
let character: Character | undefined = scenario.characters.find(char => char.color == discussionData.character.color
&& char.description == discussionData.character.description && char.name == discussionData.character.name && char.tel == discussionData.character.tel);
let discussion: Discussion = Object.assign(
new Discussion(
discussionData.ID,
character as Character,
discussionData.name
),
discussionData
);
discussion.character = character as Character;
return discussion;
});
role.sentences = role.sentences.map((sentenceData: any) => {
if (sentenceData.responses) {
return Object.assign(new InterrogativeSentence(sentenceData.ID), sentenceData);
} else {
return Object.assign(new DeclarativeSentence(sentenceData.ID), sentenceData);
}
});
role.responses = role.responses.map((responseData: any) => Object.assign(new Response(responseData.ID), responseData));
role.tasks.forEach((inlineTasks: any[], index: number) => {
role.tasks[index] = inlineTasks.map((taskData: any) => {
if (taskData !== null) {
......
......@@ -10,6 +10,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
import { MatDialogModule } from '@angular/material/dialog';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { MatExpansionModule } from '@angular/material/expansion';
import { AppComponent } from './app.component';
import { EducationalObjectiveComponent } from './pieces/educational-objective/educational-objective.component';
......@@ -57,6 +58,8 @@ 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';
import { DiscussionsComponent } from './sider-pieces/discussions/discussions.component';
import { DiscussionDialogComponent } from './components/dialogs/discussion-dialog/discussion-dialog.component';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
......@@ -105,7 +108,9 @@ export function HttpLoaderFactory(http: HttpClient) {
RewardsComponent,
MoveOptionnalTasksComponent,
CreateOptionnalTaskDialogComponent,
DeleteOptionnalTasksComponent
DeleteOptionnalTasksComponent,
DiscussionsComponent,
DiscussionDialogComponent
],
imports: [
BrowserModule,
......@@ -126,7 +131,8 @@ export function HttpLoaderFactory(http: HttpClient) {
deps: [HttpClient]
}
}),
DragDropModule
DragDropModule,
MatExpansionModule
],
providers: [],
bootstrap: [AppComponent]
......
import { Discussion } from './discussion';
describe('Discussion', () => {
it('should create an instance', () => {
expect(new Discussion()).toBeTruthy();
});
});
import { Character } from "../character/character";
export class Discussion {
constructor(ID: number, character: Character, name: string) {
this.ID = ID;
this.character = character;
this.name = name;
}
name: string = '';
ID: number = 0;
sentences: number[] = [];
results: [] = [];
firstSentenceID: number = -1;
character: Character;
isFirstDiscussion: boolean = false;
}
import { Response } from './response';
describe('Response', () => {
it('should create an instance', () => {
expect(new Response()).toBeTruthy();
});
});
export class Response {
constructor(ID: number) {
this.ID = ID;
}
ID: number = 0;
value: string = '';
nextSentence: number = -1;
results: [] = [];
idInterrogativeSentence: number = 0;
}
......@@ -6,6 +6,9 @@ import { Reward } from "../rewards/reward";
import { RoleOccurrence } from "../role-occurrence/role-occurrence";
import { RoleEducationnalObjective } from "../role-educationnal-objective/role-educationnal-objective";
import { Comment } from "../comment/comment";
import { Discussion } from "../discussion/discussion";
import { Sentence } from "../sentence/sentence";
import { Response } from "../response/response";
export class Role {
......@@ -21,6 +24,12 @@ export class Role {
occurences: RoleOccurrence[] = [new RoleOccurrence()];
tasks: (Task | null)[][] = [[new Task('normal')], []];
chronologie: (Step | null)[] = [];
discussions: Discussion[] = [];
actualDiscussionID: number = 0;
sentences: Sentence[] = [];
actualSentenceID: number = 0;
responses: Response[] = [];
actualResponseID: number = 0;
public addChronologieStep(index: number) {
this.chronologie[index] = new Step();
......
import { DeclarativeSentence } from './declarative-sentence';
describe('DeclarativeSentence', () => {
it('should create an instance', () => {
expect(new DeclarativeSentence()).toBeTruthy();
});
});
import { Sentence } from "../sentence";
export class DeclarativeSentence extends Sentence {
nextSentence: number = -1;
}
import { InterrogativeSentence } from './interrogative-sentence';
describe('InterrogativeSentence', () => {
it('should create an instance', () => {
expect(new InterrogativeSentence()).toBeTruthy();
});
});
import { Sentence } from "../sentence";
import { Response } from "../../response/response";
export class InterrogativeSentence extends Sentence {
responses: number[] = [];
}
import { Sentence } from './sentence';
describe('Sentence', () => {
it('should create an instance', () => {
expect(new Sentence()).toBeTruthy();
});
});
export abstract class Sentence {
constructor(ID: number) {
this.ID = ID;
}
ID: number = 0;
value: string = '';
results: [] = [];
idDiscussion: number = 0;
}
<h1 mat-dialog-title>{{'discussion_title' | translate}}</h1>
<mat-dialog-content>
<div class="form-intitule">
<label for="intitule">{{'discussion_name_label' | translate}}</label>
<input name="intitule" type="text" [(ngModel)]="discussion.name"/>
</div>
<div class="form-firstDiscussion"
[matTooltip]="translate.instant('discussion_firstDiscussion_tooltip')"
matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedTooltips || isSelectableAsFirstDiscussion()">
<input name="firstDiscussion" type="checkbox" [(ngModel)]="discussion.isFirstDiscussion"
[disabled]="!isSelectableAsFirstDiscussion()"/>
<label for="firstDiscussion">{{'discussion_firstDiscussion_label' | translate}}</label>
</div>
<div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label>
<select name="result">
<option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option>
</select>
</div>
<div class="form-addSentence">
<button mat-button (click)="addDeclarativeSentence()">{{'discussion_buttons_newDeclarativeSentence' | translate}}</button>
<button mat-button (click)="addInterrogativeSentence()">{{'discussion_buttons_newInterrogativeSentence' | translate}}</button>
</div>
<mat-accordion>
<ng-container *ngFor="let sentence of role.sentences">
<mat-expansion-panel *ngIf="sentence.idDiscussion == discussion.ID && isDeclarativeSentence(sentence)">
<mat-expansion-panel-header>
<mat-panel-title>{{'discussion_declarativeSentence' | translate}} (ID: {{sentence.ID}})</mat-panel-title>
<mat-panel-description>
<p>{{sentence.value}}</p>
<mat-icon fontIcon="looks_one" *ngIf="sentence.ID == discussion.firstSentenceID"
[matTooltip]="translate.instant('discussion_firstSentence_label')"
matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedTooltips"></mat-icon>
</mat-panel-description>
</mat-expansion-panel-header>
<div class="form-sentence">
<div class="form-sentence-sentence">
<label for="sentence">{{'discussion_declarativeSentence' | translate}}</label>
<textarea name="sentence" [(ngModel)]="sentence.value"></textarea>
</div>
<div class="form-sentence-firstSentence"
[matTooltip]="translate.instant('discussion_firstSentence_tooltip')"
matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedTooltips || discussion.firstSentenceID == -1 || discussion.firstSentenceID == sentence.ID">
<input name="firstSentence" type="checkbox" (click)="onCheckFirstSentence($event, sentence.ID)"
[checked]="discussion.firstSentenceID == sentence.ID ? true : false"
[disabled]="discussion.firstSentenceID != -1 && discussion.firstSentenceID != sentence.ID"/>
<label for="firstSentence">{{'discussion_firstSentence_label' | translate}}</label>
</div>
<div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label>
<select name="result">
<option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option>
</select>
</div>
<div class="form-nextSentence">
<label for="nextSentence">{{'discussion_nextSentence_label' | translate}}</label>
<select name="nextSentence" [(ngModel)]="getSentenceAsDeclarativeSentence(sentence).nextSentence">
<option [ngValue]="-1" disabled selected>{{'discussion_nextSentence_placeholder' | translate}}</option>
<ng-container *ngFor="let nextSentence of role.sentences">
<option [ngValue]="nextSentence.ID" *ngIf="sentence.ID != nextSentence.ID && sentence.idDiscussion == nextSentence.idDiscussion">ID: {{nextSentence.ID}}</option>
</ng-container>
</select>
</div>
<button mat-button class="form-sentence-delete" (click)="deleteDeclarativeSentence(sentence.ID)">{{'discussion_buttons_deleteDeclarativeSentence' | translate}}</button>
</div>
</mat-expansion-panel>
<mat-expansion-panel *ngIf="sentence.idDiscussion == discussion.ID && isInterrogativeSentence(sentence)">
<mat-expansion-panel-header>
<mat-panel-title>{{'discussion_interrogativeSentence' | translate}} (ID: {{sentence.ID}})</mat-panel-title>
<mat-panel-description>
<p>{{sentence.value}}</p>
<mat-icon fontIcon="looks_one" *ngIf="sentence.ID == discussion.firstSentenceID"
[matTooltip]="translate.instant('discussion_firstSentence_label')"
matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedTooltips"></mat-icon>
</mat-panel-description>
</mat-expansion-panel-header>
<div class="form-sentence">
<div class="form-sentence-sentence">
<label for="sentence">{{'discussion_interrogativeSentence' | translate}}</label>
<textarea name="sentence" [(ngModel)]="sentence.value"></textarea>
</div>
<div class="form-sentence-firstSentence"
[matTooltip]="translate.instant('discussion_firstSentence_tooltip')"
matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedTooltips || discussion.firstSentenceID == -1 || discussion.firstSentenceID == sentence.ID">
<input name="firstSentence" type="checkbox" (click)="onCheckFirstSentence($event, sentence.ID)"
[checked]="discussion.firstSentenceID == sentence.ID ? true : false"
[disabled]="discussion.firstSentenceID != -1 && discussion.firstSentenceID != sentence.ID"/>
<label for="firstSentence">{{'discussion_firstSentence_label' | translate}}</label>
</div>
<div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label>
<select name="result">
<option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option>
</select>
</div>
<button mat-button class="form-sentence-addResponse" (click)="addResponse(getSentenceAsInterrogativeSentence(sentence))">{{'discussion_buttons_newResponse' | translate}}</button>
<mat-accordion>
<ng-container *ngFor="let response of role.responses">
<mat-expansion-panel *ngIf="response.idInterrogativeSentence == sentence.ID">
<mat-expansion-panel-header>
<mat-panel-title>{{'discussion_response' | translate}} (ID: {{response.ID}})</mat-panel-title>
<mat-panel-description>
<p>{{response.value}}</p>
</mat-panel-description>
</mat-expansion-panel-header>
<div class="form-sentence">
<div class="form-sentence-sentence">
<label for="sentence">{{'discussion_response' | translate}}</label>
<textarea name="sentence" [(ngModel)]="response.value"></textarea>
</div>
<div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label>
<select name="result">
<option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option>
</select>
</div>
<div class="form-nextSentence">
<label for="nextSentence">{{'discussion_nextSentence_label' | translate}}</label>
<select name="nextSentence" [(ngModel)]="response.nextSentence">
<option [ngValue]="-1" disabled selected>{{'discussion_nextSentence_placeholder' | translate}}</option>
<ng-container *ngFor="let nextSentence of role.sentences">
<option [ngValue]="nextSentence.ID" *ngIf="sentence.ID != nextSentence.ID && sentence.idDiscussion == nextSentence.idDiscussion">ID: {{nextSentence.ID}}</option>
</ng-container>
</select>
</div>
<button mat-button class="form-sentence-delete" (click)="deleteResponse(getSentenceAsInterrogativeSentence(sentence), response.ID)" *ngIf="countResponses(sentence.ID) > 1">{{'discussion_buttons_deleteResponse' | translate}}</button>
</div>
</mat-expansion-panel>
</ng-container>
</mat-accordion>
<button mat-button class="form-sentence-delete" (click)="deleteInterrogativeSentence(sentence.ID)">{{'discussion_buttons_deleteInterrogativeSentence' | translate}}</button>
</div>
</mat-expansion-panel>
</ng-container>
</mat-accordion>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button mat-dialog-close>{{'discussion_buttons_close' | translate}}</button>
</mat-dialog-actions>
\ No newline at end of file
h1, h2, h3, mat-panel-title {
font-family: 'Glacial Indifference Bold', sans-serif;
}
button {
background-color: #e0d5e9;
}
label {
font-size: 17px;
}
mat-dialog-content {
font-size: 16px;
padding-top: 5px;
padding-bottom: 5px;
}
mat-expansion-panel-content {
font-family: 'Glacial Indifference', sans-serif;
}
.mat-expansion-panel-header-description {
justify-content: space-between;
p {
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 1;
line-clamp: 1;
-webkit-box-orient: vertical;
width: fit-content;
}
}
mat-dialog-actions {
margin-top: 20px;
}
.form {
&-intitule {
margin-bottom: 15px;
label {
margin-right: 10px;
}
input {
width: 25%;
}
}
&-firstDiscussion {
margin-bottom: 25px;
label {
margin-left: 10px;
}
}
&-result {
margin-top: 20px;
}
&-result, &-nextSentence {
width: 40%;
display: flex;
justify-content: space-between;
margin-bottom: 5px;
select {
width: 250px;
}
}
&-addSentence {
margin-top: 15px;
margin-bottom: 15px;
button {
margin-right: 10px;
}
}
&-sentence {
&-sentence {
display: flex;
flex-direction: column;
textarea {
width: 100%;
resize: vertical;
min-height: 100px;
max-height: 200px;
}
}
&-firstSentence {
margin-top: 5px;
label {
margin-left: 10px;
}
}
&-delete {
margin-top: 15px;
}
&-addResponse {
margin-bottom: 15px;
margin-top: 15px;
}
}
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DiscussionDialogComponent } from './discussion-dialog.component';
describe('DiscussionDialogComponent', () => {
let component: DiscussionDialogComponent;
let fixture: ComponentFixture<DiscussionDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DiscussionDialogComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(DiscussionDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
import { TranslateService } from '@ngx-translate/core';
import { Discussion } from 'src/app/class/discussion/discussion';
import { Response } from 'src/app/class/response/response';
import { Role } from 'src/app/class/role/role';
import { DeclarativeSentence } from 'src/app/class/sentence/declarativeSentence/declarative-sentence';
import { InterrogativeSentence } from 'src/app/class/sentence/interrogativeSentence/interrogative-sentence';
import { Sentence } from 'src/app/class/sentence/sentence';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from '../suppress-dialog/suppress-dialog.component';
@Component({
selector: 'app-discussion-dialog',
templateUrl: './discussion-dialog.component.html',
styleUrls: ['./discussion-dialog.component.scss']
})
export class DiscussionDialogComponent implements OnInit {
role: Role;
discussion: Discussion;
constructor(public dialogRef: MatDialogRef<DiscussionDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: DialogDiscussionData, protected translate: TranslateService, protected tooltipService: TooltipService, public dialog: MatDialog) {
this.role = this.data.role;
this.discussion = this.data.discussion;
}
ngOnInit(): void {
}
isDeclarativeSentence(sentence: Sentence): boolean {
return sentence instanceof DeclarativeSentence;
}
isInterrogativeSentence(sentence: Sentence): boolean {
return sentence instanceof InterrogativeSentence;
}
getSentenceAsDeclarativeSentence(sentence: Sentence): DeclarativeSentence {
return sentence as DeclarativeSentence;
}
getSentenceAsInterrogativeSentence(sentence: Sentence): InterrogativeSentence {
return sentence as InterrogativeSentence;
}
onCheckFirstSentence(event: any, sentenceId: number) {
if (event.target.checked) {
this.discussion.firstSentenceID = sentenceId;
} else {
this.discussion.firstSentenceID = -1;
}
}
isSelectableAsFirstDiscussion(): boolean {
let res: boolean = true;
this.role.discussions.forEach(discussion => {
if (discussion.character == this.discussion.character && discussion.ID != this.discussion.ID && discussion.isFirstDiscussion) {
res = false;
}
});
return res;
}
addDeclarativeSentence() {
let newSentence: DeclarativeSentence = new DeclarativeSentence(this.role.actualSentenceID++);
newSentence.idDiscussion = this.discussion.ID;
this.discussion.sentences.push(newSentence.ID);
this.role.sentences.push(newSentence);
}
deleteDeclarativeSentence(removedSentenceId: number) {
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: this.translate.instant('discussion_declarativeSentence_delete') });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
this.role.sentences.forEach((sentence, index) => {
if (sentence.ID == removedSentenceId) {
this.role.sentences.splice(index,1);
}
if (sentence instanceof DeclarativeSentence) {
if (sentence.nextSentence == removedSentenceId) {
//resetNextSentence
sentence.nextSentence = -1;
}
}
if (sentence instanceof InterrogativeSentence) {
this.role.responses.forEach(response => {
if (response.nextSentence == removedSentenceId) {
//resetNextSentence
response.nextSentence = -1;
}
});
}
});
}
});
}
addInterrogativeSentence() {
let newSentence: InterrogativeSentence = new InterrogativeSentence(this.role.actualSentenceID++);
newSentence.idDiscussion = this.discussion.ID;
let newResponse: Response = new Response(this.role.actualResponseID++);
newResponse.idInterrogativeSentence = newSentence.ID;
newSentence.responses.push(newResponse.ID);
this.role.responses.push(newResponse);
this.discussion.sentences.push(newSentence.ID);
this.role.sentences.push(newSentence);
}
deleteInterrogativeSentence(removedSentenceId: number) {
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: this.translate.instant('discussion_interrogativeSentence_delete') });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
for (let sentenceIndex: number = 0; sentenceIndex < this.role.sentences.length; sentenceIndex++) {
let sentence: Sentence = this.role.sentences[sentenceIndex];
if (sentence instanceof DeclarativeSentence && sentence.nextSentence == removedSentenceId) {
sentence.nextSentence = -1;
}
if (sentence instanceof InterrogativeSentence) {
if (sentence.ID == removedSentenceId) {
for (let responseIndex: number = 0; responseIndex < this.role.responses.length; responseIndex++) {
let response: Response = this.role.responses[responseIndex];
if (response.idInterrogativeSentence == removedSentenceId) {
this.role.responses.splice(responseIndex,1);
responseIndex--;
}
}
this.role.sentences.splice(sentenceIndex,1);
sentenceIndex--;
} else {
for (let responseIndex: number = 0; responseIndex < this.role.responses.length; responseIndex++) {
let response: Response = this.role.responses[responseIndex];
if (response.nextSentence == removedSentenceId) {
response.nextSentence = -1;
}
}
}
}
}
}
});
}
addResponse(sentence: InterrogativeSentence) {
let newResponse: Response = new Response(this.role.actualResponseID++);
newResponse.idInterrogativeSentence = sentence.ID;
sentence.responses.push(newResponse.ID);
this.role.responses.push(newResponse);
}
countResponses(sentenceId: number): number {
let cpt: number = 0;
this.role.responses.forEach(response => {
if (response.idInterrogativeSentence == sentenceId) {
cpt++;
}
});
return cpt;
}
deleteResponse(sentence: InterrogativeSentence, removedResponseId: number) {
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: this.translate.instant('discussion_response_delete') });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
let sentenceResponseIndex = sentence.responses.findIndex(response => response == removedResponseId);
sentence.responses.splice(sentenceResponseIndex,1);
let responseIndex = this.role.responses.findIndex(response => response.ID == removedResponseId);
this.role.responses.splice(responseIndex,1);
}
});
}
}
export interface DialogDiscussionData {
role: Role;
discussion: Discussion;
}
<div class="piece"
[matTooltip]="translate.instant('discussions_tooltip')"
matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<div class="piece-form">
<div class="piece-form-title">{{'discussions_title' | translate}}</div>
<div class="piece-form-element">
<div class="piece-form-title">{{'discussions_selectCharacter_title' | translate}}</div>
<div class="piece-form-name"
[matTooltip]="translate.instant('discussions_selectCharacter_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<label for="name">{{'discussions_selectCharacter_label' | translate}}</label>
<select name="name" [(ngModel)]="selectedCharacter">
<option [ngValue]="" disabled selected>{{'discussions_selectCharacter_placeholder' | translate}}</option>
<option *ngFor="let character of scenario.characters" [ngValue]="character">{{character.name}}</option>
</select>
</div>
</div>
<div class="piece-form-element">
<div class="piece-form-title">{{'discussions_addDiscussion_title' | translate}}</div>
<div class="piece-form-newDiscussion"
[matTooltip]="translate.instant('discussions_addDiscussion_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<label for="intitule">{{'discussions_addDiscussion_label' | translate}}</label>
<input name="intitule" type="text" [(ngModel)]="intitule"/>
</div>
<button mat-button class="piece-form-button-create" (click)="addDiscussion()">{{'discussions_addDiscussion_button' | translate}}</button>
</div>
<div class="piece-form-element">
<div class="piece-form-title">{{'discussions_editDiscussion_title' | translate}}</div>
<div class="piece-form-discussions">
<ng-container *ngFor="let discussion of role.discussions, let discussionIndex = index">
<div class="piece-form-discussions-element" *ngIf="discussion.character == selectedCharacter">
<button mat-button class="piece-form-discussions-element-discussion" (click)="openDiscussion(discussion)"
[matTooltip]="translate.instant('discussions_editDiscussion_discussion_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<mat-icon fontIcon="looks_one" *ngIf="discussion.isFirstDiscussion"
[matTooltip]="translate.instant('discussion_firstDiscussion_label')"
matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedTooltips"></mat-icon> {{discussion.name}}
</button>
<button mat-button class="piece-form-discussions-element-remove"
[matTooltip]="translate.instant('discussions_editDiscussion_remove_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<mat-icon fontIcon="remove" (click)="deleteDiscussion(discussionIndex)"></mat-icon>
</button>
</div>
</ng-container>
</div>
</div>
</div>
</div>
\ No newline at end of file
.piece {
--piece-background-color: #d5d5ff;
width: 300px;
position: relative;
background-color: var(--piece-background-color);
border: solid #707070 1px;
border-radius: 6px;
button {
border-radius: 10px;
background-color: white;
margin-top: 5px;
}
label {
margin-right: 10px;
}
input {
border: none;
border-radius: 10px;
height: 20px;
padding: 5px 5px 5px 5px;
}
select {
border-radius: 10px;
background-color: white;
border: none;
padding: 5px 10px 5px 10px;
}
&-form {
margin: 10px 5px 10px 5px;
display: flex;
flex-direction: column;
&-title {
font-family: "Glacial Indifference Bold";
margin-bottom: 10px;
}
&-element {
margin-top: 10px;
}
&-name, &-newDiscussion {
display: flex;
justify-content: space-between;
select {
width: 75%;
}
input {
width: 71%;
}
}
&-discussions {
display: flex;
flex-direction: column;
&-element {
width: 100%;
display: flex;
margin-left: auto;
margin-right: auto;
justify-content: center;
&-discussion {
width: 70%;
margin-right: 5px;
}
}
}
&-button {
&-create {
position: relative;
left: 100%;
transform: translateX(-100%);
}
}
}
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DiscussionsComponent } from './discussions.component';
describe('DiscussionsComponent', () => {
let component: DiscussionsComponent;
let fixture: ComponentFixture<DiscussionsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DiscussionsComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(DiscussionsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { TranslateService } from '@ngx-translate/core';
import { Character } from 'src/app/class/character/character';
import { Discussion } from 'src/app/class/discussion/discussion';
import { Response } from 'src/app/class/response/response';
import { Role } from 'src/app/class/role/role';
import { Scenario } from 'src/app/class/scenario/scenario';
import { DeclarativeSentence } from 'src/app/class/sentence/declarativeSentence/declarative-sentence';
import { InterrogativeSentence } from 'src/app/class/sentence/interrogativeSentence/interrogative-sentence';
import { Sentence } from 'src/app/class/sentence/sentence';
import { DiscussionDialogComponent } from 'src/app/components/dialogs/discussion-dialog/discussion-dialog.component';
import { SuppressDialogComponent } from 'src/app/components/dialogs/suppress-dialog/suppress-dialog.component';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
@Component({
selector: 'app-discussions',
templateUrl: './discussions.component.html',
styleUrls: ['./discussions.component.scss']
})
export class DiscussionsComponent implements OnInit {
selectedCharacter: Character | null = null;
intitule: string = '';
constructor(protected tooltipService: TooltipService, private pieceDetailsService: PieceDetailsService, protected translate: TranslateService, public dialog: MatDialog) { }
@Input() scenario: Scenario = new Scenario();
@Input() role: Role = new Role();
ngOnInit(): void {
}
addDiscussion() {
if (this.selectedCharacter && this.intitule) {
let discussion = new Discussion(this.role.actualDiscussionID++, this.selectedCharacter, this.intitule);
this.intitule = '';
this.role.discussions.push(discussion);
const dialogRef = this.dialog.open(DiscussionDialogComponent, {
width: '60vw',
data: { role: this.role, discussion: discussion }
});
}
}
openDiscussion(discussion: Discussion) {
const dialogRef = this.dialog.open(DiscussionDialogComponent, {
width: '60vw',
data: { role: this.role, discussion: discussion }
});
}
deleteDiscussion(discussionIndex: number) {
const dialogRef = this.dialog.open(SuppressDialogComponent, { data: this.translate.instant('discussion_delete') });
dialogRef.afterClosed().subscribe(result => {
if (result == true) {
let discussion: Discussion = this.role.discussions[discussionIndex];
for (let sentenceIndex: number = 0; sentenceIndex < this.role.sentences.length; sentenceIndex++) {
let sentence: Sentence = this.role.sentences[sentenceIndex];
if (discussion.ID == sentence.idDiscussion) {
if (sentence instanceof InterrogativeSentence) {
for (let responseIndex: number = 0; responseIndex < this.role.responses.length; responseIndex++) {
let response: Response = this.role.responses[responseIndex];
if (response.idInterrogativeSentence == sentence.ID) {
this.role.responses.splice(responseIndex,1);
responseIndex--;
}
}
}
this.role.sentences.splice(sentenceIndex,1);
sentenceIndex--;
}
}
this.role.discussions.splice(discussionIndex,1);
}
});
}
}
......@@ -407,5 +407,45 @@
"rewards_name_label": "Name",
"rewards_object_placeholder": "Name of the object",
"rewards_character_placeholder": "Character",
"rewards_skill_placeholder": "Skill"
"rewards_skill_placeholder": "Skill",
"discussions_title": "Discussions",
"discussions_tooltip": "Allows managing discussions between the role and characters",
"discussions_selectCharacter_title": "Select the character",
"discussions_selectCharacter_label": "Name",
"discussions_selectCharacter_placeholder": "Character name",
"discussions_selectCharacter_tooltip": "Specify the name of the character with whom the role will interact",
"discussions_addDiscussion_title": "Add a new discussion",
"discussions_addDiscussion_label": "Title",
"discussions_addDiscussion_tooltip": "Title of the new discussion",
"discussions_addDiscussion_button": "Add",
"discussions_editDiscussion_title": "Edit discussions",
"discussions_editDiscussion_discussion_tooltip": "Click to edit this discussion",
"discussions_editDiscussion_remove_tooltip": "Delete the discussion",
"discussion_title": "Discussion",
"discussion_name_label": "Discussion Name:",
"discussion_firstDiscussion_label": "First discussion",
"discussion_firstDiscussion_tooltip": "A first discussion is already selected for this character, you must uncheck it first to select a new one",
"discussion_firstSentence_label": "First sentence",
"discussion_firstSentence_tooltip": "A first sentence is already selected for this discussion, you must uncheck it first to select a new one",
"discussion_declarativeSentence": "Sentence",
"discussion_interrogativeSentence": "Question",
"discussion_response": "Response",
"discussion_result_label": "Result",
"discussion_result_placeholder": "Select a result",
"discussion_nextSentence_label": "Next sentence",
"discussion_nextSentence_placeholder": "Select the next sentence",
"discussion_buttons_newDeclarativeSentence": "Add a sentence",
"discussion_buttons_newInterrogativeSentence": "Add a question",
"discussion_buttons_deleteDeclarativeSentence": "Delete the sentence",
"discussion_buttons_deleteInterrogativeSentence": "Delete the question",
"discussion_buttons_newResponse": "Add a response",
"discussion_buttons_deleteResponse": "Delete the response",
"discussion_buttons_close": "Close",
"discussion_delete": "this Discussion",
"discussion_declarativeSentence_delete": "this Sentence",
"discussion_interrogativeSentence_delete": "this Question",
"discussion_response_delete": "this Response"
}
\ No newline at end of file
......@@ -407,5 +407,44 @@
"rewards_name_label": "Nom",
"rewards_object_placeholder": "Nom de l'objet",
"rewards_character_placeholder": "Personnage",
"rewards_skill_placeholder": "Compétence"
"rewards_skill_placeholder": "Compétence",
"discussions_title": "Discussions",
"discussions_tooltip": "Permet de gérer les discussions entre le rôle et les personnages",
"discussions_selectCharacter_title": "Sélectionner le personnage",
"discussions_selectCharacter_label": "Nom",
"discussions_selectCharacter_placeholder": "Nom du personnage",
"discussions_selectCharacter_tooltip": "Indiquez le nom du personnage avec lequel le rôle va interagir",
"discussions_addDiscussion_title": "Ajouter une nouvelle discussion",
"discussions_addDiscussion_label": "Intitulé",
"discussions_addDiscussion_tooltip": "Titre de la nouvelle discussion",
"discussions_addDiscussion_button": "Ajouter",
"discussions_editDiscussion_title": "Éditer les discussions",
"discussions_editDiscussion_discussion_tooltip": "Cliquez pour éditer cette discussion",
"discussions_editDiscussion_remove_tooltip": "Supprimer la discussion",
"discussion_title": "Discussion",
"discussion_name_label": "Nom de la discussion :",
"discussion_firstDiscussion_label": "Première discussion",
"discussion_firstDiscussion_tooltip": "Une première discussion est déjà choisie pour ce personnage, il vous faut d'abord la décocher pour en sélectionner une nouvelle",
"discussion_firstSentence_label": "Première phrase",
"discussion_firstSentence_tooltip": "Une première phrase est déjà choisie pour cette discussion, il vous faut d'abord la décocher pour en sélectionner une nouvelle",
"discussion_declarativeSentence": "Phrase",
"discussion_interrogativeSentence": "Question",
"discussion_response": "Réponse",
"discussion_result_label": "Résultat",
"discussion_result_placeholder": "Choisir un résultat",
"discussion_nextSentence_label": "Phrase suivante",
"discussion_nextSentence_placeholder": "Choisir la phrase suivante",
"discussion_buttons_newDeclarativeSentence": "Ajouter une phrase",
"discussion_buttons_newInterrogativeSentence": "Ajouter une question",
"discussion_buttons_deleteDeclarativeSentence": "Supprimer la phrase",
"discussion_buttons_deleteInterrogativeSentence": "Supprimer la question",
"discussion_buttons_newResponse": "Ajouter une réponse",
"discussion_buttons_deleteResponse": "Supprimer la réponse",
"discussion_buttons_close": "Fermer",
"discussion_delete": "cette Discussion",
"discussion_declarativeSentence_delete": "cette Phrase",
"discussion_interrogativeSentence_delete": "cette Question",
"discussion_response_delete": "cette Réponse"
}
\ No newline at end of file
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