Refactor on SearchBar
parent
1dc969bfb1
commit
2fb749875a
|
@ -69,19 +69,18 @@ export default {
|
||||||
this.menuService.getMenu().then(data => {
|
this.menuService.getMenu().then(data => {
|
||||||
this.menu = data;
|
this.menu = data;
|
||||||
|
|
||||||
this.routes = data.reduce((routeArray,route) => {
|
data.forEach((route) => {
|
||||||
route.children = route.children.filter((childRoute) => {
|
let childRoute = route;
|
||||||
|
childRoute = childRoute.children.filter((childRoute) => {
|
||||||
if (childRoute.meta) {
|
if (childRoute.meta) {
|
||||||
routeArray.push(childRoute);
|
this.routes.push(childRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !childRoute.meta;
|
return !childRoute.meta;
|
||||||
})
|
})
|
||||||
|
|
||||||
routeArray.push(route);
|
this.routes.push(route);
|
||||||
|
});
|
||||||
return routeArray;
|
|
||||||
}, []);
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -107,7 +106,7 @@ export default {
|
||||||
for (let route of this.routes) {
|
for (let route of this.routes) {
|
||||||
let filteredItems = FilterService.filter(route.children, ['to', 'href'], query, FilterMatchMode.CONTAINS);
|
let filteredItems = FilterService.filter(route.children, ['to', 'href'], query, FilterMatchMode.CONTAINS);
|
||||||
if (filteredItems && filteredItems.length) {
|
if (filteredItems && filteredItems.length) {
|
||||||
filteredRoutes.push({...route, ...{items: filteredItems}});
|
filteredRoutes.push({name: route.name, children: filteredItems});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue