2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 14:50:56 +00:00
This commit is contained in:
Rushabh Mehta 2018-01-30 18:56:35 +05:30
parent 7f519fa29d
commit d1e7533475
7 changed files with 94 additions and 69 deletions

9
.gitignore vendored
View File

@ -4,11 +4,4 @@ Thumbs.db
test.db
*.log
.cache
/dist
/temp
# ignore everything in 'app' folder what had been generated from 'src' folder
/app/app.js
/app/background.js
/app/**/*.map
/temp

View File

View File

@ -1,3 +1,4 @@
var desk = (function () {
'use strict';
const number_formats = {
@ -2260,6 +2261,67 @@ var form = class BaseForm {
};
var view = {
get_form_class(doctype) {
return this.get_view_class(doctype, 'Form', form);
},
get_list_class(doctype) {
return this.get_view_class(doctype, 'List', list);
},
get_view_class(doctype, class_name, default_class) {
let client_module = this.get_client_module(doctype);
if (client_module && client_module[class_name]) {
return client_module[class_name];
} else {
return default_class;
}
},
get_client_module(doctype) {
return frappe.modules[`${doctype}_client`];
}
};
var formpage = class FormPage extends page {
constructor(doctype) {
let meta = frappe.get_meta(doctype);
super(`Edit ${meta.name}`);
this.meta = meta;
this.form = new (view.get_form_class(doctype))({
doctype: doctype,
parent: this.body
});
this.on('show', async (params) => {
await this.show_doc(params.doctype, params.name);
});
}
async show_doc(doctype, name) {
try {
this.doc = await frappe.get_doc(doctype, name);
this.form.use(this.doc);
} catch (e) {
this.render_error(e.status_code, e.message);
}
}
};
var listpage = class FormPage extends page {
constructor(doctype) {
let meta = frappe.get_meta(doctype);
super(`List ${meta.name}`);
this.list = new (view.get_list_class(doctype))({
doctype: doctype,
parent: this.body
});
this.on('show', async () => {
await this.list.run();
});
}
};
var navbar = class Navbar {
constructor({brand_label = 'Home'} = {}) {
Object.assign(this, arguments[0]);
@ -2355,53 +2417,18 @@ var desk = class Desk {
get_list_page(doctype) {
if (!this.pages.lists[doctype]) {
let page$$1 = new page('List ' + frappejs.get_meta(doctype).name);
page$$1.list = new (this.get_view_class(doctype, 'List', list))({
doctype: doctype,
parent: page$$1.body
});
page$$1.on('show', async () => {
await page$$1.list.run();
});
this.pages.lists[doctype] = page$$1;
this.pages.lists[doctype] = new listpage(doctype);
}
return this.pages.lists[doctype];
}
get_form_page(doctype) {
if (!this.pages.forms[doctype]) {
let page$$1 = new page('Edit ' + frappejs.get_meta(doctype).name);
page$$1.form = new (this.get_view_class(doctype, 'Form', form))({
doctype: doctype,
parent: page$$1.body
});
page$$1.on('show', async (params) => {
try {
page$$1.doc = await frappejs.get_doc(params.doctype, params.name);
page$$1.form.use(page$$1.doc);
} catch (e) {
page$$1.render_error(e.status_code, e.message);
}
});
this.pages.forms[doctype] = page$$1;
this.pages.forms[doctype] = new formpage(doctype);
}
return this.pages.forms[doctype];
}
get_view_class(doctype, class_name, default_class) {
let client_module = this.get_client_module(doctype);
if (client_module && client_module[class_name]) {
return client_module[class_name];
} else {
return default_class;
}
}
get_client_module(doctype) {
return frappejs.modules[`${doctype}_client`];
}
add_sidebar_item(label, action) {
let item = frappejs.ui.add('a', '', frappejs.ui.add('p', null, frappejs.desk.sidebar));
item.textContent = label;
@ -2583,7 +2610,6 @@ class ToDoList extends list {
}
var todo_client = {
Form: form,
List: ToDoList
};
@ -2615,7 +2641,6 @@ var account_client = {
List: AccountList
};
// start server
client.start({
server: 'localhost:8000',
container: document.querySelector('.wrapper'),
@ -2637,8 +2662,8 @@ client.start({
frappe.router.show(window.location.hash);
});
var frappeTodo = {
var src = false;
};
return src;
module.exports = frappeTodo;
}());

View File

@ -4,8 +4,9 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="/dist/css/style.css" rel="stylesheet">
</head>
<body>
<script src="js/bundle.js"></script>
<script src="/dist/js/bundle.js"></script>
</body>
</html>

View File

@ -0,0 +1,16 @@
{
"name": "Customer",
"doctype": "DocType",
"issingle": 0,
"istable": 0,
"keyword_fields": [
],
"fields": [
{
"fieldname": "name",
"label": "Name",
"fieldtype": "Data",
"reqd": 1
}
]
}

View File

@ -1,16 +1,4 @@
module.exports = [
require('frappejs/config/rollup.config.style.js'),
{
input: './index.js',
output: {
file: './js/bundle.js',
format: 'cjs'
},
plugins: [
require('rollup-plugin-commonjs')(),
require('rollup-plugin-json')(),
require('rollup-plugin-node-resolve')(),
require('rollup-plugin-node-builtins')()
]
}
require('frappejs/config/rollup.config.style.js'),
require('frappejs/config/rollup.config.app.js')
]

View File

@ -8,10 +8,10 @@ client.start({
// require modules
frappe.modules.todo = require('frappejs/models/doctype/todo/todo.js');
frappe.modules.account = require('./models/doctype/account/account.js');
frappe.modules.item = require('./models/doctype/item/item.js');
frappe.modules.account = require('../models/doctype/account/account.js');
frappe.modules.item = require('../models/doctype/item/item.js');
frappe.modules.todo_client = require('frappejs/models/doctype/todo/todo_client.js');
frappe.modules.account_client = require('./models/doctype/account/account_client.js');
frappe.modules.account_client = require('../models/doctype/account/account_client.js');
frappe.desk.add_sidebar_item('ToDo', '#list/todo');
frappe.desk.add_sidebar_item('Accounts', '#list/account');
@ -20,4 +20,6 @@ client.start({
frappe.router.default = '#list/todo';
frappe.router.show(window.location.hash);
});
});
module.exports = false;