Skip to content

Commit

Permalink
Admin perimeters : fix filter on state rights column (#6379)
Browse files Browse the repository at this point in the history
Signed-off-by: Giovanni Ferrari <giovanni.ferrari@soft.it>
  • Loading branch information
quinarygio committed May 14, 2024
1 parent f4a2e50 commit 9c7d898
Showing 1 changed file with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,44 @@ export class PerimetersTableComponent extends AdminTableDirective implements OnI
sortable: false,
filter: 'agTextColumnFilter',
filterParams: {
valueGetter: (params) => {
textMatcher: (params) => {
const currentProcessDef = this.processesDefinition.filter(
(processDef) => processDef.id === params.data.process
)[0];
let text = '';
params.data.stateRights.forEach((stateRight) => {
if (currentProcessDef.states.get(stateRight.state))
text += currentProcessDef.states.get(stateRight.state).name + ' ';
text += currentProcessDef.states.get(stateRight.state).name.toLocaleLowerCase() + ' ';
});
return text;

let response = false;

switch (params.filterOption) {
case 'equals':
response = text.toLocaleLowerCase() === params.filterText;
break;
case 'contains':
response = text.toLocaleLowerCase().indexOf(params.filterText) >= 0;
break;
case 'notContains':
response = text.toLocaleLowerCase().indexOf(params.filterText) < 0;
break;
case 'startsWith':
response = text.toLocaleLowerCase().startsWith(params.filterText);
break;
case 'endsWith':
response = text.toLocaleLowerCase().endsWith(params.filterText);
break;
case 'blank':
response = text.trim().length === 0;
break;
case 'notblank':
response = text.trim().length > 0;
break;
default:
break;
}
return response;
}
},
wrapText: true,
Expand Down

0 comments on commit 9c7d898

Please sign in to comment.