angenda and motion list filters

This commit is contained in:
Maximilian Krambach 2019-02-14 13:32:44 +01:00 committed by Emanuel Schütze
parent f09b6f73d6
commit ca2a6b33b2
2 changed files with 65 additions and 0 deletions

View File

@ -107,6 +107,7 @@ export class AgendaListComponent extends ListViewBaseComponent<ViewItem> impleme
this.config this.config
.get<boolean>('agenda_enable_numbering') .get<boolean>('agenda_enable_numbering')
.subscribe(autoNumbering => (this.isNumberingAllowed = autoNumbering)); .subscribe(autoNumbering => (this.isNumberingAllowed = autoNumbering));
this.setFulltextFilter();
} }
/** /**
@ -287,4 +288,24 @@ export class AgendaListComponent extends ListViewBaseComponent<ViewItem> impleme
return result; return result;
} }
} }
/**
* Overwrites the dataSource's string filter with a case-insensitive search
* in the item number and title
*/
private setFulltextFilter(): void {
this.dataSource.filterPredicate = (data, filter) => {
if (!data) {
return false;
}
filter = filter ? filter.toLowerCase() : '';
return (
data.itemNumber.toLowerCase().includes(filter) ||
data
.getListTitle()
.toLowerCase()
.includes(filter)
);
};
}
} }

View File

@ -135,6 +135,7 @@ export class MotionListComponent extends ListViewBaseComponent<ViewMotion> imple
this.dataSource.data = sortedData; this.dataSource.data = sortedData;
this.checkSelection(); this.checkSelection();
}); });
this.setFulltextFilter();
} }
/** /**
@ -285,4 +286,47 @@ export class MotionListComponent extends ListViewBaseComponent<ViewMotion> imple
this.configService.instant<string>('motions_recommendation_text_mode') as ChangeRecoMode this.configService.instant<string>('motions_recommendation_text_mode') as ChangeRecoMode
); );
} }
/**
* Overwrites the dataSource's string filter with a case-insensitive search
* in the identifier, title, state, recommendations, submitters and motion blocks
*/
private setFulltextFilter(): void {
this.dataSource.filterPredicate = (data, filter) => {
if (!data) {
return false;
}
filter = filter ? filter.toLowerCase() : '';
if (
data.recommendation &&
this.translate
.instant(data.recommendation.recommendation_label)
.toLowerCase()
.includes(filter)
) {
return true;
}
if (
this.translate
.instant(data.state.name)
.toLowerCase()
.includes(filter)
) {
return true;
}
if (data.submitters.length && data.submitters.find(user => user.full_name.toLowerCase().includes(filter))) {
return true;
}
if (data.motion_block && data.motion_block.title.toLowerCase().includes(filter)) {
return true;
}
if (data.title.toLowerCase().includes(filter)) {
return true;
}
if (data.identifier && data.identifier.toLowerCase().includes(filter)) {
return true;
}
return false;
};
}
} }