2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 19:39:07 +00:00
books/src/App.vue
Faris Ansari 67e9ce094d refactor: Setup wizard and company setup
- Move setup logic into setupCompany.js
- Set setupComplete field in AccountingSettings
- move connectToLocalDatabase in utils
2020-01-01 13:41:57 +05:30

97 lines
2.5 KiB
Vue

<template>
<div id="app" class="h-screen flex flex-col font-sans overflow-hidden">
<WindowsTitleBar
v-if="['Windows', 'Linux'].includes(platform)"
@close="reloadMainWindowOnSettingsClose"
/>
<Desk class="flex-1" v-if="activeScreen === 'Desk'" />
<DatabaseSelector
v-if="activeScreen === 'DatabaseSelector'"
@database-connect="showSetupWizardOrDesk"
/>
<SetupWizard
v-if="activeScreen === 'SetupWizard'"
@setup-complete="showSetupWizardOrDesk"
/>
<Settings v-if="activeScreen === 'Settings'" />
<portal-target name="popovers" multiple></portal-target>
</div>
</template>
<script>
import './styles/index.css';
import 'frappe-charts/dist/frappe-charts.min.css';
import frappe from 'frappejs';
import Desk from './pages/Desk';
import SetupWizard from './pages/SetupWizard/SetupWizard';
import DatabaseSelector from './pages/DatabaseSelector';
import Settings from '@/pages/Settings/Settings.vue';
import WindowsTitleBar from '@/components/WindowsTitleBar';
import { remote } from 'electron';
import { connectToLocalDatabase } from '@/utils';
export default {
name: 'App',
data() {
return {
activeScreen: null
};
},
watch: {
activeScreen(value) {
if (!value) return;
let size = {
Desk: [1200, 907],
DatabaseSelector: [600, 600],
SetupWizard: [600, 600],
Settings: [460, 577]
}[value];
let resizable = value === 'Desk';
let win = remote.getCurrentWindow();
if (size.length) {
win.setSize(...size);
win.setResizable(resizable);
}
}
},
components: {
Desk,
SetupWizard,
DatabaseSelector,
Settings,
WindowsTitleBar
},
async mounted() {
let dbPath = localStorage.dbPath;
if (!dbPath) {
this.activeScreen = 'DatabaseSelector';
} else {
await connectToLocalDatabase(dbPath);
this.showSetupWizardOrDesk();
}
},
methods: {
showSetupWizardOrDesk() {
const { setupComplete } = frappe.AccountingSettings;
if (!setupComplete) {
this.activeScreen = 'SetupWizard';
} else if (this.$route.path.startsWith('/settings')) {
this.activeScreen = 'Settings';
} else {
this.activeScreen = 'Desk';
this.checkForUpdates();
}
},
reloadMainWindowOnSettingsClose() {
if (this.activeScreen === 'Settings') {
frappe.events.trigger('reload-main-window');
}
},
checkForUpdates() {
frappe.events.trigger('check-for-updates');
}
}
};
</script>