mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] router: replace t-routecomponent directive by RouteComponent
closes #287
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { Component } from "../component/component";
|
||||
|
||||
export const ROUTE_COMPONENT_TEMPLATE_NAME = "__owl__-router-component";
|
||||
export const ROUTE_COMPONENT_TEMPLATE = `
|
||||
<t t-foreach="routes" t-as="route">
|
||||
<t t-if="env.router.currentRouteName === route.name">
|
||||
<t t-component="{{route.component}}" t-props="env.router.currentParams"/>
|
||||
</t>
|
||||
</t>`;
|
||||
|
||||
export class RouteComponent extends Component<any, {}, {}> {
|
||||
template = ROUTE_COMPONENT_TEMPLATE_NAME;
|
||||
routes: any[] = [];
|
||||
constructor(parent, props) {
|
||||
super(parent, props);
|
||||
const router = this.env.router;
|
||||
for (let name of router.routeIds) {
|
||||
const route = router.routes[name];
|
||||
if (route.component) {
|
||||
this.routes.push({
|
||||
name: route.name,
|
||||
component: "__component__" + route.name
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user