Skip to content
Snippets Groups Projects
Commit 110532d4 authored by Ruben Bimberg's avatar Ruben Bimberg :computer:
Browse files

Implement questioner name

parent 023b7d9c
Branches
Tags
No related merge requests found
Showing
with 95 additions and 11 deletions
...@@ -26,3 +26,7 @@ ...@@ -26,3 +26,7 @@
[cancelButtonClickAction]="buildCloseDialogActionCallback()" [cancelButtonClickAction]="buildCloseDialogActionCallback()"
[confirmButtonClickAction]="buildConfirmDialogActionCallback()" [confirmButtonClickAction]="buildConfirmDialogActionCallback()"
></app-dialog-action-buttons> ></app-dialog-action-buttons>
<div class="visually-hidden">
<div id="room-name">{{ 'room-page.a11y-room-name' | translate }}</div>
</div>
<ars-row ars-flex-box> <ars-row ars-flex-box>
<app-write-comment [confirmLabel]="'send'" <app-write-comment [confirmLabel]="'send'"
[isQuestionerNameEnabled]="true"
[onSubmit]="this.closeDialog.bind(this)" [onSubmit]="this.closeDialog.bind(this)"
[onClose]="this.onNoClick.bind(this)" [onClose]="this.onNoClick.bind(this)"
[isSpinning]="isSendingToSpacy" [isSpinning]="isSendingToSpacy"
......
...@@ -43,13 +43,14 @@ export class CreateCommentComponent implements OnInit { ...@@ -43,13 +43,14 @@ export class CreateCommentComponent implements OnInit {
this.dialogRef.close(); this.dialogRef.close();
} }
closeDialog(body: string, text: string, tag: string) { closeDialog(body: string, text: string, tag: string, name: string) {
const comment = new Comment(); const comment = new Comment();
comment.roomId = localStorage.getItem(`roomId`); comment.roomId = localStorage.getItem(`roomId`);
comment.body = body; comment.body = body;
comment.creatorId = this.user.id; comment.creatorId = this.user.id;
comment.createdFromLecturer = this.user.role > 0; comment.createdFromLecturer = this.user.role > 0;
comment.tag = tag; comment.tag = tag;
comment.questionerName = name;
this.isSendingToSpacy = true; this.isSendingToSpacy = true;
this.openSpacyDialog(comment, text); this.openSpacyDialog(comment, text);
} }
......
...@@ -376,6 +376,15 @@ ...@@ -376,6 +376,15 @@
</div> </div>
<span class="fill-remaining-space"></span> <span class="fill-remaining-space"></span>
<div fxLayoutAlign="center center"
matTooltip="{{ 'comment-page.questioner-name' | translate }}"
*ngIf="comment.questionerName"
class="comment-tags">
<mat-icon>account_circle</mat-icon>
<span>
{{comment.questionerName}}
</span>
</div>
<button mat-icon-button <button mat-icon-button
class="moderate-button" class="moderate-button"
*ngIf="(isCreator || isModerator) && !inAnswerView" *ngIf="(isCreator || isModerator) && !inAnswerView"
......
...@@ -50,7 +50,23 @@ ...@@ -50,7 +50,23 @@
[isEditor]="true" [isEditor]="true"
[maxTextCharacters]="maxTextCharacters" [maxTextCharacters]="maxTextCharacters"
[maxDataCharacters]="maxDataCharacters" [maxDataCharacters]="maxDataCharacters"
[placeHolderText]="placeholder"></app-view-comment-data> [placeHolderText]="placeholder">
</app-view-comment-data>
<mat-form-field class="questioner-name-input" *ngIf="isQuestionerNameEnabled && enabled">
<input (focus)="eventService.makeFocusOnInputTrue()"
(blur)="eventService.makeFocusOnInputFalse()"
matInput
[formControl]="questionerNameFormControl"
name="questioner-name"
maxlength="20"
aria-labelledby="questioner-name"/>
<mat-placeholder class="placeholder">{{ 'write-comment.questioner-name' | translate }}</mat-placeholder>
<mat-hint align="end"><span aria-hidden="true">{{ questionerNameFormControl.value.length }} / 20</span></mat-hint>
<mat-error *ngIf="questionerNameFormControl.hasError('minlength') ||
questionerNameFormControl.hasError('maxlength')">
{{ 'write-comment.name-length-error' | translate }}
</mat-error>
</mat-form-field>
<ars-row ars-flex-box *ngIf="enabled" class="spellcheck"> <ars-row ars-flex-box *ngIf="enabled" class="spellcheck">
<ars-col> <ars-col>
<button <button
...@@ -77,3 +93,7 @@ ...@@ -77,3 +93,7 @@
></app-dialog-action-buttons> ></app-dialog-action-buttons>
</ars-col> </ars-col>
</ars-row> </ars-row>
<div class="visually-hidden">
<div id="questioner-name">{{ 'write-comment.a11y-questioner-name' | translate }}</div>
</div>
.questioner-name-input {
width: 100%;
max-width: 260px;
margin-top: -5px;
@media screen and (max-width: 500px) {
max-width: unset;
}
}
button { button {
min-width: 80px; min-width: 80px;
} }
......
...@@ -9,6 +9,7 @@ import { ViewCommentDataComponent } from '../view-comment-data/view-comment-data ...@@ -9,6 +9,7 @@ import { ViewCommentDataComponent } from '../view-comment-data/view-comment-data
import { DeepLService, SourceLang, TargetLang } from '../../../services/http/deep-l.service'; import { DeepLService, SourceLang, TargetLang } from '../../../services/http/deep-l.service';
import { DeepLDialogComponent } from '../_dialogs/deep-ldialog/deep-ldialog.component'; import { DeepLDialogComponent } from '../_dialogs/deep-ldialog/deep-ldialog.component';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { FormControl, Validators } from '@angular/forms';
@Component({ @Component({
selector: 'app-write-comment', selector: 'app-write-comment',
...@@ -22,7 +23,7 @@ export class WriteCommentComponent implements OnInit { ...@@ -22,7 +23,7 @@ export class WriteCommentComponent implements OnInit {
@Input() isModerator = false; @Input() isModerator = false;
@Input() tags: string[]; @Input() tags: string[];
@Input() onClose: () => any; @Input() onClose: () => any;
@Input() onSubmit: (commentData: string, commentText: string, selectedTag: string) => any; @Input() onSubmit: (commentData: string, commentText: string, selectedTag: string, name?: string) => any;
@Input() isSpinning = false; @Input() isSpinning = false;
@Input() disableCancelButton = false; @Input() disableCancelButton = false;
@Input() confirmLabel = 'save'; @Input() confirmLabel = 'save';
...@@ -32,6 +33,7 @@ export class WriteCommentComponent implements OnInit { ...@@ -32,6 +33,7 @@ export class WriteCommentComponent implements OnInit {
@Input() isCommentAnswer = false; @Input() isCommentAnswer = false;
@Input() placeholder = 'comment-page.enter-comment'; @Input() placeholder = 'comment-page.enter-comment';
@Input() i18nSection = 'comment-page'; @Input() i18nSection = 'comment-page';
@Input() isQuestionerNameEnabled = false;
comment: Comment; comment: Comment;
selectedTag: string; selectedTag: string;
maxTextCharacters = 500; maxTextCharacters = 500;
...@@ -42,6 +44,9 @@ export class WriteCommentComponent implements OnInit { ...@@ -42,6 +44,9 @@ export class WriteCommentComponent implements OnInit {
isSpellchecking = false; isSpellchecking = false;
hasSpellcheckConfidence = true; hasSpellcheckConfidence = true;
newLang = 'auto'; newLang = 'auto';
questionerNameFormControl = new FormControl('', [
Validators.minLength(2), Validators.maxLength(20)
]);
constructor(private notification: NotificationService, constructor(private notification: NotificationService,
private languageService: LanguageService, private languageService: LanguageService,
...@@ -77,9 +82,15 @@ export class WriteCommentComponent implements OnInit { ...@@ -77,9 +82,15 @@ export class WriteCommentComponent implements OnInit {
return undefined; return undefined;
} }
return () => { return () => {
let allowed = true;
if (this.isQuestionerNameEnabled) {
this.questionerNameFormControl.setValue((this.questionerNameFormControl.value || '').trim());
allowed = !this.questionerNameFormControl.hasError('minlength') &&
!this.questionerNameFormControl.hasError('maxlength');
}
if (ViewCommentDataComponent.checkInputData(this.commentData.currentData, this.commentData.currentText, if (ViewCommentDataComponent.checkInputData(this.commentData.currentData, this.commentData.currentText,
this.translateService, this.notification, this.maxTextCharacters, this.maxDataCharacters)) { this.translateService, this.notification, this.maxTextCharacters, this.maxDataCharacters) && allowed) {
this.onSubmit(this.commentData.currentData, this.commentData.currentText, this.selectedTag); this.onSubmit(this.commentData.currentData, this.commentData.currentText, this.selectedTag, this.questionerNameFormControl.value);
} }
}; };
} }
......
...@@ -26,6 +26,7 @@ export class Comment { ...@@ -26,6 +26,7 @@ export class Comment {
upvotes: number; upvotes: number;
downvotes: number; downvotes: number;
language: Language; language: Language;
questionerName: string;
createdBy; createdBy;
constructor(roomId: string = '', constructor(roomId: string = '',
...@@ -48,6 +49,7 @@ export class Comment { ...@@ -48,6 +49,7 @@ export class Comment {
upvotes = 0, upvotes = 0,
downvotes = 0, downvotes = 0,
language = Language.auto, language = Language.auto,
questionerName: string = null,
createdBy?: any) { createdBy?: any) {
this.id = ''; this.id = '';
this.roomId = roomId; this.roomId = roomId;
...@@ -72,6 +74,7 @@ export class Comment { ...@@ -72,6 +74,7 @@ export class Comment {
this.downvotes = downvotes; this.downvotes = downvotes;
this.language = language; this.language = language;
this.createdBy = createdBy; this.createdBy = createdBy;
this.questionerName = questionerName;
} }
static mapModelToLanguage(model: Model): Language { static mapModelToLanguage(model: Model): Language {
......
...@@ -184,11 +184,11 @@ export class RoomDataService { ...@@ -184,11 +184,11 @@ export class RoomDataService {
} }
getUnFilteredBody(id: string): string { getUnFilteredBody(id: string): string {
return this._savedCommentsBeforeFilter.get(id)[0]; return this._savedCommentsBeforeFilter.get(id).body;
} }
getFilteredBody(id: string): string { getFilteredBody(id: string): string {
return this._savedCommentsAfterFilter.get(id)[0]; return this._savedCommentsAfterFilter.get(id).body;
} }
getCensoredInformation(comment: Comment): CommentFilterData { getCensoredInformation(comment: Comment): CommentFilterData {
...@@ -314,6 +314,7 @@ export class RoomDataService { ...@@ -314,6 +314,7 @@ export class RoomDataService {
c.userNumber = this.commentService.hashCode(c.creatorId); c.userNumber = this.commentService.hashCode(c.creatorId);
c.keywordsFromQuestioner = JSON.parse(payload.keywordsFromQuestioner); c.keywordsFromQuestioner = JSON.parse(payload.keywordsFromQuestioner);
c.language = payload.language; c.language = payload.language;
c.questionerName = payload.questionerName;
this._fastCommentAccess[c.id] = c; this._fastCommentAccess[c.id] = c;
this._currentComments.push(c); this._currentComments.push(c);
this.triggerUpdate(UpdateType.commentStream, { this.triggerUpdate(UpdateType.commentStream, {
......
...@@ -195,7 +195,8 @@ ...@@ -195,7 +195,8 @@
"show-comment-with-filter": "Vulgäre Wörter ausixen", "show-comment-with-filter": "Vulgäre Wörter ausixen",
"show-comment-without-filter": "Vulgäre Wörter anzeigen", "show-comment-without-filter": "Vulgäre Wörter anzeigen",
"upvote": "positiv:", "upvote": "positiv:",
"downvote": "negativ:" "downvote": "negativ:",
"questioner-name": "Name des Fragenstellers"
}, },
"content": { "content": {
"abort": "Abbrechen", "abort": "Abbrechen",
...@@ -591,5 +592,10 @@ ...@@ -591,5 +592,10 @@
"bad-spelled" : "Zu schlechte Rechtschreibung", "bad-spelled" : "Zu schlechte Rechtschreibung",
"failed" : "Fehler aufgetreten", "failed" : "Fehler aufgetreten",
"inline-header": "Laufende Stichwort-Aktualisierungen" "inline-header": "Laufende Stichwort-Aktualisierungen"
},
"write-comment": {
"questioner-name": "Dein Name, wenn du willst ...",
"a11y-questioner-name": "Hier kannst du, wenn du willst, deinen Namen eingeben. Dieser ist für alle an diesem Kommentar sichtbar.",
"name-length-error": "Der Name muss zwischen 2 und 20 Zeichen lang sein."
} }
} }
...@@ -196,7 +196,8 @@ ...@@ -196,7 +196,8 @@
"show-comment-with-filter": "Hide vulgar words", "show-comment-with-filter": "Hide vulgar words",
"show-comment-without-filter": "Show vulgar words", "show-comment-without-filter": "Show vulgar words",
"upvote": "upvotes:", "upvote": "upvotes:",
"downvote": "downvotes:" "downvote": "downvotes:",
"questioner-name": "Name of the questioner"
}, },
"content": { "content": {
"abort": "Abort", "abort": "Abort",
...@@ -589,5 +590,10 @@ ...@@ -589,5 +590,10 @@
"bad-spelled": "Spelling too bad", "bad-spelled": "Spelling too bad",
"failed": "Error occurred", "failed": "Error occurred",
"inline-header": "Ongoing keyword updates" "inline-header": "Ongoing keyword updates"
},
"write-comment": {
"questioner-name": "Your name, if you want ...",
"a11y-questioner-name": "Here you can enter your name if you want. This is visible for everyone at this comment.",
"name-length-error": "The name must be between 2 and 20 characters."
} }
} }
...@@ -162,7 +162,8 @@ ...@@ -162,7 +162,8 @@
"sure": "Bist du sicher?", "sure": "Bist du sicher?",
"grammar-check": "Text prüfen", "grammar-check": "Text prüfen",
"upvote": "positiv:", "upvote": "positiv:",
"downvote": "negativ:" "downvote": "negativ:",
"questioner-name": "Name des Fragenstellers"
}, },
"deepl": { "deepl": {
"header": "Text prüfen", "header": "Text prüfen",
...@@ -473,5 +474,10 @@ ...@@ -473,5 +474,10 @@
"cancel": "Schließen", "cancel": "Schließen",
"cancel-description": "Schließe die Einführung und gehe zurück zur Anmeldung.", "cancel-description": "Schließe die Einführung und gehe zurück zur Anmeldung.",
"title": "Einführung" "title": "Einführung"
},
"write-comment": {
"questioner-name": "Dein Name, wenn du willst ...",
"a11y-questioner-name": "Hier kannst du, wenn du willst, deinen Namen eingeben. Dieser ist für alle an diesem Kommentar sichtbar.",
"name-length-error": "Der Name muss zwischen 2 und 20 Zeichen lang sein."
} }
} }
...@@ -171,7 +171,8 @@ ...@@ -171,7 +171,8 @@
"delete": "Delete question", "delete": "Delete question",
"grammar-check": "Check text", "grammar-check": "Check text",
"upvote": "upvotes:", "upvote": "upvotes:",
"downvote": "downvotes:" "downvote": "downvotes:",
"questioner-name": "Name of the questioner"
}, },
"deepl": { "deepl": {
"header": "Check text", "header": "Check text",
...@@ -479,5 +480,10 @@ ...@@ -479,5 +480,10 @@
"cancel": "Close", "cancel": "Close",
"cancel-description": "Close introduction.", "cancel-description": "Close introduction.",
"title": "Introduction" "title": "Introduction"
},
"write-comment": {
"questioner-name": "Your name, if you want ...",
"a11y-questioner-name": "Here you can enter your name if you want. This is visible for everyone at this comment.",
"name-length-error": "The name must be between 2 and 20 characters."
} }
} }
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