Skip to content
Snippets Groups Projects
Commit a0f6bb05 authored by Thomas Groß's avatar Thomas Groß
Browse files

Merge branch 'comment-component' into 'master'

Comment component

See merge request swtp-2019/arsnova-lite!13
parents 2811dbc8 d962351c
Branches
Tags
No related merge requests found
<mat-toolbar >List of Questions</mat-toolbar> <mat-toolbar >List of Questions</mat-toolbar>
<mat-card class="outer-card"> <mat-card class="outer-card">
<mat-card class="card-container" *ngFor="let comment of comments"> <app-comment *ngFor="let current of comments" [comment]="current"> </app-comment>
<mat-card-title>{{comment.subject}}</mat-card-title>
<mat-divider></mat-divider>
<mat-card-content>
<p>{{comment.body}}</p>
</mat-card-content>
</mat-card>
</mat-card> </mat-card>
import { Component, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { Comment } from '../../../models/comment'; import { Comment } from '../../../models/comment';
...@@ -52,16 +52,4 @@ export class CommentListComponent implements OnInit { ...@@ -52,16 +52,4 @@ export class CommentListComponent implements OnInit {
this.isLoading = false; this.isLoading = false;
}); });
} }
setRead(comment: Comment): void {
this.comments.find(c => c.id === comment.id).read = !comment.read;
this.commentService.updateComment(comment).subscribe();
}
delete(comment: Comment): void {
this.comments = this.comments.filter(c => c !== comment);
this.commentService.deleteComment(comment.id).subscribe(room => {
this.notification.show(`Comment '${comment.subject}' successfully deleted.`);
});
}
} }
<mat-card>
<mat-card-title>{{comment.subject}}</mat-card-title>
<mat-divider></mat-divider>
<mat-card-content>
<p>{{comment.body}}</p>
</mat-card-content>
</mat-card>
/*import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CommentComponent } from './comment.component';
describe('CommentComponent', () => {
let component: CommentComponent;
let fixture: ComponentFixture<CommentComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CommentComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CommentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
*/
import { Component, Input, OnInit } from '@angular/core';
import { Comment } from '../../../models/comment';
import { UserRole } from '../../../models/user-roles.enum';
import { User } from '../../../models/user';
import { AuthenticationService } from '../../../services/http/authentication.service';
import { ActivatedRoute } from '@angular/router';
import { RoomService } from '../../../services/http/room.service';
import { Location } from '@angular/common';
import { CommentService } from '../../../services/http/comment.service';
import { NotificationService } from '../../../services/util/notification.service';
import { TranslateService } from '@ngx-translate/core';
import { LanguageService } from '../../../services/util/language.service';
@Component({
selector: 'app-comment',
templateUrl: './comment.component.html',
styleUrls: ['./comment.component.scss']
})
export class CommentComponent implements OnInit {
@Input() comment: Comment;
userRoleTemp: any = UserRole.CREATOR;
userRole: UserRole;
user: User;
isLoading = true;
roomId: string;
roomShortId: string;
constructor(protected authenticationService: AuthenticationService,
private route: ActivatedRoute,
private roomService: RoomService,
private location: Location,
private commentService: CommentService,
private notification: NotificationService,
private translateService: TranslateService,
protected langService: LanguageService) {
langService.langEmitter.subscribe(lang => translateService.use(lang)); }
ngOnInit() {
this.userRole = this.authenticationService.getRole();
this.user = this.authenticationService.getUser();
this.roomShortId = this.route.snapshot.paramMap.get('roomId');
this.roomId = localStorage.getItem(`roomId`);
this.translateService.use(localStorage.getItem('currentLang'));
}
setRead(comment: Comment): void {
this.commentService.updateComment(comment).subscribe();
}
delete(comment: Comment): void {
this.commentService.deleteComment(comment.id).subscribe(room => {
this.notification.show(`Comment '${comment.subject}' successfully deleted.`);
});
}
}
...@@ -21,6 +21,7 @@ import { RoomJoinComponent } from './room-join/room-join.component'; ...@@ -21,6 +21,7 @@ import { RoomJoinComponent } from './room-join/room-join.component';
import { RoomCreateComponent } from './_dialogs/room-create/room-create.component'; import { RoomCreateComponent } from './_dialogs/room-create/room-create.component';
import { LoginComponent } from './login/login.component'; import { LoginComponent } from './login/login.component';
import { StatisticHelpComponent } from './_dialogs/statistic-help/statistic-help.component'; import { StatisticHelpComponent } from './_dialogs/statistic-help/statistic-help.component';
import { CommentComponent } from './comment/comment.component';
@NgModule({ @NgModule({
imports: [ imports: [
...@@ -48,7 +49,8 @@ import { StatisticHelpComponent } from './_dialogs/statistic-help/statistic-help ...@@ -48,7 +49,8 @@ import { StatisticHelpComponent } from './_dialogs/statistic-help/statistic-help
StatisticComponent, StatisticComponent,
RoomCreateComponent, RoomCreateComponent,
LoginComponent, LoginComponent,
StatisticHelpComponent StatisticHelpComponent,
CommentComponent
], ],
exports: [ exports: [
RoomJoinComponent, RoomJoinComponent,
......
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