diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index 9500a70feb..e5b04ddd37 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -109,97 +109,75 @@ erpnext.AccountsChart = Class.extend({ args: {ctype: ctype, comp: company}, method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_children', click: function(link) { - if(me.cur_toolbar) - $(me.cur_toolbar).toggle(false); - - if(!link.toolbar) - me.make_link_toolbar(link); - - if(link.toolbar) { - me.cur_toolbar = link.toolbar; - $(me.cur_toolbar).toggle(true); - } - // bold $('.bold').removeClass('bold'); // deselect $(link).parent().find('.balance-area:first').addClass('bold'); // select }, - onrender: function(treenode) { - if (ctype == 'Account' && treenode.data) { - if(treenode.data.balance) { - treenode.parent.append('' - + format_currency(treenode.data.balance, treenode.data.currency) - + ''); + toolbar: [ + { toggle_btn: true }, + { + label: __("Open"), + condition: function(node) { return !node.root }, + click: function(node, btn) { + frappe.set_route("Form", me.ctype, node.label); } + }, + { + condition: function(node) { return !node.root && node.expandable; }, + label: __("Add Child"), + click: function() { + if(me.ctype=='Account') { + me.new_account(); + } else { + me.new_cost_center(); + } + } + }, + { + condition: function(node) { + return !node.root && me.ctype === 'Account' + && frappe.boot.profile.can_read.indexOf("GL Entry") !== -1 + }, + label: __("View Ledger"), + click: function(node, btn) { + frappe.route_options = { + "account": node.label, + "from_date": sys_defaults.year_start_date, + "to_date": sys_defaults.year_end_date, + "company": me.company + }; + frappe.set_route("query-report", "General Ledger"); + } + + }, + { + condition: function(node) { return !node.root && me.can_write }, + label: __("Rename"), + click: function(node) { + frappe.model.rename_doc(me.ctype, node.label, function(new_name) { + node.reload(); + }); + } + }, + { + condition: function(node) { return !node.root && me.can_delete }, + label: __("Delete"), + click: function(node) { + frappe.model.delete_doc(me.ctype, node.label, function() { + node.parent.remove(); + }); + } + } + ], + onrender: function(node) { + if (me.ctype == 'Account' && node.data && node.data.balance!==undefined) { + $('' + + format_currency(node.data.balance, node.data.currency) + + '').insertBefore(node.$ul); } } }); - this.tree.rootnode.$a.click(); - }, - make_link_toolbar: function(link) { - var data = $(link).data('node-data'); - if(!data) return; - - link.toolbar = $('').insertAfter(link); - - var node_links = []; - // edit - if (frappe.model.can_read(this.ctype) !== -1) { - node_links.push(''+frappe._('Edit')+''); - } - if (data.expandable && frappe.boot.profile.in_create.indexOf(this.ctype) !== -1) { - node_links.push(''+frappe._('Add Child')+''); - } else if (this.ctype === 'Account' && frappe.boot.profile.can_read.indexOf("GL Entry") !== -1) { - node_links.push(''+frappe._('View Ledger')+''); - } - - if (this.can_write) { - node_links.push(''+frappe._('Rename')+''); - }; - - if (this.can_delete) { - node_links.push(''+frappe._('Delete')+''); - }; - - link.toolbar.append(node_links.join(" | ")); - }, - open: function() { - var node = this.selected_node(); - frappe.set_route("Form", this.ctype, node.data("label")); - }, - show_ledger: function() { - var me = this; - var node = me.selected_node(); - frappe.route_options = { - "account": node.data('label'), - "from_date": sys_defaults.year_start_date, - "to_date": sys_defaults.year_end_date, - "company": me.company - }; - frappe.set_route("query-report", "General Ledger"); - }, - rename: function() { - var node = this.selected_node(); - frappe.model.rename_doc(this.ctype, node.data('label'), function(new_name) { - node.parents("ul:first").parent().find(".tree-link:first").trigger("reload"); - }); - }, - delete: function() { - var node = this.selected_node(); - frappe.model.delete_doc(this.ctype, node.data('label'), function() { - node.parent().remove(); - }); - }, - new_node: function() { - if(this.ctype=='Account') { - this.new_account(); - } else { - this.new_cost_center(); - } - }, - selected_node: function() { - return this.tree.$w.find('.tree-link.selected'); }, new_account: function() { var me = this; @@ -250,12 +228,11 @@ erpnext.AccountsChart = Class.extend({ // create $(fd.create_new.input).click(function() { var btn = this; - $(btn).set_working(); var v = d.get_values(); if(!v) return; - var node = me.selected_node(); - v.parent_account = node.data('label'); + var node = me.tree.get_selected_node(); + v.parent_account = node.label; v.master_type = ''; v.company = me.company; @@ -263,9 +240,8 @@ erpnext.AccountsChart = Class.extend({ args: v, method: 'erpnext.accounts.utils.add_ac', callback: function(r) { - $(btn).done_working(); d.hide(); - node.trigger('reload'); + node.reload; } }); }); @@ -296,23 +272,20 @@ erpnext.AccountsChart = Class.extend({ // create $(d.fields_dict.create_new.input).click(function() { - var btn = this; - $(btn).set_working(); var v = d.get_values(); if(!v) return; - var node = me.selected_node(); + var node = me.tree.get_selected_node(); - v.parent_cost_center = node.data('label'); + v.parent_cost_center = node.label; v.company = me.company; return frappe.call({ args: v, method: 'erpnext.accounts.utils.add_cc', callback: function(r) { - $(btn).done_working(); d.hide(); - node.trigger('reload'); + node.reload(); } }); }); diff --git a/erpnext/selling/page/sales_browser/sales_browser.js b/erpnext/selling/page/sales_browser/sales_browser.js index 57a7ee69cf..7beeb4218b 100644 --- a/erpnext/selling/page/sales_browser/sales_browser.js +++ b/erpnext/selling/page/sales_browser/sales_browser.js @@ -56,57 +56,56 @@ erpnext.SalesChart = Class.extend({ $(parent).empty(); var me = this; me.ctype = ctype; + me.can_read = frappe.model.can_read(this.ctype); + me.can_create = frappe.boot.profile.can_create.indexOf(this.ctype) !== -1 || + frappe.boot.profile.in_create.indexOf(this.ctype) !== -1; + me.can_write = frappe.model.can_write(this.ctype); + me.can_delete = frappe.model.can_delete(this.ctype); + this.tree = new frappe.ui.Tree({ parent: $(parent), label: root, args: {ctype: ctype}, method: 'erpnext.selling.page.sales_browser.sales_browser.get_children', - click: function(link) { - if(me.cur_toolbar) - $(me.cur_toolbar).toggle(false); - - if(!link.toolbar) - me.make_link_toolbar(link); - - if(link.toolbar) { - me.cur_toolbar = link.toolbar; - $(me.cur_toolbar).toggle(true); + toolbar: [ + {toggle_btn: true}, + { + label:__("Edit"), + condition: function(node) { + return !node.root && me.can_read; + }, + click: function(node) { + frappe.set_route("Form", me.ctype, node.label); + } + }, + { + label:__("Add Child"), + condition: function(node) { return me.can_create && node.expandable; }, + click: function(node) { + me.new_node(); + } + }, + { + label:__("Rename"), + condition: function(node) { return !node.root && me.can_write; }, + click: function(node) { + frappe.model.rename_doc(me.ctype, node.label, function(new_name) { + node.$a.html(new_name); + }); + } + }, + { + label:__("Delete"), + condition: function(node) { return !node.root && me.can_delete; }, + click: function(node) { + frappe.model.delete_doc(me.ctype, node.label, function() { + node.parent.remove(); + }); + } } - } + + ] }); - this.tree.rootnode.$a - .data('node-data', {value: root, expandable:1}) - .click(); - }, - make_link_toolbar: function(link) { - var data = $(link).data('node-data'); - if(!data) return; - - link.toolbar = $('').insertAfter(link); - - // edit - var node_links = []; - - if (frappe.model.can_read(this.ctype)) { - node_links.push(''+frappe._('Edit')+''); - } - - if(data.expandable) { - if (frappe.boot.profile.can_create.indexOf(this.ctype) !== -1 || - frappe.boot.profile.in_create.indexOf(this.ctype) !== -1) { - node_links.push('' + frappe._('Add Child') + ''); - } - } - - if (frappe.model.can_write(this.ctype)) { - node_links.push('' + frappe._('Rename') + ''); - }; - - if (frappe.model.can_delete(this.ctype)) { - node_links.push('' + frappe._('Delete') + ''); - }; - - link.toolbar.append(node_links.join(" | ")); }, new_node: function() { var me = this; @@ -134,44 +133,23 @@ erpnext.SalesChart = Class.extend({ // create $(d.fields_dict.create_new.input).click(function() { var btn = this; - $(btn).set_working(); var v = d.get_values(); if(!v) return; - var node = me.selected_node(); + var node = me.tree.get_selected_node(); - v.parent = node.data('label'); + v.parent = node.label; v.ctype = me.ctype; return frappe.call({ method: 'erpnext.selling.page.sales_browser.sales_browser.add_node', args: v, callback: function() { - $(btn).done_working(); d.hide(); - node.trigger('reload'); + node.reload(); } }) }); d.show(); }, - selected_node: function() { - return this.tree.$w.find('.tree-link.selected'); - }, - open: function() { - var node = this.selected_node(); - frappe.set_route("Form", this.ctype, node.data("label")); - }, - rename: function() { - var node = this.selected_node(); - frappe.model.rename_doc(this.ctype, node.data('label'), function(new_name) { - node.data('label', new_name).find(".tree-label").html(new_name); - }); - }, - delete: function() { - var node = this.selected_node(); - frappe.model.delete_doc(this.ctype, node.data('label'), function() { - node.parent().remove(); - }); - }, }); \ No newline at end of file diff --git a/erpnext/setup/doctype/company/sample_home_page.html b/erpnext/setup/doctype/company/sample_home_page.html index d6a05195b9..6c1e04192e 100644 --- a/erpnext/setup/doctype/company/sample_home_page.html +++ b/erpnext/setup/doctype/company/sample_home_page.html @@ -1,5 +1,3 @@ -
This is a sample home page for your company %(name)s's website. This was created from the Website Module inside ERPNext. ERPNext provides you with simple tools to build and update your website. You can add sections like your Product Catalog, diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.js b/erpnext/setup/page/setup_wizard/setup_wizard.js index 4a88013c93..6e28bbbe4c 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.js +++ b/erpnext/setup/page/setup_wizard/setup_wizard.js @@ -371,11 +371,11 @@ frappe.wiz.WizardSlide = Class.extend({ this.$wrapper = $(repl('