From 54616ef926834af4e90260c3c3139e044ccd7e70 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 23 Dec 2019 13:56:41 +0530 Subject: [PATCH] fix: Add Chart of Accounts to sidebar --- src/components/Sidebar.vue | 14 +++++++++++--- src/router.js | 2 +- src/sidebarConfig.js | 17 +++++++++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index f499a9ba..df81fe54 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -35,7 +35,7 @@ :key="item.label" class="mt-1 first:mt-0 text-base text-gray-800 py-1 pl-10 rounded cursor-pointer hover:bg-white" :class="itemActiveClass(item)" - @click="routeTo(item.route)" + @click="onItemClick(item)" > {{ item.label }} @@ -91,9 +91,9 @@ export default { }, methods: { itemActiveClass(item) { - let currentRoute = this.$route.path; + let { path: currentRoute, params } = this.$route; let routeMatch = currentRoute === item.route; - let doctypeMatch = this.$route.params.doctype === item.doctype; + let doctypeMatch = item.doctype && params.doctype === item.doctype; return routeMatch || doctypeMatch ? 'bg-white text-blue-500' : ''; }, isActiveGroup(group) { @@ -108,6 +108,14 @@ export default { } this.activeGroup = group; }, + onItemClick(item) { + if (item.action) { + item.action(); + } + if (item.route) { + this.routeTo(item.route); + } + }, routeTo(route) { this.$router.push(route); } diff --git a/src/router.js b/src/router.js index e02439d6..50c83d40 100644 --- a/src/router.js +++ b/src/router.js @@ -87,7 +87,7 @@ const routes = [ props: true }, { - path: '/chartOfAccounts', + path: '/chart-of-accounts', name: 'Chart Of Accounts', components: { default: ChartOfAccounts, diff --git a/src/sidebarConfig.js b/src/sidebarConfig.js index ce6a17b2..14224905 100644 --- a/src/sidebarConfig.js +++ b/src/sidebarConfig.js @@ -114,11 +114,20 @@ const config = { ] }, { - title: _('Settings'), + title: _('Setup'), icon: getIcon('settings'), - action() { - openSettings(); - } + items: [ + { + label: _('Chart of Accounts'), + route: '/chart-of-accounts' + }, + { + label: _('Settings'), + action() { + openSettings(); + } + } + ] } ] };