Href for route with multiple parameters

I have some routes like so:

{
   route: "/sessions/:sid?",
   nav: true,
   name: "sessions",
   moduleId: ...,
   href: "/sessions"
},
{
   route: "/sessions/:sid/jurors",
   nav: false,
   name: "sessionjurors",
   moduleId: ...
},
{
   route: "/sessions/:sid/cases/:cid?",
   nav: false,
   name: "cases",
   moduleId: ...
}

Notice the last route – “cases”. My understanding is that because I have an optional parameter, I’m also required to provide an href value (like I did with “sessions”). However, the “base” href value requires a session id (sid).

Is there a way to configure this or get this working with Aurelia routing?

Note
Incidentally, I tried doing the following:

...
{ 
   route: "/sessions/:sid/cases/:cid?",
   name: "cases",
   nav: false,
   moduleId: ...,
   href: "/sessions"
},
{
   route: "/sessions/:sid/cases/:cid/jurors",
   name: "casejurors",
   nav: false,
   moduleId: ...
}

Notice the base href set to “sessions”. This satisfied the need for the href, but it failed when trying to navigate from casejurors back to cases. The navigation acted really weird. The first click of the back arrow left me sitting at casejurors. The second click of the back arrow took me all the way back to sessions instead of to cases.

2 Likes

I don’t think I can help, but I’d like to understand the use cases here. If we look at it from a module/component perspective, is it
1a) sessions, AND
1b) session(sid)
,
2) session(sid)/jurors [as in two components in parent-child viewports]
OR
2) session-jurors(sid) [one component]
,
3a) session(sid)/cases, AND
3b) session(sid)/case(cid) [two components, parent-child viewports]
OR
3a) session-cases(sid), AND
3b) session-case(sid, cid) [one component]
?

1 Like