Merge pull request #4340 from FinnStutzenstein/fixMotionCommentSectionList

Fix comment section list
This commit is contained in:
Emanuel Schütze 2019-02-14 13:29:05 +01:00 committed by GitHub
commit 67fd5ee2c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,12 +10,12 @@ import { MotionCommentSection } from 'app/shared/models/motions/motion-comment-s
import { ViewMotionCommentSection } from '../../models/view-motion-comment-section'; import { ViewMotionCommentSection } from '../../models/view-motion-comment-section';
import { MotionCommentSectionRepositoryService } from 'app/core/repositories/motions/motion-comment-section-repository.service'; import { MotionCommentSectionRepositoryService } from 'app/core/repositories/motions/motion-comment-section-repository.service';
import { PromptService } from 'app/core/ui-services/prompt.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 { 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({ @Component({
selector: 'os-motion-comment-section-list', selector: 'os-motion-comment-section-list',
@ -40,7 +40,7 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme
public openId: number | null; public openId: number | null;
public editId: number | null; public editId: number | null;
public groups: BehaviorSubject<Array<Group>>; public groups: BehaviorSubject<ViewGroup[]>;
/** /**
* The usual component constructor * The usual component constructor
@ -59,7 +59,7 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme
private repo: MotionCommentSectionRepositoryService, private repo: MotionCommentSectionRepositoryService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private promptService: PromptService, private promptService: PromptService,
private DS: DataStoreService private groupRepo: GroupRepositoryService
) { ) {
super(titleService, translate, matSnackBar); super(titleService, translate, matSnackBar);
@ -97,20 +97,12 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme
/** /**
* Init function. * Init function.
*
* Sets the title and gets/observes categories from DataStore
*/ */
public ngOnInit(): void { public ngOnInit(): void {
super.setTitle('Comment fields'); super.setTitle('Comment fields');
this.groups = new BehaviorSubject(this.DS.getAll(Group)); this.groups = new BehaviorSubject(this.groupRepo.getViewModelList());
this.DS.changeObservable.subscribe(model => { this.groupRepo.getViewModelListObservable().subscribe(groups => this.groups.next(groups));
if (model instanceof Group) { this.repo.getViewModelListObservable().subscribe(newViewSections => (this.commentSections = newViewSections));
this.groups.next(this.DS.getAll(Group));
}
});
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 * @param viewSection The section to save
*/ */
public onSaveButton(viewSection: ViewMotionCommentSection): void { public onSaveButton(viewSection: ViewMotionCommentSection): void {
@ -178,7 +171,7 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme
/** /**
* Is executed when a mat-extension-panel is closed * 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 { public panelClosed(viewSection: ViewMotionCommentSection): void {
this.openId = null; this.openId = null;