Skip to content

Commit

Permalink
split first name / last name in filter search person (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbittich authored Mar 9, 2022
1 parent 2fba8c5 commit 66c15d1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
13 changes: 11 additions & 2 deletions app/controllers/people/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@ import { tracked } from '@glimmer/tracking';

export default class PeopleIndexController extends Controller {
@service router;
queryParams = ['page', 'size', 'name', 'organization', 'status', 'position'];
queryParams = [
'page',
'size',
'given_name',
'family_name',
'organization',
'status',
'position',
];
@tracked status = true;
@tracked position;

@tracked page = 0;
size = 25;
@tracked sort = 'family_name';
@tracked name = '';
@tracked given_name = '';
@tracked family_name = '';
@tracked organization;
@tracked selectedOrganization;

Expand Down
12 changes: 7 additions & 5 deletions app/routes/people/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default class PeopleIndexRoute extends Route {
organization: { replace: true },
status: { refreshModel: true },
position: { refreshModel: true },
name: { replace: true },
given_name: { replace: true },
family_name: { replace: true },
};

model(params) {
Expand All @@ -24,10 +25,11 @@ export default class PeopleIndexRoute extends Route {
@dropTask({ cancelOn: 'deactivate' })
*loadPeopleTask(params) {
const filter = {};
if (params.name) {
filter[
':query:given_name'
] = `(given_name:${params.name}~) OR (family_name:${params.name}~ ) `;
if (params.given_name) {
filter[':prefix:given_name'] = `${params.given_name.toLowerCase()}`;
}
if (params.family_name) {
filter[':prefix:family_name'] = `${params.family_name.toLowerCase()}`;
}
if (params.status) {
let date = new Date().toISOString().slice(0, -5);
Expand Down
12 changes: 10 additions & 2 deletions app/templates/people/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
<div class="au-c-sidebar__content au-o-box">
<form {{on "submit" this.search}} class="au-o-grid au-o-grid--small">
<p class="au-o-grid__item">
<AuLabel for="filter-given-name">Naam</AuLabel>
<AuLabel for="filter-given-name">Voornaam</AuLabel>
<AuInput
@width="block"
@value={{this.name}}
@value={{this.given_name}}
id="filter-given-name"
/>
</p>
<p class="au-o-grid__item">
<AuLabel for="filter-family-name">Achternaam</AuLabel>
<AuInput
@width="block"
@value={{this.family_name}}
id="filter-family-name"
/>
</p>
<p class="au-o-grid__item">
<AuLabel for="filter-organization">Organisatie</AuLabel>
<AdministrativeUnitSelect
Expand Down

0 comments on commit 66c15d1

Please sign in to comment.