Dynamic segments as query without real models and the #linkTo helper active class


I’m a bit confused about the controllerFor hook and dynamic segments.

I’ve a application where I’ve a 2 layer hirachical navigation, for a search page. So I can search global, or over the first or second layer of the navigation.

First I’ve tried to solve this problem with 3 routes, but then it looked more logical if I use just one. So now I’ve a single Route with 3 dynamic segments '/search/:level1/:level2/:query

I’ve used the model hook to deserialize the dynamic segments into a hash. In the setupController hook I am able to analyse the query, level1 and level2 and provide a “dummy” request-model object to the controller. Depending on the analyse I will also tell the controller to load the search result, or to cleanup.

Then I’ve used the serialize hook to serialize all avaliable data back to a logical url.

To change the query from the controller, I use the transitionToRoute method to transition to myself but with another model. It works fine, but is this a proper way to do that?

Then I’ve kinda abused the serialize and setupController methods, because in my navigation I’ve not the “dummy” request-model, but level1 and level2 navigation objects. So I’ve used the #linkTo helper with theese objects, and catch that in the serialize and setupController methods, where I transform that to a usable model for my controller. This works fine, but looks dirty. whats the canonical way to solve this kind of problems?

Almost everything is working fine, I’m just thinking its not a clean solution, and I’m kinda confused how to use multiple dynamic segments. I would prefer a little documentation how to use this.

The only thing that is not working as requested, is the ‘active’ class on the #linkTo helper. Logal is a solution, where the level1 link is still active, while the nexted level2 link is active. Same for the query, so the level2 link should stay active, and dont change if I set the query.

Whats the recommended way to handle this kind of application structure?

Thanks for any help, and thanks @ember-team for ember