Merge pull request #4926 from tsiegleauq/hide-amendments-from-motion-list

Add option to hide amendments
This commit is contained in:
Emanuel Schütze 2019-08-20 12:00:25 +02:00 committed by GitHub
commit 14d7269959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 16 deletions

View File

@ -338,23 +338,27 @@ export class ListViewTableComponent<V extends BaseViewModel, M extends BaseModel
// custom filter predicates
if (this.filterProps && this.filterProps.length) {
for (const prop of this.filterProps) {
let propertyAsString = '';
// If the property is a function, call it.
if (typeof item[prop] === 'function') {
propertyAsString = '' + item[prop]();
} else {
propertyAsString = '' + item[prop];
}
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];
}
if (!!propertyAsString) {
const foundProp =
propertyAsString
.trim()
.toLowerCase()
.indexOf(trimmedInput) !== -1;
if (!!propertyAsString) {
const foundProp =
propertyAsString
.trim()
.toLowerCase()
.indexOf(trimmedInput) !== -1;
if (foundProp) {
return true;
if (foundProp) {
return true;
}
}
}
}

View File

@ -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'];
/**
*

View File

@ -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;