From e170ab565589ac8a62143afed88bb430762d21a1 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Sun, 15 Jul 2018 17:11:27 +0530 Subject: [PATCH] Sidebar Title - set as companyName - open DatabaseSelector on click --- src/components/DatabaseSelector.vue | 50 +++++++++++++++ src/sidebarConfig.js | 98 ++++++++++++++++++----------- 2 files changed, 110 insertions(+), 38 deletions(-) create mode 100644 src/components/DatabaseSelector.vue diff --git a/src/components/DatabaseSelector.vue b/src/components/DatabaseSelector.vue new file mode 100644 index 00000000..0415bf84 --- /dev/null +++ b/src/components/DatabaseSelector.vue @@ -0,0 +1,50 @@ + + diff --git a/src/sidebarConfig.js b/src/sidebarConfig.js index 2a830cd2..ea9c3a25 100644 --- a/src/sidebarConfig.js +++ b/src/sidebarConfig.js @@ -1,42 +1,64 @@ -const { _ } = require('frappejs/utils'); +import frappe from 'frappejs'; +import { _ } from 'frappejs/utils'; +import DatabaseSelector from './components/DatabaseSelector'; -export default [ - { - items: [ - { - label: _('ToDo'), route: '#/list/ToDo' - }, - { - label: _('Event'), route: '#/list/Event' - } - ] +export default { + async getTitle() { + const accountingSettings = await frappe.getSingle('AccountingSettings'); + return accountingSettings.companyName; }, - { - title: _('Masters'), - items: [ - { - label: _('Item'), route: '#/list/Item' - }, - { - label: _('Party'), route: '#/list/Party' - }, - { - label: _('Invoice'), route: '#/list/Invoice' - }, - { - label: _('Tax'), route: '#/list/Tax' - }, - { - label: _('Account'), route: '#/list/Account' + onTitleClick(vm) { + vm.$modal.show({ + component: DatabaseSelector, + modalProps: { + title: _('Change Database File'), + primaryAction: { + label: _('Submit'), + handler: (vm) => { + vm.changeDatabase(); + } + } } - ] + }); }, - { - title: _('Reports'), - items: [ - { - label: _('General Ledger'), route: '#/report/general-ledger' - } - ] - } -]; + groups: [ + { + items: [ + { + label: _('ToDo'), route: '#/list/ToDo' + }, + { + label: _('Event'), route: '#/list/Event' + } + ] + }, + { + title: _('Masters'), + items: [ + { + label: _('Item'), route: '#/list/Item' + }, + { + label: _('Party'), route: '#/list/Party' + }, + { + label: _('Invoice'), route: '#/list/Invoice' + }, + { + label: _('Tax'), route: '#/list/Tax' + }, + { + label: _('Account'), route: '#/list/Account' + } + ] + }, + { + title: _('Reports'), + items: [ + { + label: _('General Ledger'), route: '#/report/general-ledger' + } + ] + } + ] +};