From 05d9f6a3bb3a46520a312761f8b0c8484df88461 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Thu, 14 Feb 2019 13:07:04 +0100 Subject: [PATCH] Fix comment section list --- .../motion-comment-section-list.component.ts | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/client/src/app/site/motions/components/motion-comment-section-list/motion-comment-section-list.component.ts b/client/src/app/site/motions/components/motion-comment-section-list/motion-comment-section-list.component.ts index 24d41eccc..12555ae56 100644 --- a/client/src/app/site/motions/components/motion-comment-section-list/motion-comment-section-list.component.ts +++ b/client/src/app/site/motions/components/motion-comment-section-list/motion-comment-section-list.component.ts @@ -10,12 +10,12 @@ import { MotionCommentSection } from 'app/shared/models/motions/motion-comment-s import { ViewMotionCommentSection } from '../../models/view-motion-comment-section'; import { MotionCommentSectionRepositoryService } from 'app/core/repositories/motions/motion-comment-section-repository.service'; import { PromptService } from 'app/core/ui-services/prompt.service'; -import { Group } from 'app/shared/models/users/group'; -import { DataStoreService } from 'app/core/core-services/data-store.service'; import { BaseViewComponent } from '../../../base/base-view'; +import { ViewGroup } from 'app/site/users/models/view-group'; +import { GroupRepositoryService } from 'app/core/repositories/users/group-repository.service'; /** - * List view for the categories. + * List view for the comment sections. */ @Component({ selector: 'os-motion-comment-section-list', @@ -40,7 +40,7 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme public openId: number | null; public editId: number | null; - public groups: BehaviorSubject>; + public groups: BehaviorSubject; /** * The usual component constructor @@ -59,7 +59,7 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme private repo: MotionCommentSectionRepositoryService, private formBuilder: FormBuilder, private promptService: PromptService, - private DS: DataStoreService + private groupRepo: GroupRepositoryService ) { super(titleService, translate, matSnackBar); @@ -97,20 +97,12 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme /** * Init function. - * - * Sets the title and gets/observes categories from DataStore */ public ngOnInit(): void { super.setTitle('Comment fields'); - this.groups = new BehaviorSubject(this.DS.getAll(Group)); - this.DS.changeObservable.subscribe(model => { - if (model instanceof Group) { - this.groups.next(this.DS.getAll(Group)); - } - }); - this.repo.getViewModelListObservable().subscribe(newViewSections => { - this.commentSections = newViewSections; - }); + this.groups = new BehaviorSubject(this.groupRepo.getViewModelList()); + this.groupRepo.getViewModelListObservable().subscribe(groups => this.groups.next(groups)); + this.repo.getViewModelListObservable().subscribe(newViewSections => (this.commentSections = newViewSections)); } /** @@ -154,7 +146,8 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme } /** - * Saves the categories + * Saves the comment section + * * @param viewSection The section to save */ public onSaveButton(viewSection: ViewMotionCommentSection): void { @@ -178,7 +171,7 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme /** * Is executed when a mat-extension-panel is closed - * @param viewSection the category in the panel + * @param viewSection the section in the panel */ public panelClosed(viewSection: ViewMotionCommentSection): void { this.openId = null;