2018-06-01 12:35:51 +00:00
|
|
|
<template>
|
|
|
|
<div id="app">
|
2018-06-11 09:46:25 +00:00
|
|
|
<frappe-desk v-if="showDesk">
|
2018-06-04 09:30:12 +00:00
|
|
|
<router-view />
|
2018-06-01 12:35:51 +00:00
|
|
|
</frappe-desk>
|
2018-06-11 09:46:25 +00:00
|
|
|
<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>
|
2018-06-13 09:14:51 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Observable from 'frappejs/utils/observable';
|
2018-06-01 12:35:51 +00:00
|
|
|
import Desk from '@/components/Desk';
|
2018-06-13 09:14:51 +00:00
|
|
|
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',
|
2018-06-11 09:46:25 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2018-06-13 09:14:51 +00:00
|
|
|
showDesk: true,
|
|
|
|
showModal: false,
|
|
|
|
modalOptions: {}
|
2018-06-11 09:46:25 +00:00
|
|
|
}
|
|
|
|
},
|
2018-06-01 12:35:51 +00:00
|
|
|
components: {
|
2018-06-13 09:14:51 +00:00
|
|
|
FrappeDesk: Desk,
|
|
|
|
FrappeModal: Modal
|
2018-06-11 09:46:25 +00:00
|
|
|
},
|
|
|
|
async beforeRouteUpdate(to, from, next) {
|
|
|
|
const accountingSettings = await frappe.getSingle('AccountingSettings');
|
|
|
|
if (accountingSettings.companyName) {
|
|
|
|
this.showDesk = true;
|
|
|
|
} else {
|
|
|
|
this.showDesk = true;
|
|
|
|
}
|
2018-06-13 09:14:51 +00:00
|
|
|
},
|
|
|
|
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>
|