2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +00:00

Sidebar Title

- set as companyName
- open DatabaseSelector on click
This commit is contained in:
Faris Ansari 2018-07-15 17:11:27 +05:30
parent 4b86558527
commit e170ab5655
2 changed files with 110 additions and 38 deletions

View File

@ -0,0 +1,50 @@
<template>
<form-layout
:fields="[docfield]"
:doc="doc"
/>
</template>
<script>
import frappe from 'frappejs';
// import SQLite from 'frappejs/backends/sqlite';
import FormLayout from 'frappejs/ui/components/Form/FormLayout';
import Observable from 'frappejs/utils/observable';
export default {
name: 'DatabaseSelector',
components: {
FormLayout
},
data() {
return {
docfield: {
fieldtype: 'File',
label: 'Select File',
fieldname: 'file',
filetypes: ['.db']
},
value: null,
invalid: false
}
},
created() {
this.doc = new Observable();
},
methods: {
handleChange(fileList) {
const value = fileList[0].name;
this.value = value;
},
async changeDatabase() {
if (frappe.db) {
frappe.db.close();
}
const dbPath = this.value;
frappe.db = new SQLite({ dbPath });
await frappe.db.connect();
await frappe.db.migrate();
}
}
}
</script>

View File

@ -1,42 +1,64 @@
const { _ } = require('frappejs/utils'); import frappe from 'frappejs';
import { _ } from 'frappejs/utils';
import DatabaseSelector from './components/DatabaseSelector';
export default [ export default {
{ async getTitle() {
items: [ const accountingSettings = await frappe.getSingle('AccountingSettings');
{ return accountingSettings.companyName;
label: _('ToDo'), route: '#/list/ToDo'
},
{
label: _('Event'), route: '#/list/Event'
}
]
}, },
{ onTitleClick(vm) {
title: _('Masters'), vm.$modal.show({
items: [ component: DatabaseSelector,
{ modalProps: {
label: _('Item'), route: '#/list/Item' title: _('Change Database File'),
}, primaryAction: {
{ label: _('Submit'),
label: _('Party'), route: '#/list/Party' handler: (vm) => {
}, vm.changeDatabase();
{ }
label: _('Invoice'), route: '#/list/Invoice' }
},
{
label: _('Tax'), route: '#/list/Tax'
},
{
label: _('Account'), route: '#/list/Account'
} }
] });
}, },
{ groups: [
title: _('Reports'), {
items: [ items: [
{ {
label: _('General Ledger'), route: '#/report/general-ledger' 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'
}
]
}
]
};