fix: Page container routing

This commit is contained in:
Faris Ansari 2018-08-30 14:36:05 +05:30
parent 062cd62484
commit 90265aec24

View File

@ -58,7 +58,6 @@ export default {
get_current_page() {
const curr_route = frappe.get_route_str();
let route = Object.keys(route_map).filter(route => route == curr_route)[0];
if (!route) {
// find route by matching it with dynamic part
const curr_route_parts = curr_route.split('/');
@ -70,7 +69,7 @@ export default {
let weight = 0;
route_parts.forEach((part, i) => {
const curr_route_part = curr_route_parts[i];
if (part === curr_route_part || curr_route_part.includes(':')) {
if (part === curr_route_part || part.includes(':')) {
weight += 1;
}
});
@ -80,12 +79,13 @@ export default {
}, {});
// get the route with the highest weight
let weight = 0
for (let key in weighted_routes) {
const route_weight = weighted_routes[key];
if (route_weight > weight) {
if (route_weight === curr_route_parts.length) {
route = key;
weight = route_weight;
break;
} else {
route = null;
}
}
}