Refactor on SearchBar

pull/1021/head
Yiğit FINDIKLI 2021-02-18 12:08:30 +03:00
parent 1dc969bfb1
commit 2fb749875a
1 changed files with 7 additions and 8 deletions

View File

@ -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});
} }
} }