2
0
mirror of https://github.com/frappe/books.git synced 2024-12-24 20:00:29 +00:00
books/src/App.vue

81 lines
1.6 KiB
Vue
Raw Normal View History

2018-06-01 12:35:51 +00:00
<template>
<div id="app">
<frappe-desk v-if="showDesk">
<router-view />
2018-06-01 12:35:51 +00:00
</frappe-desk>
<router-view v-else name="setup" />
2018-06-15 15:46:45 +00:00
<frappe-modal ref="modal" :show="showModal" v-bind="modalOptions" @close-modal="showModal = false"/>
2018-06-01 12:35:51 +00:00
</div>
</template>
<script>
import Vue from 'vue';
import Observable from 'frappejs/utils/observable';
2018-06-01 12:35:51 +00:00
import Desk from '@/components/Desk';
import Modal from '@/components/Modal';
const Bus = new Observable();
Vue.use({
// enable use of this.$modal in every component
// this also keeps only one modal in the DOM at any time
// which is the recommended way by bootstrap
install (Vue) {
Vue.prototype.$modal = {
show(options) {
Bus.trigger('showModal', options);
},
hide() {
Bus.trigger('hideModal');
}
}
}
});
2018-06-01 12:35:51 +00:00
export default {
name: 'App',
data() {
return {
showDesk: true,
showModal: false,
modalOptions: {}
}
},
2018-06-01 12:35:51 +00:00
components: {
FrappeDesk: Desk,
FrappeModal: Modal
},
async beforeRouteUpdate(to, from, next) {
const accountingSettings = await frappe.getSingle('AccountingSettings');
if (accountingSettings.companyName) {
this.showDesk = true;
} else {
this.showDesk = true;
}
},
mounted() {
Bus.on('showModal', (options = {}) => {
this.showModal = true;
this.modalOptions = options;
});
Bus.on('hideModal', () => {
this.showModal = false;
});
window.frappeModal = this.$modal;
2018-06-01 12:35:51 +00:00
}
}
</script>
<style lang="scss">
@import "~bootstrap/scss/bootstrap";
2018-06-11 11:20:34 +00:00
@import '~frappe-datatable/dist/frappe-datatable';
2018-06-01 12:35:51 +00:00
html {
font-size: 14px;
}
</style>