Merge pull request #4926 from tsiegleauq/hide-amendments-from-motion-list
Add option to hide amendments
This commit is contained in:
commit
14d7269959
@ -338,10 +338,13 @@ export class ListViewTableComponent<V extends BaseViewModel, M extends BaseModel
|
||||
// custom filter predicates
|
||||
if (this.filterProps && this.filterProps.length) {
|
||||
for (const prop of this.filterProps) {
|
||||
if (item[prop]) {
|
||||
let propertyAsString = '';
|
||||
// If the property is a function, call it.
|
||||
if (typeof item[prop] === 'function') {
|
||||
propertyAsString = '' + item[prop]();
|
||||
} else if (item[prop].constructor === Array) {
|
||||
propertyAsString = item[prop].join('');
|
||||
} else {
|
||||
propertyAsString = '' + item[prop];
|
||||
}
|
||||
@ -360,6 +363,7 @@ export class ListViewTableComponent<V extends BaseViewModel, M extends BaseModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.dataSource.setFilter(filterPredicate);
|
||||
|
@ -62,7 +62,7 @@ export class AmendmentListComponent extends BaseListViewComponent<ViewMotion> im
|
||||
/**
|
||||
* To filter stuff
|
||||
*/
|
||||
public filterProps = ['submitters', 'title', 'identifier'];
|
||||
public filterProps = ['submitters', 'title', 'identifier', 'amendment_paragraphs'];
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -39,6 +39,11 @@ export class MotionFilterListService extends BaseFilterListService<ViewMotion> {
|
||||
*/
|
||||
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<ViewMotion> {
|
||||
) {
|
||||
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<ViewMotion> {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @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<boolean>('motions_amendments_main_table').subscribe(show => {
|
||||
this.showAmendmentsInMainTable = show;
|
||||
});
|
||||
}
|
||||
|
||||
private getWorkflowConfig(): void {
|
||||
this.config.get<string>('motions_statute_amendments_workflow').subscribe(id => {
|
||||
this.enabledWorkflows.statute = +id;
|
||||
|
Loading…
Reference in New Issue
Block a user