From 43ee7f2fcebaac223097de5afa2bea7ef8fc6d26 Mon Sep 17 00:00:00 2001 From: Lukas Haase <lukas.haase@mni.thm.de> Date: Fri, 10 Jul 2020 14:12:18 +0200 Subject: [PATCH] user can delete their questions --- .../shared/comment-list/comment-list.component.html | 13 +++++++++---- .../shared/comment/comment.component.html | 3 ++- .../components/shared/comment/comment.component.ts | 2 ++ src/assets/i18n/participant/de.json | 13 ++++++++++--- src/assets/i18n/participant/en.json | 13 ++++++++++--- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/app/components/shared/comment-list/comment-list.component.html b/src/app/components/shared/comment-list/comment-list.component.html index 17a1deb18..1adaeb9a1 100644 --- a/src/app/components/shared/comment-list/comment-list.component.html +++ b/src/app/components/shared/comment-list/comment-list.component.html @@ -148,10 +148,15 @@ </div> <div *ngIf="!isLoading"> - <app-comment *ngFor="let current of hideCommentsList ? filteredComments : comments" [comment]="current" - [parseVote]="getVote(current)" [userRole]="userRole" [moderator]="false" - (clickedOnTag)="clickedOnTag($event)" (clickedUserNumber)="clickedUserNumber($event)"> - </app-comment> + <app-comment *ngFor="let current of hideCommentsList ? filteredComments : comments" + [comment]="current" + [parseVote]="getVote(current)" + [userRole]="userRole" + [moderator]="false" + [user]="user" + (clickedOnTag)="clickedOnTag($event)" + (clickedUserNumber)="clickedUserNumber($event)"> + </app-comment> </div> <!-- No Questions Present --> <div *ngIf="comments && comments.length < 1 && !isLoading" fxLayout="row" fxLayoutAlign="center center" diff --git a/src/app/components/shared/comment/comment.component.html b/src/app/components/shared/comment/comment.component.html index 7718edf87..5dbdc15ff 100644 --- a/src/app/components/shared/comment/comment.component.html +++ b/src/app/components/shared/comment/comment.component.html @@ -52,7 +52,8 @@ : ('comment-page.mark-not-favorite' | translate)">grade </mat-icon> </button> - <button mat-icon-button *ngIf="isCreator && !comment.favorite && !inAnswerView" (click)="openDeleteCommentDialog()" + <button mat-icon-button + *ngIf="(isCreator || comment.creatorId === user.id) && !comment.favorite && !inAnswerView" (click)="openDeleteCommentDialog()" tabindex="0" attr.aria-labelledby="comment_delete{{ comment.id }}"> <mat-icon class="not-marked" matTooltip="{{ 'comment-page.delete' | translate }}">delete </mat-icon> diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index 40af32129..ca7f9526f 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -17,6 +17,7 @@ import { CorrectWrong } from '../../../models/correct-wrong.enum'; import { UserRole } from '../../../models/user-roles.enum'; import { Rescale } from '../../../models/rescale'; import { RowComponent } from '../../../../../projects/ars/src/lib/components/layout/frame/row/row.component'; +import { User } from '../../../models/user'; @Component({ selector: 'app-comment', @@ -38,6 +39,7 @@ export class CommentComponent implements OnInit, AfterViewInit { @Input() comment: Comment; @Input() moderator: boolean; @Input() userRole: UserRole; + @Input() user: User; @Output() clickedOnTag = new EventEmitter<string>(); @Output() clickedUserNumber = new EventEmitter<number>(); isStudent = false; diff --git a/src/assets/i18n/participant/de.json b/src/assets/i18n/participant/de.json index 2890ebe50..dda0337cc 100644 --- a/src/assets/i18n/participant/de.json +++ b/src/assets/i18n/participant/de.json @@ -57,7 +57,12 @@ "unread": "Nicht im Hörsaal besprochen", "vote-asc": "Aufsteigende Bewertungen", "vote-desc": "Absteigende Bewertungen", - "wrong": "Verneint" + "wrong": "Verneint", + "really-delete": "Willst du die Frage wirklich löschen?" + }, + "content": { + "cancel": "Abbrechen", + "delete": "Löschen" }, "comment-page": { "a11y-comment_input": "Gib deine Frage ein", @@ -99,7 +104,8 @@ "write-comment": "Schreiben", "preview-comment": "Vorschau", "show-more": "mehr ansehen", - "show-less": "weniger anzeigen" + "show-less": "weniger anzeigen", + "sure": "Bist du sicher?" }, "home-page": { @@ -121,7 +127,8 @@ "live-feedback": "Live Feedback", "session-id": "Code", "bonus-token": "Tokens für Bonuspunkte", - "bonus-token-header": "Tokens für Bonuspunkte" + "bonus-token-header": "Tokens für Bonuspunkte", + "delete": "Frage löschen" }, "question-wall": { "next-comment": "Nächste Frage", diff --git a/src/assets/i18n/participant/en.json b/src/assets/i18n/participant/en.json index b4c9015d7..2362558c4 100644 --- a/src/assets/i18n/participant/en.json +++ b/src/assets/i18n/participant/en.json @@ -57,7 +57,12 @@ "unread": "Not yet discussed", "vote-desc": "Descending votes", "vote-asc": "Ascending votes", - "wrong": "Marked as wrong by the professor" + "wrong": "Marked as wrong by the professor", + "really-delete": "Do you really want to delete this question?" + }, + "content": { + "cancel": "Cancel", + "delete": "Delete" }, "comment-page": { "a11y-comment_input": "Enter your question", @@ -99,7 +104,8 @@ "write-comment": "Write", "preview-comment": "Preview", "show-more": "show more", - "show-less": "show less" + "show-less": "show less", + "delete": "Delete question" }, "home-page": { "exactly-8": "A session key is a combination of exactly 8 digits.", @@ -120,7 +126,8 @@ "live-feedback": "Live feedback", "session-id": "Key", "bonus-token": "Tokens for bonus points", - "bonus-token-header": "Tokens for bonus points" + "bonus-token-header": "Tokens for bonus points", + "sure": "Are you sure?" }, "question-wall": { "next-comment": "Next question", -- GitLab