diff --git a/css/all-app.css b/css/all-app.css index 033ca6e8eda..d267c9b7890 100644 --- a/css/all-app.css +++ b/css/all-app.css @@ -1945,7 +1945,7 @@ div.std-footer-item { padding: 0px; } -.layout-section { +.layout-main { padding: 15px; } diff --git a/css/all-web.css b/css/all-web.css index 53eb733105a..c16a8e8e9b3 100644 --- a/css/all-web.css +++ b/css/all-web.css @@ -1425,7 +1425,7 @@ div.std-footer-item { padding: 0px; } -.layout-section { +.layout-main { padding: 15px; } diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.css b/erpnext/accounts/page/accounts_browser/accounts_browser.css index 1e3904f6ac4..bbbbb6b8aac 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.css +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.css @@ -4,7 +4,7 @@ select.accbrowser-company-select { margin-left: 10px; } -span.accbrowser-node-toolbar { +span.tree-node-toolbar { padding: 2px; margin-left: 15px; border-radius: 3px; diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index 9be45eabd47..0561bd73a4f 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -102,7 +102,7 @@ erpnext.AccountsChart = Class.extend({ var data = $(link).data('node-data'); if(!data) return; - link.toolbar = $('').insertAfter(link); + link.toolbar = $('').insertAfter(link); // edit $('Add Child'); } else if(this.ctype=='Account') { link.toolbar.append(' | View Ledger'); - } + } }, show_ledger: function() { var me = this; diff --git a/erpnext/home/page/activity/activity.html b/erpnext/home/page/activity/activity.html index b348d95cc69..9fb910cab33 100644 --- a/erpnext/home/page/activity/activity.html +++ b/erpnext/home/page/activity/activity.html @@ -1,6 +1,7 @@ -
- × -

Activity

-
+
+
+
+
+
\ No newline at end of file diff --git a/erpnext/home/page/activity/activity.js b/erpnext/home/page/activity/activity.js index 83f018dc625..7df834e94ff 100644 --- a/erpnext/home/page/activity/activity.js +++ b/erpnext/home/page/activity/activity.js @@ -1,5 +1,8 @@ wn.pages['activity'].onload = function(wrapper) { + wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe')); + wrapper.appframe.title('Activity'); var list = new wn.ui.Listing({ + appframe: wrapper.appframe, method: 'home.page.activity.activity.get_feed', parent: $('#activity-list'), render_row: function(row, data) { diff --git a/erpnext/selling/page/sales_browser/sales_browser.css b/erpnext/selling/page/sales_browser/sales_browser.css new file mode 100644 index 00000000000..38b8e963753 --- /dev/null +++ b/erpnext/selling/page/sales_browser/sales_browser.css @@ -0,0 +1,14 @@ +span.tree-node-toolbar { + padding: 2px; + margin-left: 15px; + border-radius: 3px; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + background-color: #ddd; +} + +.tree-area a.selected { + font-weight: bold; + text-decoration: underline; +} diff --git a/erpnext/selling/page/sales_browser/sales_browser.html b/erpnext/selling/page/sales_browser/sales_browser.html index 1acb5eefd7c..4683a0781e5 100644 --- a/erpnext/selling/page/sales_browser/sales_browser.html +++ b/erpnext/selling/page/sales_browser/sales_browser.html @@ -1,4 +1,11 @@ -
-
-
+
+
+
+
+
+
+
To add child nodes, explore tree and click on the node under which you want to add more nodes. +
+
+
\ No newline at end of file diff --git a/erpnext/selling/page/sales_browser/sales_browser.js b/erpnext/selling/page/sales_browser/sales_browser.js index 8137d0411a1..4d5a3dcfa11 100644 --- a/erpnext/selling/page/sales_browser/sales_browser.js +++ b/erpnext/selling/page/sales_browser/sales_browser.js @@ -14,6 +14,123 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +pscript['onload_Sales Browser'] = function(wrapper){ + wn.require('lib/js/wn/ui/tree.js'); + wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area')); + wrapper.appframe.add_button('Refresh', function() { + wrapper.make_tree(); + }, 'icon-refresh'); + + wrapper.make_tree = function() { + var ctype = wn.get_route()[1] || 'Territory'; + erpnext.sales_chart = new erpnext.SalesChart(ctype, wrapper); + } + + wrapper.make_tree(); +} + +pscript['onshow_Sales Browser'] = function(wrapper){ + // set route + var ctype = wn.get_route()[1] || 'Territory'; + wrapper.appframe.title(ctype + ' Tree'); + + if(erpnext.sales_chart && erpnext.sales_chart.ctype != ctype) { + wrapper.make_tree(); + } +}; + +erpnext.SalesChart = Class.extend({ + init: function(ctype, wrapper) { + var root_nodes = { + 'Territory': 'All Territories', + 'Item Group': 'All Item Groups', + 'Customer Group': 'All Customer Groups', + 'Sales Person': 'All Sales Persons' + } + + $(wrapper).find('.tree-area').empty(); + var me = this; + me.ctype = ctype; + this.tree = new wn.ui.Tree({ + parent: $(wrapper).find('.tree-area'), + label: root_nodes[ctype], + args: {ctype: ctype}, + method: '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); + } + } + }); + this.tree.rootnode.$a + .data('node-data', {value: root_nodes[ctype], expandable:1}) + .click(); + }, + make_link_toolbar: function(link) { + var data = $(link).data('node-data'); + if(!data) return; + + link.toolbar = $('').insertAfter(link); + + // edit + $('Edit').appendTo(link.toolbar); + + if(data.expandable) { + link.toolbar.append(' | Add Child'); + } + }, + new_node: function() { + var me = this; + + // the dialog + var d = new wn.ui.Dialog({ + title:'New ' + me.ctype, + fields: [ + {fieldtype:'Data', fieldname: 'name_field', label:'New ' + me.ctype + ' Name', reqd:true}, + {fieldtype:'Select', fieldname:'is_group', label:'Group Node', + options:'No\nYes', description:'Entries can made only against non-group (leaf) nodes'}, + {fieldtype:'Button', fieldname:'create_new', label:'Create New' } + ] + }) + + // 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(); + + v.parent = node.data('label'); + v.ctype = me.ctype; + + wn.call({ + method: 'selling.page.sales_browser.sales_browser.add_node', + args: v, + callback: function() { + $(btn).done_working(); + d.hide(); + node.trigger('reload'); + } + }) + }); + d.show(); + }, + selected_node: function() { + return this.tree.$w.find('.tree-link.selected'); + } +}); + +/* pscript['onshow_Sales Browser'] = function(){ wn.require('lib/js/legacy/widgets/tree.js'); @@ -397,14 +514,14 @@ MakeDialog.prototype.btn_onclick=function(btn_name){ $c_obj('Sales Browser Control',method_name, docstring(arg2), function(r,rt) { me.main_dialog.widgets[me.lbl_rec].value=''; me.main_dialog.hide(); - /*if(me.btn_name == "Create"){ - me.cls_obj.cur_node.clear_child_nodes(); - me.cls_obj.dtl.innerHTML = ''; - me.cls_obj.cur_node.expand(); - } - else{ - me.cls_obj.refresh_tree(); - }*/ + //if(me.btn_name == "Create"){ + // me.cls_obj.cur_node.clear_child_nodes(); + // me.cls_obj.dtl.innerHTML = ''; + // me.cls_obj.cur_node.expand(); + //} + //else{ + // me.cls_obj.refresh_tree(); + //} me.cls_obj.refresh_tree(); }); } @@ -444,3 +561,4 @@ MakeDialog.prototype.make_args = function(){ return {'node_title':nt,'sales_person_name':nm,'parent_sales_person':pnm,'is_group':grp,'old_parent':old_prt} } +*/ \ No newline at end of file diff --git a/erpnext/selling/page/sales_browser/sales_browser.py b/erpnext/selling/page/sales_browser/sales_browser.py new file mode 100644 index 00000000000..d5419f55758 --- /dev/null +++ b/erpnext/selling/page/sales_browser/sales_browser.py @@ -0,0 +1,25 @@ +import webnotes + +@webnotes.whitelist() +def get_children(): + ctype = webnotes.form_dict.get('ctype') + webnotes.form_dict['parent_field'] = 'parent_' + ctype.lower().replace(' ', '_') + + return webnotes.conn.sql("""select name as value, + if(is_group='Yes', 1, 0) as expandable + from `tab%(ctype)s` + where docstatus < 2 + and %(parent_field)s = "%(parent)s" + order by name""" % webnotes.form_dict, as_dict=1) + +@webnotes.whitelist() +def add_node(): + from webnotes.model.doc import Document + ctype = webnotes.form_dict.get('ctype') + parent_field = 'parent_' + ctype.lower().replace(' ', '_') + + d = Document(ctype) + d.fields[ctype.lower().replace(' ', '_') + '_name'] = webnotes.form_dict['name_field'] + d.fields[parent_field] = webnotes.form_dict['parent'] + d.is_group = webnotes.form_dict['is_group'] + d.save() \ No newline at end of file