Merge pull request #5163 from tsiegleauq/no-order-in-comments

Fix order of comments in motion detail
This commit is contained in:
Emanuel Schütze 2019-12-13 09:22:47 +01:00 committed by GitHub
commit cc4d867e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 9 deletions

View File

@ -1,4 +1,4 @@
import { Component, Input } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms'; import { FormBuilder, FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Title } from '@angular/platform-browser'; import { Title } from '@angular/platform-browser';
@ -21,7 +21,7 @@ import { MotionPdfExportService } from 'app/site/motions/services/motion-pdf-exp
templateUrl: './motion-comments.component.html', templateUrl: './motion-comments.component.html',
styleUrls: ['./motion-comments.component.scss'] styleUrls: ['./motion-comments.component.scss']
}) })
export class MotionCommentsComponent extends BaseViewComponent { export class MotionCommentsComponent extends BaseViewComponent implements OnInit {
/** /**
* An array of all sections the operator can see. * An array of all sections the operator can see.
*/ */
@ -79,19 +79,27 @@ export class MotionCommentsComponent extends BaseViewComponent {
matSnackBar: MatSnackBar matSnackBar: MatSnackBar
) { ) {
super(titleService, translate, matSnackBar); super(titleService, translate, matSnackBar);
}
this.commentRepo.getViewModelListObservable().subscribe(sections => this.setSections(sections)); public ngOnInit(): void {
this.operator.getUserObservable().subscribe(() => this.setSections(this.commentRepo.getViewModelList())); this.subscriptions.push(
this.commentRepo.getViewModelListObservable().subscribe(sections => {
if (sections && sections.length) {
this.sections = sections;
this.filterSections();
}
})
);
} }
/** /**
* sets the `sections` member with sections, if the operator has reading permissions. * sets the `sections` member with sections, if the operator has reading permissions.
*
* @param allSections A list of all sections available
*/ */
private setSections(allSections: ViewMotionCommentSection[]): void { private filterSections(): void {
this.sections = allSections.filter(section => this.operator.isInGroupIds(...section.read_groups_id)); if (this.sections && this.sections.length) {
this.updateComments(); this.sections = this.sections.filter(section => this.operator.isInGroupIds(...section.read_groups_id));
this.updateComments();
}
} }
/** /**