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
This commit is contained in:
Sean Engelhardt 2019-08-19 16:25:35 +02:00
parent eaf4d8180d
commit e7357a5b64
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;