Add redirect to parent when filter excludes all
This commit is contained in:
parent
7ed1f4dda8
commit
3ef7f9f89e
|
@ -182,6 +182,15 @@ export default class OptimizeController extends Controller {
|
|||
this.ensureActiveSummaryIsNotExcluded();
|
||||
}
|
||||
|
||||
@action
|
||||
transitionToFirstSummary() {
|
||||
const firstFilteredSummary = this.filteredSummaries.objectAt(0);
|
||||
|
||||
if (firstFilteredSummary) {
|
||||
this.transitionToSummary(firstFilteredSummary);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
ensureActiveSummaryIsNotExcluded() {
|
||||
scheduleOnce('actions', () => {
|
||||
|
@ -190,6 +199,8 @@ export default class OptimizeController extends Controller {
|
|||
|
||||
if (firstFilteredSummary) {
|
||||
this.transitionToSummary(firstFilteredSummary);
|
||||
} else {
|
||||
this.transitionToRoute('optimize');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class OptimizeIndexRoute extends Route {
|
||||
async redirect() {
|
||||
const summaries = this.modelFor('optimize');
|
||||
async activate() {
|
||||
// This runs late in the loading lifecycle to ensure .filteredSummaries is populated
|
||||
const summaries = this.controllerFor('optimize').filteredSummaries;
|
||||
|
||||
if (summaries.length) {
|
||||
const firstSummary = summaries.objectAt(0);
|
||||
|
|
|
@ -411,6 +411,7 @@ module('Acceptance | optimize search and facets', function(hooks) {
|
|||
assert.notOk(Optimize.card.isPresent);
|
||||
assert.ok(Optimize.empty.isPresent);
|
||||
assert.equal(Optimize.empty.headline, 'No Matches');
|
||||
assert.equal(currentURL(), '/optimize?search=qqq');
|
||||
});
|
||||
|
||||
test('processing a summary moves to the next one in the sorted list', async function(assert) {
|
||||
|
|
Loading…
Reference in a new issue