diff --git a/js/core.min.js b/js/core.min.js index d5c0f55ab2..17df0d111b 100644 --- a/js/core.min.js +++ b/js/core.min.js @@ -49,6 +49,11 @@ wn.get_cookie=function(c){var t=""+document.cookie;var ind=t.indexOf(c);if(ind== * lib/js/wn/model.js */ wn.provide('wn.model');wn.model={no_value_type:['Section Break','Column Break','HTML','Table','Button','Image'],new_names:{},with_doctype:function(doctype,callback){if(locals.DocType[doctype]){callback();}else{wn.call({method:'webnotes.widgets.form.load.getdoctype',args:{doctype:doctype},callback:callback});}},with_doc:function(doctype,name,callback){if(!name)name=doctype;if(locals[doctype]&&locals[doctype][name]){callback(name);}else{if(name&&name.indexOf('New '+doctype)!=-1){name=LocalDB.create(doctype);callback(name);}else{wn.call({method:'webnotes.widgets.form.load.getdoc',args:{doctype:doctype,name:name},callback:function(r){callback(name);}});}}},can_delete:function(doctype){if(!doctype)return false;return locals.DocType[doctype].allow_trash&&wn.boot.profile.can_cancel.indexOf(doctype)!=-1;}} +/* + * lib/js/wn/misc/tools.js + */ +wn.markdown=function(txt){if(!wn.md2html){wn.require('lib/js/lib/showdown.js');wn.md2html=new Showdown.converter();} +return wn.md2html.makeHtml(txt);} /* * lib/js/wn/misc/user.js */ @@ -227,13 +232,13 @@ wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype,page){this.doct
\ ',{label:this.label}));},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.add_delete_option();},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1 else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);} -this.listview.parent=this;},init_list:function(){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.$page.find('.wnlist-area'),start:0,page_length:20,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:true,no_result_message:this.make_no_result(),columns:this.listview.fields});this.run();},make_no_result:function(){return repl('

No %(doctype)s found

\ +this.listview.parent=this;},init_list:function(){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.$page.find('.wnlist-area'),start:0,page_length:20,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:true,no_result_message:this.make_no_result(),columns:this.listview.fields});this.run();},make_no_result:function(){return repl('

No %(doctype_label)s found

\ %(description)s\
\

\ -

',{doctype:this.doctype,description:locals.DocType[this.doctype].description||''});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[]}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('\ + onclick="wn.set_route(\'Form\', \'%(doctype)s\', \'New %(doctype)s\');"\ + >Make a new %(doctype_label)s\ +

',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[]}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('\ Delete',function(){me.delete_items();},'.btn-filter')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length) return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;} me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this diff --git a/js/legacy/wn/widgets/form/sidebar.js b/js/legacy/wn/widgets/form/sidebar.js index c918207c15..15577bdb53 100644 --- a/js/legacy/wn/widgets/form/sidebar.js +++ b/js/legacy/wn/widgets/form/sidebar.js @@ -165,13 +165,8 @@ wn.widgets.form.sidebar = { Sidebar: function(form) { { title: 'Help', render: function(wrapper) { - if(!wn.md2html) { - wn.require('lib/js/lib/showdown.js'); - wn.md2html = new Showdown.converter(); - } - - $a(wrapper, 'div', 'help small', {}, - wn.md2html.makeHtml(me.form.meta.description)); + $(wrapper).html('
' + + wn.markdown(me.form.meta.description) + '
') }, display: function() { return me.form.meta.description } } diff --git a/js/wn/misc/tools.js b/js/wn/misc/tools.js new file mode 100644 index 0000000000..5699f9640f --- /dev/null +++ b/js/wn/misc/tools.js @@ -0,0 +1,7 @@ +wn.markdown = function(txt) { + if(!wn.md2html) { + wn.require('lib/js/lib/showdown.js'); + wn.md2html = new Showdown.converter(); + } + return wn.md2html.makeHtml(txt); +} \ No newline at end of file diff --git a/js/wn/views/doclistview.js b/js/wn/views/doclistview.js index 40b8e8e636..8c6a0bf052 100644 --- a/js/wn/views/doclistview.js +++ b/js/wn/views/doclistview.js @@ -123,15 +123,16 @@ wn.views.DocListView = wn.ui.Listing.extend({ this.run(); }, make_no_result: function() { - return repl('

No %(doctype)s found

\ + return repl('

No %(doctype_label)s found

\ %(description)s\
\

\ + onclick="wn.set_route(\'Form\', \'%(doctype)s\', \'New %(doctype)s\');"\ + >Make a new %(doctype_label)s\

', { + doctype_label: get_doctype_label(this.doctype), doctype: this.doctype, - description: locals.DocType[this.doctype].description || '' + description: wn.markdown(locals.DocType[this.doctype].description || '') }); }, render_row: function(row, data) {