diff --git a/js/core.min.js b/js/core.min.js index 79577a8f72..f70b9cd50f 100644 --- a/js/core.min.js +++ b/js/core.min.js @@ -183,7 +183,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) diff --git a/js/legacy/webpage/loaders.js b/js/legacy/webpage/loaders.js index 11702b4f9f..df417f1bee 100644 --- a/js/legacy/webpage/loaders.js +++ b/js/legacy/webpage/loaders.js @@ -39,10 +39,10 @@ function loaddoc(doctype, name, onload) { } var load_doc = loaddoc; -function new_doc(doctype, onload, in_dialog, on_save_callback, cdt, cdn, cnic) { +function new_doc(doctype, in_form) { doctype = get_label_doctype(doctype); wn.model.with_doctype(doctype, function() { - if(locals.DocType[doctype].in_dialog) { + if(!in_form && locals.DocType[doctype].in_dialog) { var new_name = LocalDB.create(doctype); _f.edit_record(doctype, new_name); } else { diff --git a/js/legacy/widgets/form/fields.js b/js/legacy/widgets/form/fields.js index 08e9f05664..b75b8818f2 100644 --- a/js/legacy/widgets/form/fields.js +++ b/js/legacy/widgets/form/fields.js @@ -684,7 +684,7 @@ LinkField.prototype.setup_buttons = function() { } } _f.calling_doc_stack.push([me.doctype, me.docname]); - new_doc(me.df.options, me.on_new, 1, on_save_callback, me.doctype, me.docname, me.frm.not_in_container); + new_doc(me.df.options); } } else { $dh(me.btn2); $y($td(me.tab,0,2), {width:'0px'}); diff --git a/js/legacy/widgets/form/form_dialog.js b/js/legacy/widgets/form/form_dialog.js index ab0ff21da7..eb5d2b27a7 100644 --- a/js/legacy/widgets/form/form_dialog.js +++ b/js/legacy/widgets/form/form_dialog.js @@ -127,7 +127,7 @@ _f.edit_record = function(dt, dn) { $(f.page_layout.wrapper).removeClass('layout-wrapper') .removeClass('layout-wrapper-background').toggle(true); - d.dialog.show(); + d.dialog.show(); }) }) } \ No newline at end of file diff --git a/js/wn/ui/listing.js b/js/wn/ui/listing.js index a542dc6630..0f3bde8045 100644 --- a/js/wn/ui/listing.js +++ b/js/wn/ui/listing.js @@ -173,7 +173,7 @@ wn.ui.Listing = Class.extend({ // new if(this.new_doctype) { this.add_button('New ' + this.new_doctype, function() { - me.make_new_doc(me.new_doctype); + (me.custom_new_doc || me.make_new_doc)(me.new_doctype); }, 'icon-plus'); } diff --git a/js/wn/views/doclistview.js b/js/wn/views/doclistview.js index 51b914bdd0..4695e56059 100644 --- a/js/wn/views/doclistview.js +++ b/js/wn/views/doclistview.js @@ -144,13 +144,14 @@ wn.views.DocListView = wn.ui.Listing.extend({ new_doctype: this.doctype, allow_delete: this.allow_delete, no_result_message: this.make_no_result(), - columns: this.listview.fields + columns: this.listview.fields, + custom_new_doc: me.listview.make_new_doc || undefined, }); // make_new_doc can be overridden so that default values can be prefilled // for example - communication list in customer $(this.wrapper).find('button[list_view_doc="'+me.doctype+'"]').click(function(){ - me.make_new_doc(me.doctype); + (me.listview.make_new_doc || me.make_new_doc)(me.doctype); }); if((auto_run !== false) && (auto_run !== 0)) this.run();