Skip to content

Commit

Permalink
Merge pull request #296 from lblod/bugfix/search-and-pagination
Browse files Browse the repository at this point in the history
Bugfix/search and pagination
  • Loading branch information
nvdk authored Jul 1, 2022
2 parents db9a01c + 050facb commit abe274c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 12 deletions.
23 changes: 19 additions & 4 deletions app/controllers/inbox/agendapoints.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import Controller from '@ember/controller';
import DefaultQueryParamsMixin from 'ember-data-table/mixins/default-query-params';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { restartableTask, timeout } from 'ember-concurrency';

export default class InboxDraftDecisionsController extends Controller {
@tracked page = 0;
@tracked size = 10;
@tracked filter = '';
@tracked searchValue = this.filter;
@tracked debounceTime = 2000;

export default class InboxDraftDecisionsController extends Controller.extend(
DefaultQueryParamsMixin
) {
@service currentSession;
@service router;
sort = '-current-version.updated-on';

@restartableTask
*updateFilter(event) {
const input = event.target.value;
this.searchValue = input;
yield timeout(this.debounceTime);
this.filter = this.searchValue;
this.page = 0;
}

@action
openNewDocument() {
this.router.transitionTo('agendapoints.new');
}

get readOnly() {
return !this.currentSession.canWrite && this.currentSession.canRead;
}
Expand Down
12 changes: 12 additions & 0 deletions app/controllers/inbox/irg-archive.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { restartableTask, timeout } from 'ember-concurrency';

export default class InboxIrgArchiveController extends Controller {
@tracked page = 0;
@tracked size = 10;
@tracked filter = '';
@tracked searchValue = this.filter;
@tracked debounceTime = 2000;

@restartableTask
*updateFilter(event) {
const input = event.target.value;
this.searchValue = input;
yield timeout(this.debounceTime);
this.filter = this.searchValue;
this.page = 0;
}
}
6 changes: 3 additions & 3 deletions app/routes/inbox/agendapoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class InboxAgendapointsRoute extends Route {
queryParams = {
page: { refreshModel: true },
sort: { refreshModel: true },
title: { refreshModel: true },
filter: { refreshModel: true },
};

async model(params) {
Expand All @@ -22,8 +22,8 @@ export default class InboxAgendapointsRoute extends Route {
number: params.page,
},
};
if (params.title) {
options['filter[current-version][title]'] = params.title;
if (params.filter) {
options['filter[current-version][title]'] = params.filter;
}
return this.store.query('document-container', options);
}
Expand Down
6 changes: 3 additions & 3 deletions app/routes/inbox/irg-archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class InboxIrgArchiveRoute extends Route {
queryParams = {
page: { refreshModel: true },
sort: { refreshModel: true },
title: { refreshModel: true },
filter: { refreshModel: true },
};

async model(params) {
Expand All @@ -20,8 +20,8 @@ export default class InboxIrgArchiveRoute extends Route {
number: params.page,
},
};
if (params.title) {
options['filter[current-version][title]'] = params.title;
if (params.filter) {
options['filter[current-version][title]'] = params.filter;
}
return this.store.query('document-container', options);
}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/inbox/agendapoints.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</AuHeading>
</AuToolbarGroup>
<AuToolbarGroup class="au-c-toolbar__group--center">
<AuDataTableTextSearch @wait={{2000}} @filter={{this.title}} @placeholder={{t 'inbox.agendapoints.searchPlaceholder'}} />
<AuInput @icon="search" @iconAlignment="right" @value={{this.searchValue}} placeholder={{t 'inbox.agendapoints.searchPlaceholder'}} {{on "input" (perform this.updateFilter)}}/>
{{#unless this.readOnly}}
<AuLink @route="inbox.agendapoints.new" @skin="button" @icon="add" @iconAlignment="left">{{t "inbox.agendapoints.new.title"}}</AuLink>
{{/unless}}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/inbox/irg-archive.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</AuHeading>
</Group>
<Group class="au-c-toolbar__group--center">
<AuDataTableTextSearch @wait={{2000}} @filter={{this.title}} @placeholder={{t 'inbox.irgArchive.searchPlaceholder'}} />
<AuInput @icon="search" @iconAlignment="right" @width="block" @value={{this.searchValue}} placeholder={{t 'inbox.irgArchive.searchPlaceholder'}} {{on "input" (perform this.updateFilter)}}/>
</Group>
</AuToolbar>
</menu.general>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint:hbs": "ember-template-lint .",
"lint:errors": "eslint . --quiet",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
Expand Down

0 comments on commit abe274c

Please sign in to comment.