mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
[refactor] account views
This commit is contained in:
parent
7d3f27ef7d
commit
7885ddb68b
9
index.js
9
index.js
@ -7,11 +7,12 @@ client.start({
|
||||
server: 'localhost:8000',
|
||||
container: document.querySelector('.wrapper'),
|
||||
}).then(() => {
|
||||
frappe.todo_module = require('frappejs/models/doctype/todo/todo.js');
|
||||
frappe.account_module = require('./models/doctype/account/account.js');
|
||||
|
||||
frappe.init_controller('account', frappe.account_module);
|
||||
frappe.init_controller('todo', frappe.todo_module);
|
||||
// require modules
|
||||
frappe.modules.todo = require('frappejs/models/doctype/todo/todo.js');
|
||||
frappe.modules.account = require('./models/doctype/account/account.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.desk.add_sidebar_item('ToDo', '#list/todo');
|
||||
frappe.desk.add_sidebar_item('Accounts', '#list/account');
|
||||
|
1660
js/bundle.js
1660
js/bundle.js
File diff suppressed because one or more lines are too long
@ -1,27 +1,14 @@
|
||||
const frappe = require('frappejs');
|
||||
const BaseMeta = require('frappejs/model/meta');
|
||||
const BaseDocument = require('frappejs/model/document');
|
||||
|
||||
class account_meta extends frappe.meta.Meta {
|
||||
class AccountMeta extends BaseMeta {
|
||||
setup_meta() {
|
||||
Object.assign(this, require('./account.json'));
|
||||
this.list_options.fields = ['name', 'account_type'];
|
||||
this.setup_links();
|
||||
}
|
||||
|
||||
setup_links() {
|
||||
this.get_field('parent_account').get_filters = function(query) {
|
||||
return {
|
||||
keywords: ["like", query],
|
||||
name: ["!=", this.form.doc.name]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get_row_html(data) {
|
||||
return `<a href="#edit/account/${data.name}">${data.name} (${data.account_type})</a>`;
|
||||
}
|
||||
}
|
||||
|
||||
class account extends frappe.document.Document {
|
||||
class Account extends BaseDocument {
|
||||
setup() {
|
||||
this.add_handler('validate');
|
||||
}
|
||||
@ -36,4 +23,7 @@ class account extends frappe.document.Document {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {account:account, account_meta:account_meta};
|
||||
module.exports = {
|
||||
Document: Account,
|
||||
Meta: AccountMeta
|
||||
};
|
||||
|
30
models/doctype/account/account_client.js
Normal file
30
models/doctype/account/account_client.js
Normal file
@ -0,0 +1,30 @@
|
||||
const BaseList = require('frappejs/client/view/list');
|
||||
const BaseForm = require('frappejs/client/view/form');
|
||||
|
||||
class AccountList extends BaseList {
|
||||
get_fields() {
|
||||
return ['name', 'account_type'];
|
||||
}
|
||||
get_row_html(data) {
|
||||
return `<a href="#edit/account/${data.name}">${data.name} (${data.account_type})</a>`;
|
||||
}
|
||||
}
|
||||
|
||||
class AccountForm extends BaseForm {
|
||||
make() {
|
||||
this.super();
|
||||
|
||||
// override controller event
|
||||
this.controls['parent_account'].get_filters = (query) => {
|
||||
return {
|
||||
keywords: ["like", query],
|
||||
name: ["!=", this.doc.name]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Form: AccountForm,
|
||||
List: AccountList
|
||||
}
|
11
models/doctype/account/index.html
Normal file
11
models/doctype/account/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="js/bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user