2
0
mirror of https://github.com/frappe/books.git synced 2025-02-02 12:08:27 +00:00

Initialize docs in frappe.init

This commit is contained in:
Faris Ansari 2018-07-14 18:45:21 +05:30
parent cda0bbffc7
commit e9d2f5c2c2
3 changed files with 98 additions and 98 deletions

View File

@ -6,21 +6,21 @@ const homedir = os.homedir();
const configFilePath = path.join(homedir, '.config', 'frappe-accounting', 'settings.json');
function getSettings() {
let settings;
try {
settings = require(configFilePath);
} catch (e) {
settings = {}
}
let settings;
try {
settings = require(configFilePath);
} catch (e) {
settings = {};
}
return settings;
return settings;
}
async function saveSettings(settings) {
await writeFile(configFilePath, JSON.stringify(settings));
await writeFile(configFilePath, JSON.stringify(settings));
}
module.exports = {
getSettings,
saveSettings
}
getSettings,
saveSettings
};

View File

@ -8,10 +8,9 @@ import router from './router';
import frappeVue from 'frappejs/ui/plugins/frappeVue';
// frappejs imports
import io from 'socket.io-client';
import frappe from 'frappejs';
import io from 'socket.io-client';
import HTTPClient from 'frappejs/backends/http';
import Observable from 'frappejs/utils/observable';
import common from 'frappejs/common';
import coreModels from 'frappejs/models';
import models from '../models';
@ -26,8 +25,6 @@ frappe.fetch = window.fetch.bind();
frappe.db = new HTTPClient({ server });
const socket = io.connect(`http://${server}`);
frappe.db.bindSocketClient(socket);
frappe.registerModels(models);
frappe.docs = new Observable();
frappe.getSingle('SystemSettings');
registerReportMethods();

View File

@ -1,36 +1,36 @@
<template>
<div class="setup-wizard d-flex justify-content-center">
<div class="col-4 border rounded shadow-sm p-4 mt-5">
<h4 class="text-center">Setup your account</h4>
<div class="progress-indicator d-flex justify-content-center p-4">
<indicator class="mr-1" :color="indicatorColor(index)" v-for="(section, index) in layout.sections" :key="index" />
</div>
<form-layout
:doc="doc"
:fields="fields"
:layout="layout"
:currentSection="currentSection"
/>
<div class="d-flex justify-content-between">
<div>
<f-button secondary v-if="currentSection > 0"
@click="prevSection">
Prev
</f-button>
</div>
<div>
<f-button primary v-if="currentSection < layout.sections.length - 1"
@click="nextSection">
Next
</f-button>
<f-button primary v-if="currentSection === layout.sections.length - 1"
@click="submit">
Complete
</f-button>
</div>
</div>
<div class="setup-wizard d-flex justify-content-center">
<div class="col-4 border rounded shadow-sm p-4 mt-5">
<h4 class="text-center">Setup your account</h4>
<div class="progress-indicator d-flex justify-content-center p-4">
<indicator class="mr-1" :color="indicatorColor(index)" v-for="(section, index) in layout.sections" :key="index" />
</div>
<form-layout
:doc="doc"
:fields="fields"
:layout="layout"
:currentSection="currentSection"
/>
<div class="d-flex justify-content-between">
<div>
<f-button secondary v-if="currentSection > 0"
@click="prevSection">
Prev
</f-button>
</div>
<div>
<f-button primary v-if="currentSection < layout.sections.length - 1"
@click="nextSection">
Next
</f-button>
<f-button primary v-if="currentSection === layout.sections.length - 1"
@click="submit">
Complete
</f-button>
</div>
</div>
</div>
</div>
</template>
<script>
import frappe from 'frappejs';
@ -40,61 +40,64 @@ import indicatorColor from 'frappejs/ui/constants/indicators';
import setupConfig from './config';
export default {
data() {
return {
currentSection: 0
}
},
components: {
FormLayout
},
created() {
this.doc = new Observable();
},
methods: {
async submit() {
const {
companyName,
country,
name,
email,
abbreviation,
bankName,
fiscalYearStart,
fiscalYearEnd
} = this.doc;
name: 'SetupWizard',
data() {
return {
currentSection: 0
};
},
components: {
FormLayout
},
created() {
this.doc = new Observable();
},
methods: {
async submit() {
const {
companyName,
country,
name,
email,
abbreviation,
bankName,
fiscalYearStart,
fiscalYearEnd
} = this.doc;
const doc = await frappe.getSingle('AccountingSettings');
await doc.set({
companyName,
country,
fullname: name,
email,
bankName,
fiscalYearStart,
fiscalYearEnd
});
await doc.update();
const doc = await frappe.getSingle('AccountingSettings');
await doc.set({
companyName,
country,
fullname: name,
email,
bankName,
fiscalYearStart,
fiscalYearEnd
});
await doc.update();
this.$router.push('/list/ToDo');
},
nextSection() {
this.currentSection += 1;
},
prevSection() {
this.currentSection -= 1;
},
indicatorColor(i) {
return i === this.currentSection ? indicatorColor.BLUE : '';
}
this.$router.push('/list/ToDo');
},
computed: {
fields() {
return setupConfig.fields;
},
layout() {
return setupConfig.layout;
}
nextSection() {
this.currentSection += 1;
},
prevSection() {
this.currentSection -= 1;
},
indicatorColor(i) {
return i === this.currentSection
? indicatorColor.BLUE
: indicatorColor.GREY;
}
}
},
computed: {
fields() {
return setupConfig.fields;
},
layout() {
return setupConfig.layout;
}
}
};
</script>