mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
commit
2be57c6f4c
@ -21,8 +21,8 @@ module.exports = {
|
||||
frappe.syncDoc(require('../fixtures/invoicePrint'));
|
||||
|
||||
// init naming series if missing
|
||||
await naming.createNumberSeries('INV-', 'InvoiceSetting');
|
||||
await naming.createNumberSeries('PAY-', 'PaymentSetting');
|
||||
await naming.createNumberSeries('INV-', 'InvoiceSettings');
|
||||
await naming.createNumberSeries('PAY-', 'PaymentSettings');
|
||||
|
||||
frappe.registerMethod({
|
||||
method: 'general-ledger',
|
||||
|
55
setup/config.js
Normal file
55
setup/config.js
Normal file
@ -0,0 +1,55 @@
|
||||
module.exports = [
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
"fieldname": "country",
|
||||
"label": "Country",
|
||||
"fieldtype": "Data",
|
||||
"required": 1
|
||||
}
|
||||
],
|
||||
title: 'Select Country'
|
||||
},
|
||||
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
"fieldname": "name",
|
||||
"label": "Name",
|
||||
"fieldtype": "Data",
|
||||
"required": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "email",
|
||||
"label": "Email",
|
||||
"fieldtype": "Data",
|
||||
"required": 1
|
||||
}
|
||||
],
|
||||
title: 'Add a Profile'
|
||||
},
|
||||
|
||||
{
|
||||
fields: [
|
||||
{
|
||||
"fieldname": "companyName",
|
||||
"label": "Company Name",
|
||||
"fieldtype": "Data",
|
||||
"required": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "abbreviation",
|
||||
"label": "Abbreviation",
|
||||
"fieldtype": "Data",
|
||||
"required": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "bankName",
|
||||
"label": "Bank Name",
|
||||
"fieldtype": "Data",
|
||||
"required": 1
|
||||
}
|
||||
],
|
||||
title: 'Add your Company'
|
||||
}
|
||||
]
|
135
setup/index.js
Normal file
135
setup/index.js
Normal file
@ -0,0 +1,135 @@
|
||||
const frappe = require('frappejs');
|
||||
const utils = require('frappejs/client/ui/utils');
|
||||
const slideConfigs = require('./config');
|
||||
const Tree = require('frappejs/client/ui/tree');
|
||||
const FormLayout = require('frappejs/client/view/formLayout');
|
||||
|
||||
module.exports = class SetupWizard {
|
||||
constructor({postSetup = () => {}}) {
|
||||
this.slideList = [];
|
||||
this.indicatorList = [];
|
||||
this.footerLinks = {};
|
||||
|
||||
this.currentIndex = 0;
|
||||
this.data = {};
|
||||
|
||||
this.postSetup = postSetup;
|
||||
this.make();
|
||||
|
||||
this.showSlide(this.currentIndex);
|
||||
}
|
||||
|
||||
make() {
|
||||
let body = document.querySelector('body');
|
||||
this.container = frappe.ui.add('form', 'setup-container container', body);
|
||||
this.$indicators = frappe.ui.add('div', 'indicators vertical-margin align-center', this.container);
|
||||
|
||||
this.makeSlides();
|
||||
this.makeLinks();
|
||||
}
|
||||
|
||||
makeSlides() {
|
||||
slideConfigs.forEach(config => {
|
||||
this.formLayout = new FormLayout(config);
|
||||
this.slideList.push(this.formLayout);
|
||||
let form = this.formLayout.form;
|
||||
this.container.appendChild(form);
|
||||
|
||||
let title = frappe.ui.create('h3', {
|
||||
className: 'text-extra-muted',
|
||||
innerHTML: config.title
|
||||
})
|
||||
form.insertBefore(title, form.firstChild);
|
||||
|
||||
let indicator = frappe.ui.create('span', {
|
||||
inside: this.$indicators,
|
||||
className: 'indicator gray'
|
||||
})
|
||||
this.indicatorList.push(indicator);
|
||||
});
|
||||
}
|
||||
|
||||
makeLinks() {
|
||||
this.linkArea = frappe.ui.add('div', 'setup-link-area align-right', this.container);
|
||||
|
||||
// this.formLayout.on('change', () => {
|
||||
// const show = this.doc._dirty && !this.doc.submitted;
|
||||
// this.saveButton.classList.toggle('hide', !show);
|
||||
// });
|
||||
|
||||
this.getFooterLinks().map(link => {
|
||||
let $link = utils.addLink(link.label, this.linkArea, () => {
|
||||
this.buildData();
|
||||
link.action(this.data);
|
||||
});
|
||||
this.footerLinks[link.name] = $link;
|
||||
})
|
||||
}
|
||||
|
||||
buildData() {
|
||||
this.data = {};
|
||||
this.slideList.forEach(slide => {
|
||||
Object.assign(this.data, slide.doc);
|
||||
});
|
||||
}
|
||||
|
||||
showSlide(index) {
|
||||
utils.activate(this.container, this.slideList[index].form, 'form-body', 'active');
|
||||
this.slideList[index].controlList[0].input.blur();
|
||||
this.activateIndicator(index);
|
||||
this.showFooterLinks(index);
|
||||
this.currentIndex = index;
|
||||
}
|
||||
|
||||
prevSlide() {
|
||||
this.showSlide(this.currentIndex - 1);
|
||||
}
|
||||
|
||||
nextSlide() {
|
||||
this.showSlide(this.currentIndex + 1);
|
||||
}
|
||||
|
||||
activateIndicator(index) {
|
||||
this.indicatorList.forEach(indicator => {indicator.classList.add('gray')});
|
||||
let indicator = this.indicatorList[index];
|
||||
utils.activate(this.$indicators, indicator, 'gray', 'blue', index);
|
||||
|
||||
frappe.ui.removeClass(indicator, 'gray');
|
||||
indicator.classList.remove('gray');
|
||||
}
|
||||
|
||||
showFooterLinks(index) {
|
||||
let mat = [1, 1, 0]
|
||||
if(index === 0) {
|
||||
mat = [0, 1, 0];
|
||||
} else if (index === this.slideList.length - 1) {
|
||||
mat = [1, 0, 1];
|
||||
}
|
||||
this.showHideLinks(mat);
|
||||
}
|
||||
|
||||
showHideLinks(matrix = [1, 1, 0]) {
|
||||
let linkNames = this.getFooterLinks().map(link => link.name);
|
||||
matrix.forEach((value, i) => {
|
||||
const fn = value ? 'remove' : 'add';
|
||||
this.footerLinks[linkNames[i]].classList[fn]('hide');
|
||||
});
|
||||
}
|
||||
|
||||
getFooterLinks() {
|
||||
return [
|
||||
{
|
||||
label: 'Prev', name: 'prev',
|
||||
action: this.prevSlide.bind(this)
|
||||
},
|
||||
{
|
||||
label: 'Next', name: 'next',
|
||||
action: this.nextSlide.bind(this)
|
||||
},
|
||||
{
|
||||
label: 'Complete', name: 'complete',
|
||||
action: this.postSetup.bind(this)
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
22
www/dist/css/style.css
vendored
22
www/dist/css/style.css
vendored
@ -7486,3 +7486,25 @@ html {
|
||||
mark {
|
||||
padding: none;
|
||||
background: inherit; }
|
||||
.align-right {
|
||||
text-align: right; }
|
||||
.align-center {
|
||||
text-align: center; }
|
||||
.btn-sm, .btn-group-sm > .btn {
|
||||
margin: 0.25rem; }
|
||||
.vertical-margin {
|
||||
margin: 1rem 0px; }
|
||||
.setup-container {
|
||||
margin: 40px auto;
|
||||
padding: 20px 0px;
|
||||
width: 450px;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 4px; }
|
||||
.setup-container h3 {
|
||||
text-align: center; }
|
||||
.setup-container .form-body {
|
||||
display: none; }
|
||||
.setup-container .form-body.active {
|
||||
display: block; }
|
||||
.setup-container .setup-link-area {
|
||||
margin: 0.25rem 2rem; }
|
||||
|
1196
www/dist/js/bundle.js
vendored
1196
www/dist/js/bundle.js
vendored
File diff suppressed because it is too large
Load Diff
14
www/index.js
14
www/index.js
@ -1,11 +1,21 @@
|
||||
const client = require('frappejs/client');
|
||||
const appClient = require('../client');
|
||||
const SetupWizard = require('../setup');
|
||||
|
||||
// start server
|
||||
client.start({
|
||||
columns: 3,
|
||||
server: 'localhost:8000'
|
||||
server: 'localhost:8000',
|
||||
makeDesk: 0
|
||||
}).then(() => {
|
||||
// new SetupWizard({
|
||||
// postSetup: async (data) => {
|
||||
// client.makeDesk(3);
|
||||
// appClient.start();
|
||||
|
||||
// await frappe.router.setRoute('list', 'ToDo');
|
||||
// }
|
||||
// });
|
||||
client.makeDesk(3);
|
||||
appClient.start();
|
||||
});
|
||||
|
||||
|
27
yarn.lock
27
yarn.lock
@ -1486,9 +1486,13 @@ fragment-cache@^0.2.1:
|
||||
dependencies:
|
||||
map-cache "^0.2.2"
|
||||
|
||||
"frappe-datatable@link:../datatable":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
frappe-datatable@^0.0.3:
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/frappe-datatable/-/frappe-datatable-0.0.3.tgz#55d3fd7bafdf2a7380efab2ae2aaaa956624fca0"
|
||||
dependencies:
|
||||
clusterize.js "^0.18.0"
|
||||
lodash "^4.17.5"
|
||||
sortablejs "^1.7.0"
|
||||
|
||||
"frappejs@link:../frappejs":
|
||||
version "0.0.0"
|
||||
@ -2826,7 +2830,7 @@ oauth-sign@~0.8.1, oauth-sign@~0.8.2:
|
||||
version "0.8.2"
|
||||
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"
|
||||
|
||||
object-assign@^4.0.1, object-assign@^4.1.0:
|
||||
object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
|
||||
@ -2861,6 +2865,12 @@ object.pick@^1.3.0:
|
||||
dependencies:
|
||||
isobject "^3.0.1"
|
||||
|
||||
octicons@^7.2.0:
|
||||
version "7.2.0"
|
||||
resolved "https://registry.yarnpkg.com/octicons/-/octicons-7.2.0.tgz#a721635f73c774d7ffda56a83a29dbde03fc4b53"
|
||||
dependencies:
|
||||
object-assign "^4.1.1"
|
||||
|
||||
on-finished@~2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"
|
||||
@ -3943,6 +3953,15 @@ rollup-plugin-sass@^0.5.3:
|
||||
node-sass ">= 3.8.0"
|
||||
rollup-pluginutils ">= 1.3.1"
|
||||
|
||||
rollup-plugin-sass@^0.6.0:
|
||||
version "0.6.0"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-sass/-/rollup-plugin-sass-0.6.0.tgz#7d490827f395db4b5252485c45cc1a39da88901b"
|
||||
dependencies:
|
||||
babel-runtime "^6.23.0"
|
||||
fs-extra "^0.30.0"
|
||||
node-sass ">= 3.8.0"
|
||||
rollup-pluginutils ">= 1.3.1"
|
||||
|
||||
"rollup-pluginutils@>= 1.3.1", rollup-pluginutils@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.0.1.tgz#7ec95b3573f6543a46a6461bd9a7c544525d0fc0"
|
||||
|
Loading…
Reference in New Issue
Block a user