From e7357a5b6489cb62b64c956b2b5e3581cd49e11f Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Mon, 19 Aug 2019 16:25:35 +0200 Subject: [PATCH] Add option to hide amendments Enables to hide amendments from the motion list Allows to search through amendment paragraphs in the list view of amendments --- .../list-view-table.component.ts | 34 +++++++++++-------- .../amendment-list.component.ts | 2 +- .../services/motion-filter-list.service.ts | 25 ++++++++++++++ 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/client/src/app/shared/components/list-view-table/list-view-table.component.ts b/client/src/app/shared/components/list-view-table/list-view-table.component.ts index 86ec9d863..8b0107ab1 100644 --- a/client/src/app/shared/components/list-view-table/list-view-table.component.ts +++ b/client/src/app/shared/components/list-view-table/list-view-table.component.ts @@ -338,23 +338,27 @@ export class ListViewTableComponent im /** * To filter stuff */ - public filterProps = ['submitters', 'title', 'identifier']; + public filterProps = ['submitters', 'title', 'identifier', 'amendment_paragraphs']; /** * diff --git a/client/src/app/site/motions/services/motion-filter-list.service.ts b/client/src/app/site/motions/services/motion-filter-list.service.ts index 3245c9363..254883fbf 100644 --- a/client/src/app/site/motions/services/motion-filter-list.service.ts +++ b/client/src/app/site/motions/services/motion-filter-list.service.ts @@ -39,6 +39,11 @@ export class MotionFilterListService extends BaseFilterListService { */ private enabledWorkflows = { statuteEnabled: false, statute: null, motion: null }; + /** + * Determine to show amendments in the motion list + */ + private showAmendmentsInMainTable: boolean; + /** * Filter definitions for the workflow filter. Options will be generated by * getFilterOptions (as the workflows available may change) @@ -136,6 +141,7 @@ export class MotionFilterListService extends BaseFilterListService { ) { super(store, OSStatus); this.getWorkflowConfig(); + this.getShowAmendmentConfig(); this.updateFilterForRepo(categoryRepo, this.categoryFilterOptions, this.translate.instant('No category set')); @@ -155,6 +161,25 @@ export class MotionFilterListService extends BaseFilterListService { }); } + /** + * @override + * @param motions The motions without amendments, if the according config was set + */ + protected preFilter(motions: ViewMotion[]): ViewMotion[] { + if (!this.showAmendmentsInMainTable) { + return motions.filter(motion => !motion.parent_id); + } + } + + /** + * Listen to changes for the 'motions_amendments_main_table' config value + */ + private getShowAmendmentConfig(): void { + this.config.get('motions_amendments_main_table').subscribe(show => { + this.showAmendmentsInMainTable = show; + }); + } + private getWorkflowConfig(): void { this.config.get('motions_statute_amendments_workflow').subscribe(id => { this.enabledWorkflows.statute = +id;