From c9b538ec9d9855e7255ac5042afb1d3d6b4d0951 Mon Sep 17 00:00:00 2001 From: Hagen <hagen.dressler@mni.thm.de> Date: Fri, 23 Mar 2018 01:58:00 +0100 Subject: [PATCH] Edit component comment-list (delete not working code) --- .../comment-create-page.component.scss | 4 +- .../comment-list/comment-list.component.html | 68 +++++++++---------- .../comment-list/comment-list.component.scss | 7 +- .../comment-list/comment-list.component.ts | 17 +---- .../room-creator-page.component.html | 8 ++- .../room-participant-page.component.html | 2 +- src/app/services/http/comment.service.ts | 8 +-- 7 files changed, 45 insertions(+), 69 deletions(-) diff --git a/src/app/components/pages/comment-create-page/comment-create-page.component.scss b/src/app/components/pages/comment-create-page/comment-create-page.component.scss index 0ca4a4971..d354757ab 100644 --- a/src/app/components/pages/comment-create-page/comment-create-page.component.scss +++ b/src/app/components/pages/comment-create-page/comment-create-page.component.scss @@ -1,6 +1,4 @@ form { - display: block; - width: 100%; max-width: 800px; - margin-bottom: 50px; + width: 100%; } diff --git a/src/app/components/pages/comment-list/comment-list.component.html b/src/app/components/pages/comment-list/comment-list.component.html index 79ade9f83..cff817686 100644 --- a/src/app/components/pages/comment-list/comment-list.component.html +++ b/src/app/components/pages/comment-list/comment-list.component.html @@ -1,37 +1,31 @@ -<mat-card *ngFor="let comment of comments"> - <mat-card-header> - <mat-card-title>{{comment.subject}}</mat-card-title> - <mat-card-subtitle> - <span class="mat-caption">Submitted on {{ comment.creationTimestamp | date:'dd-MM-yyyy HH:mm:ss' }}</span> - </mat-card-subtitle> - </mat-card-header> - <mat-divider></mat-divider> - <mat-card-content> - <p>{{comment.body}}</p> - </mat-card-content> - <mat-divider></mat-divider> - <mat-card-actions *ngIf="userRole === userRoleTemp"> - <button mat-icon-button *ngIf="comment.read" color="primary" matTooltip="Mark as read" - (click)="setRead(comment)"> - <mat-icon>speaker_notes</mat-icon> - </button> - <button mat-icon-button *ngIf="!comment.read" color="warn" matTooltip="Mark as unread" - (click)="setRead(comment)"> - <mat-icon>speaker_notes_off</mat-icon> - </button> - <button mat-icon-button color="warn" matTooltip="Delete comment" - (click)="delete(comment)"> - <mat-icon>delete</mat-icon> - </button> - </mat-card-actions> - <mat-card-actions *ngIf="userRole !== userRoleTemp"> - <button mat-icon-button *ngIf="comment.read" color="primary" matTooltip="Mark as read" - (click)="setRead(comment)" disabled> - <mat-icon>speaker_notes</mat-icon> - </button> - <button mat-icon-button *ngIf="!comment.read" color="warn" matTooltip="Mark as unread" - (click)="setRead(comment)" disabled> - <mat-icon>speaker_notes_off</mat-icon> - </button> - </mat-card-actions> -</mat-card> +<div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="20px"> + <div fxLayout="row" fxLayoutAlign="center" *ngFor="let comment of comments"> + <mat-card> + <mat-card-header> + <mat-card-title>{{comment.subject}}</mat-card-title> + <mat-card-subtitle> + <span class="mat-caption">Submitted on {{ comment.creationTimestamp | date:'dd-MM-yyyy HH:mm:ss' }}</span> + </mat-card-subtitle> + </mat-card-header> + <mat-divider></mat-divider> + <mat-card-content> + <p>{{comment.body}}</p> + </mat-card-content> + <mat-divider></mat-divider> + <mat-card-actions> + <button mat-icon-button *ngIf="comment.read" color="primary" matTooltip="Mark as read" + (click)="setRead(comment)"> + <mat-icon>speaker_notes</mat-icon> + </button> + <button mat-icon-button *ngIf="!comment.read" color="warn" matTooltip="Mark as unread" + (click)="setRead(comment)"> + <mat-icon>speaker_notes_off</mat-icon> + </button> + <button mat-icon-button color="warn" matTooltip="Delete comment" + (click)="delete(comment)"> + <mat-icon>delete</mat-icon> + </button> + </mat-card-actions> + </mat-card> + </div> +</div> diff --git a/src/app/components/pages/comment-list/comment-list.component.scss b/src/app/components/pages/comment-list/comment-list.component.scss index 54dc90c34..40cb245eb 100644 --- a/src/app/components/pages/comment-list/comment-list.component.scss +++ b/src/app/components/pages/comment-list/comment-list.component.scss @@ -1,7 +1,4 @@ mat-card { - margin-bottom: 20px; -} - -mat-card-content>:first-child { - margin-top: 20px; + max-width: 800px; + width: 100%; } diff --git a/src/app/components/pages/comment-list/comment-list.component.ts b/src/app/components/pages/comment-list/comment-list.component.ts index 7cad6d866..a90f24a85 100644 --- a/src/app/components/pages/comment-list/comment-list.component.ts +++ b/src/app/components/pages/comment-list/comment-list.component.ts @@ -5,9 +5,6 @@ import { Comment } from '../../../models/comment'; import { CommentService } from '../../../services/http/comment.service'; import { RoomService } from '../../../services/http/room.service'; import { NotificationService } from '../../../services/util/notification.service'; -import { AuthenticationService } from '../../../services/http/authentication.service'; -import { UserRole } from '../../../models/user-roles.enum'; -import { User } from '../../../models/user'; @Component({ selector: 'app-comment-list', @@ -15,23 +12,17 @@ import { User } from '../../../models/user'; styleUrls: ['./comment-list.component.scss'] }) export class CommentListComponent implements OnInit { - userRoleTemp: any = UserRole.CREATOR; - userRole: UserRole; - user: User; comments: Comment[]; isLoading = true; - constructor(protected authenticationService: AuthenticationService, - private route: ActivatedRoute, + constructor( private route: ActivatedRoute, private roomService: RoomService, private location: Location, private commentService: CommentService, - private notification: NotificationService) { + private notification: NotificationService ) { } ngOnInit() { - this.userRole = this.authenticationService.getRole(); - this.user = this.authenticationService.getUser(); this.route.params.subscribe(params => { this.getRoom(params['roomId']); }); @@ -63,8 +54,4 @@ export class CommentListComponent implements OnInit { this.notification.show(`Comment '${comment.subject}' successfully deleted.`); }); } - - goBack(): void { - this.location.back(); - } } diff --git a/src/app/components/pages/room-creator-page/room-creator-page.component.html b/src/app/components/pages/room-creator-page/room-creator-page.component.html index d691d5959..dd0efdb73 100644 --- a/src/app/components/pages/room-creator-page/room-creator-page.component.html +++ b/src/app/components/pages/room-creator-page/room-creator-page.component.html @@ -23,13 +23,15 @@ <mat-divider></mat-divider> <mat-card-actions> <button mat-button color="primary" matTooltip="Create new content" - routerLink="/creator/room/{{room.id}}/create-content"> + routerLink="/creator/room/{{ room.shortId }}/create-content"> Create content </button> - <button mat-button color="primary" matTooltip="See room comments" routerLink="/creator/room/{{room.id}}/comments"> + <button mat-button color="primary" matTooltip="See room comments" + routerLink="/creator/room/{{ room.shortId }}/comments"> Comments </button> - <button mat-button color="primary" matTooltip="See answer statistics" routerLink="/creator/room/{{room.id}}/answer-statistics"> + <button mat-button color="primary" matTooltip="See answer statistics" + routerLink="/creator/room/{{ room.shortId }}/answer-statistics"> Answer statistics </button> <button *ngIf="!modify" (click)="showEditDialog()" mat-button color="primary"> diff --git a/src/app/components/pages/room-participant-page/room-participant-page.component.html b/src/app/components/pages/room-participant-page/room-participant-page.component.html index e9444018f..b75ff0e26 100644 --- a/src/app/components/pages/room-participant-page/room-participant-page.component.html +++ b/src/app/components/pages/room-participant-page/room-participant-page.component.html @@ -27,7 +27,7 @@ </mat-grid-tile> </mat-grid-list> <mat-nav-list> - <mat-list-item matTooltip="Join question round" routerLink="/participant/room/{{ room.id }}/questions"> + <mat-list-item matTooltip="Join question round" routerLink="/participant/room/{{ room.shortId }}/questions"> Contents </mat-list-item> <mat-list-item matTooltip="See room comments"> diff --git a/src/app/services/http/comment.service.ts b/src/app/services/http/comment.service.ts index 2bd824827..f6c7ba96d 100644 --- a/src/app/services/http/comment.service.ts +++ b/src/app/services/http/comment.service.ts @@ -16,8 +16,7 @@ export class CommentService extends BaseHttpService { private commentsUrl = '/comment'; private findCommentUrl = '/find'; - constructor( private http: HttpClient, - private authService: AuthenticationService ) { + constructor( private http: HttpClient ) { super(); } @@ -50,10 +49,9 @@ export class CommentService extends BaseHttpService { } updateComment(comment: Comment): Observable<any> { - const url = `${this.apiBaseUrl}${this.commentsUrl}/${comment.id} + '/'`; + const url = `${this.apiBaseUrl}${this.commentsUrl}/${comment.id}`; return this.http.put(url, { - ownerId: this.authService.getUser().id, - roomId: comment.roomId, subject: comment.subject, body: comment.body, read: !comment.read, + read: !comment.read }, httpOptions).pipe( tap(_ => ''), catchError(this.handleError<any>('updateComment')) -- GitLab