diff --git a/erpnext/website/templates/js/blog.js b/erpnext/website/templates/js/blog.js
index 76b9fb66ec..8c9b9d7252 100644
--- a/erpnext/website/templates/js/blog.js
+++ b/erpnext/website/templates/js/blog.js
@@ -24,7 +24,7 @@ wn.pages['{{ name }}'].onload = function(wrapper) {
render_row: function(parent, data) {
if(!data.comments) {
data.comment_text = 'No comments yet.'
- } else if (data.comments=1) {
+ } else if (data.comments===1) {
data.comment_text = '1 comment.'
} else {
data.comment_text = data.comments + ' comments.'
diff --git a/erpnext/website/web_cache.py b/erpnext/website/web_cache.py
index 7b3de0aaef..9892dac78c 100644
--- a/erpnext/website/web_cache.py
+++ b/erpnext/website/web_cache.py
@@ -139,11 +139,26 @@ def get_outer_env():
env dict for outer template
"""
import webnotes
+
+ all_top_items = webnotes.conn.sql("""\
+ select * from `tabTop Bar Item`
+ where parent='Website Settings' and parentfield='top_bar_items'
+ order by idx asc""", as_dict=1)
+
+ top_items = [d for d in all_top_items if not d['parent_label']]
+
+ # attach child items to top bar
+ for d in all_top_items:
+ if d['parent_label']:
+ for t in top_items:
+ if t['label']==d['parent_label']:
+ if not 'child_items' in t:
+ t['child_items'] = []
+ t['child_items'].append(d)
+ break
+
return {
- 'top_bar_items': webnotes.conn.sql("""\
- select * from `tabTop Bar Item`
- where parent='Website Settings' and parentfield='top_bar_items'
- order by idx asc""", as_dict=1),
+ 'top_bar_items': top_items,
'footer_items': webnotes.conn.sql("""\
select * from `tabTop Bar Item`
diff --git a/public/js/all-app.js b/public/js/all-app.js
index 81308297d7..37284304f1 100644
--- a/public/js/all-app.js
+++ b/public/js/all-app.js
@@ -305,7 +305,7 @@ if(this.show_filters){this.make_filters();}},add_button:function(label,click,ico
if(icon){$('
').addClass(icon).appendTo($button);}
$button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');}
-if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){me.make_new_doc(me.new_doctype);},'icon-plus');}
+if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){(me.custom_new_doc||me.make_new_doc)(me.new_doctype);},'icon-plus');}
if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');}
if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_new_doc:function(new_doctype){new_doc(new_doctype);},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
this.onrun=a0;if(a0&&a0.callback)
@@ -321,7 +321,7 @@ if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:funct
* lib/js/wn/ui/filters.js
*/
wn.ui.FilterList=Class.extend({init:function(opts){wn.require('js/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});this.$w.find('.search-btn').bind('click',function(){me.listobj.run();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length)
-this.add_filter();},add_filter:function(fieldname,condition,value){this.push_new_filter(fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
+this.add_filter();},add_filter:function(tablename,fieldname,condition,value){this.push_new_filter(tablename,fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(tablename,fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,tablename:tablename,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
values.push(f.get_value());})
return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);})
this.filters=fl;},get_filter:function(fieldname){for(var i in this.filters){if(this.filters[i].field.df.fieldname==fieldname)
@@ -339,21 +339,22 @@ return this.filters[i];}}});wn.ui.Filter=Class.extend({init:function(opts){$.ext
\
\
×\
- ');this.$w=this.flist.$w.find('.list_filter:last-child');},make_select:function(){this.fieldselect=new wn.ui.FieldSelect(this.$w.find('.fieldname_select_area'),this.doctype,this.filter_fields);},set_events:function(){var me=this;this.fieldselect.$select.bind('change',function(){me.set_field(this.value);});this.$w.find('a.close').bind('click',function(){me.$w.css('display','none');var value=me.field.get_value();me.field=null;if(!me.flist.get_filters().length){me.flist.$w.find('.set_filters').toggle(true);me.flist.$w.find('.show_filters').toggle(false);}
+