diff --git a/src/app/components/creator/_dialogs/tags/tags.component.html b/src/app/components/creator/_dialogs/tags/tags.component.html index a439d548a55185e32def8c767de159ab8e7609af..bbf60db9987edaf3b29d18637b97e0565a3a13b4 100644 --- a/src/app/components/creator/_dialogs/tags/tags.component.html +++ b/src/app/components/creator/_dialogs/tags/tags.component.html @@ -13,7 +13,7 @@ aria-labelledby="tag-new" [formControl]="tagFormControl" name="taginput" - maxlength="30"/> + maxlength="20"/> <mat-placeholder class="placeholder">{{ 'room-page.tag-new' | translate }}</mat-placeholder> <mat-hint align="end"><span aria-hidden="true">{{tag.value.length}} / 30</span></mat-hint> <mat-error *ngIf="!tagFormControl.valid"> @@ -29,7 +29,7 @@ </button> <span class="fill-remaining-space"></span> </div> - <div *ngIf="tagsEnabled === true && tags !== undefined && tags.length > 0"> + <div *ngIf="tags.length > 0"> <div fxLayout="row" *ngFor="let tag of tags" diff --git a/src/app/components/creator/_dialogs/tags/tags.component.ts b/src/app/components/creator/_dialogs/tags/tags.component.ts index dd5e91a4d1c01ddeaf6b05b7d7d0d225d479c7ab..5c39e455959be592e2fe6ce61a79c2158babbf21 100644 --- a/src/app/components/creator/_dialogs/tags/tags.component.ts +++ b/src/app/components/creator/_dialogs/tags/tags.component.ts @@ -12,12 +12,9 @@ import { FormControl, Validators } from '@angular/forms'; templateUrl: './tags.component.html', styleUrls: ['./tags.component.scss'] }) -export class TagsComponent implements OnInit { - - extension: {}; +export class TagsComponent { tags: string[]; - tagsEnabled: boolean; tagFormControl = new FormControl('', [Validators.minLength(3), Validators.maxLength(50)]); @ViewChild('tag') redel: ElementRef; @@ -32,37 +29,19 @@ export class TagsComponent implements OnInit { langService.langEmitter.subscribe(lang => translationService.use(lang)); } - ngOnInit() { - if (!this.extension) { - this.extension = {}; - this.extension['enableTags'] = true; - this.tags = []; - this.tagsEnabled = true; - } else { - if (this.extension['tags']) { - this.tags = this.extension['tags']; - } else { - this.tags = []; - } - this.tagsEnabled = this.extension['enableTags']; - } - } - addTag(tag: string) { - if (this.tagFormControl.valid) { + if (this.tagFormControl.valid && tag.length > 0) { this.tags.push(tag); - this.extension['tags'] = this.tags; this.redel.nativeElement.value = ''; } } deleteTag(tag: string) { this.tags = this.tags.filter(o => o !== tag); - this.extension['tags'] = this.tags; } closeDialog(): void { - this.dialogRef.close(this.extension); + this.dialogRef.close(this.tags); } diff --git a/src/app/components/creator/room-creator-page/room-creator-page.component.ts b/src/app/components/creator/room-creator-page/room-creator-page.component.ts index 2c0586a0510d686304afe604300309d2dddbc52b..f47f4fab4d464d0bc4861522a7ab4564833e7817 100644 --- a/src/app/components/creator/room-creator-page/room-creator-page.component.ts +++ b/src/app/components/creator/room-creator-page/room-creator-page.component.ts @@ -123,14 +123,7 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni } updateCommentSettings(settings: CommentSettingsDialog) { - // ToDo: FIX - /*const commentExtension: TSMap<string, any> = new TSMap(); - commentExtension.set('enableThreshold', settings.enableThreshold); - commentExtension.set('commentThreshold', settings.threshold); - commentExtension.set('enableModeration', settings.enableModeration); - commentExtension.set('enableTags', settings.enableTags); - commentExtension.set('tags', settings.tags); - this.room.extensions['comments'] = commentExtension; + this.room.tags = settings.tags; if (this.moderationEnabled && !settings.enableModeration) { this.viewModuleCount = this.viewModuleCount - 1; @@ -140,15 +133,13 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni this.moderationEnabled = settings.enableModeration; localStorage.setItem('moderationEnabled', String(this.moderationEnabled)); - - this.updRoom.extensions['comments'] = commentExtension;*/ } resetThreshold(): void { - // ToDo: FIX - /*if (this.room.extensions && this.room.extensions['comments']) { - delete this.room.extensions['comments']; - }*/ + this.room.moderated = undefined; + this.room.threshold = undefined; + this.room.directSend = undefined; + this.room.tags = undefined; } saveChanges() { @@ -224,25 +215,24 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni } showTagsDialog(): void { - // ToDo: FIX - // this.updRoom = JSON.parse(JSON.stringify(this.room)); - /*const dialogRef = this.dialog.open(TagsComponent, { + this.updRoom = JSON.parse(JSON.stringify(this.room)); + const dialogRef = this.dialog.open(TagsComponent, { width: '400px' }); - let tagExtension; - if (this.room.extensions !== undefined && this.room.extensions['tags'] !== undefined) { - tagExtension = JSON.parse(JSON.stringify(this.room.extensions['tags'])); + let tags = []; + if (this.room.tags !== undefined) { + tags = this.room.tags; } - dialogRef.componentInstance.extension = tagExtension; + dialogRef.componentInstance.tags = tags; dialogRef.afterClosed() .subscribe(result => { if (!result || result === 'abort') { return; } else { - this.updRoom.extensions['tags'] = result; + this.updRoom.tags = result; this.saveChanges(); } - });*/ + }); } copyShortId(): void { diff --git a/src/app/components/shared/_dialogs/create-comment/create-comment.component.ts b/src/app/components/shared/_dialogs/create-comment/create-comment.component.ts index 0c10780c9d19754688516a8f0d9ceaaeafe9e8db..5e14d05cb5e5dce50b04a7112bfe9e43cd2e1530 100644 --- a/src/app/components/shared/_dialogs/create-comment/create-comment.component.ts +++ b/src/app/components/shared/_dialogs/create-comment/create-comment.component.ts @@ -65,9 +65,7 @@ export class CreateCommentComponent implements OnInit { comment.body = body; comment.creatorId = this.user.id; comment.createdFromLecturer = this.user.role === 1; - if (this.selectedTag !== null) { - comment.tag = this.selectedTag; - } + comment.tag = this.selectedTag; this.dialogRef.close(comment); } } diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index 07c995f4cada25a8c33903de2cac851ad1c09909..7ab27fe5f8bb2ab55fccdcd8febab6c258519eab 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -295,10 +295,9 @@ export class CommentListComponent implements OnInit, OnDestroy { dialogRef.componentInstance.roomId = this.roomId; let tags; tags = []; - // ToDo: FIX - /*if (this.room.extensions && this.room.extensions['tags'] && this.room.extensions['tags'].tags) { - tags = this.room.extensions['tags'].tags; - }*/ + if (this.room.tags) { + tags = this.room.tags; + } dialogRef.componentInstance.tags = tags; dialogRef.afterClosed() .subscribe(result => { diff --git a/src/app/components/shared/questionwall/question-wall/question-wall.component.ts b/src/app/components/shared/questionwall/question-wall/question-wall.component.ts index dc49394d7545cf705f2622058e87c195d8954ff4..3919c37bbcd9d42d1a415eedca3cecd5bd34c293 100644 --- a/src/app/components/shared/questionwall/question-wall/question-wall.component.ts +++ b/src/app/components/shared/questionwall/question-wall/question-wall.component.ts @@ -84,9 +84,7 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy { }); this.roomService.getRoom(this.roomId).subscribe(e => { this.room = e; - // ToDo: Fix - // this.tags = e.extensions['tags']['tags']; - this.tags = []; + this.tags = e.tags; }); this.wsCommentService.getCommentStream(this.roomId).subscribe(e => { this.commentService.getComment(JSON.parse(e.body).payload.id).subscribe(comment => { diff --git a/src/app/models/room.ts b/src/app/models/room.ts index d345d0b6441ade5e1a04f74aa47bde5283ffd11c..f1af7606f38c427b79d8f8e5c05189e1ddbddd9f 100644 --- a/src/app/models/room.ts +++ b/src/app/models/room.ts @@ -12,6 +12,7 @@ export class Room { moderated: boolean; directSend: boolean; threshold: number; + tags: string[]; constructor( ownerId: string = '', @@ -23,16 +24,18 @@ export class Room { moderated: boolean = true, directSend: boolean = true, threshold: number = null, + tags: string[] = [] ) { - this.id = '', + this.id = ''; this.ownerId = ownerId; this.shortId = shortId; this.abbreviation = abbreviation; - this.name = name, + this.name = name; this.description = description; this.closed = closed; this.moderated = moderated; this.directSend = directSend; this.threshold = threshold; + this.tags = tags; } } diff --git a/src/app/services/http/comment.service.ts b/src/app/services/http/comment.service.ts index a3ed74dcfc46f416e42fa6cb82bb4ade5cea074f..1d3f3a544c72e44edc331c2e30c5a1b63c64fa34 100644 --- a/src/app/services/http/comment.service.ts +++ b/src/app/services/http/comment.service.ts @@ -75,7 +75,7 @@ export class CommentService extends BaseHttpService { return this.http.post<Comment>(connectionUrl, { roomId: comment.roomId, body: comment.body, - read: comment.read, creationTimestamp: comment.timestamp + read: comment.read, creationTimestamp: comment.timestamp, tag: comment.tag }, httpOptions).pipe( tap(_ => ''), catchError(this.handleError<Comment>('addComment'))