I'm not very good with iron-pages and app-route so I will try and explain this the best I can.
I am building a web application with two main "apps" built into it - the regular user interface and an admin dashboard. So naturally I would want two different main 'paths': /admin
and /home
The admin dashboard should have a drawer in it, where I can select from a list of 'categories' and upon selecting a category, load a specific view. Example /admin/users
will load a view that will load a list of users. And upon clicking on an item on the list page, bring up a details section. Example /admin/user/UserA
Here is my structure so far. demo-app has iron-pages that holds the HomePage and AdminPage. AdminPage also has iron-pages that holds ListView and DetailView.
I can get to the admin page, but upon selecting from a list of 'categories', the route doesn't pick up. I'm basing my code off of the Shop Demo
demo-app
<app-location route="{{route}}"></app-location>
<app-route
route="{{route}}"
pattern="/:page"
data="{{routeData}}"
tail="{{subroute}}"></app-route>
<iron-media-query query="max-width: 767px" query-matches="{{smallScreen}}"></iron-media-query>
<app-header role="navigation" id="header" effects="waterfall" condenses reveals>
<app-toolbar>
</app-toolbar>
</app-header>
<iron-pages role="main" selected="[[page]]" attr-for-selected="name" selected-attribute="visible" fallback-selection="404">
<!-- home view -->
<demo-home name="home"></demo-home>
<!-- admin view -->
<demo-admin name="admin"></demo-admin>
<shop-404-warning name="404"></shop-404-warning>
</iron-pages>
demo-admin
<app-route
route="{{route}}"
pattern="/admin"
data="{{routeData}}"
tail="{{subroute}}"></app-route>
<h1>Admin</h1>
<ul>
<li><a href="/admin/users">Users</a></li>
<li><a href="/admin/bars">Bars</a></li>
<li><a href="/admin/stepsheets">Stepsheets</a></li>
<li><a href="/admin/events">Events</a></li>
</ul>
<p>subroute: [[subroute]]</p>
<iron-pages role="main" selected="{{subroute.path}}" attr-for-selected="name" selected-attribute="visible" fallback-selection="404">
<demo-list name="list" route="{{subroute}}"></demo-list>
</iron-pages>
</template>
demo-list
<app-route
route="[[route]]"
pattern="/admin/:collection"
data="{{routeData}}"></app-route>
<h1>Collection: [[routeData.collection]]</h1>
EDIT I might be onto something...
<app-location route="{{route}}"></app-location>
<app-route
route="{{route}}"
pattern="/:page"
data="{{routeData}}"
tail="{{subroute}}"></app-route>
<app-route
route="{{subroute}}"
pattern="/:category"
data="{{subrouteData}}"></app-route>
and then
static get observers() { return [
'_routePageChanged(routeData.page)',
'_routeCategoryChanged(subrouteData.category)'
]}
Not sure if this is the right way to do it? I feel like this would get very cumbersome if I had a url with 3+ subroutes
In
demo-admin
the routeris probably not working as expected because
demo-app
'sroute
property is not accessible insidedemo-admin
. Alsopatterm="/admin"
is redundant: ifdemo-admin
is being loaded then the url is already/admin
.You can pass
demo-app
'ssubroute
property to child views who need to parse sub routes:demo-app.html
demo-admin.html
Find more info in
app-route
's documentation.