diff --git a/public/build.json b/public/build.json index 13c899c9c4..39e04dfb30 100644 --- a/public/build.json +++ b/public/build.json @@ -148,6 +148,7 @@ "lib/public/js/wn/form/layout.js", "lib/public/js/wn/form/script_manager.js", "lib/public/js/wn/form/control.js", + "lib/public/js/wn/form/link_selector.js", "lib/public/js/wn/form/editors.js", "lib/public/js/wn/form/grid.js", "lib/public/js/wn/form/attachments.js", diff --git a/public/js/wn/form/control.js b/public/js/wn/form/control.js index 26934c954c..5e727232ab 100644 --- a/public/js/wn/form/control.js +++ b/public/js/wn/form/control.js @@ -538,8 +538,11 @@ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({ // magnifier - search this.$input_area.find(".btn-search").on("click", function() { - selector.set(me, me.df.options, me.df.label); - selector.show(me.txt); + new wn.ui.form.LinkSelector({ + doctype: me.df.options, + target: me, + txt: me.$input.val() + }); }); // open @@ -617,8 +620,8 @@ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({ }; }, get_custom_query: function() { - if(this.get_query && this.doctype) { - return this.get_query(this.frm.doc, this.doctype, this.docname); + if(this.get_query) { + return this.get_query(this.frm && this.frm.doc, this.doctype, this.docname); } }, validate: function(value, callback) { @@ -627,6 +630,7 @@ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({ if(this.df.options=="[Select]") { callback(value); + return; } var fetch = ''; diff --git a/public/js/wn/form/link_selector.js b/public/js/wn/form/link_selector.js new file mode 100644 index 0000000000..d22be0d860 --- /dev/null +++ b/public/js/wn/form/link_selector.js @@ -0,0 +1,46 @@ +wn.ui.form.LinkSelector = Class.extend({ + _help: "Dialog box to select a Link Value", + init: function(opts) { + /* help: Options: doctype, get_query, target */ + $.extend(this, opts); + + var me = this; + if(this.doctype!="[Select]") { + wn.model.with_doctype(this.doctype, function(r) { + me.make(); + }); + } else { + this.make(); + } + }, + make: function() { + this.dialog = new wn.ui.Dialog({ + "title": "Select " + this.doctype, + "fields": [ + { + fieldtype: "Data", fieldname: "txt", label: "Beginning with", + description: "You can use wildcard %" + }, + { + fieldtype: "Select", fieldname: "search_field", label: "Search With" + }, + { + fieldtype: "Button", fieldname: "search", label: "Search", + }, + { + fieldtype: "HTML", fieldname: "results" + } + ] + }); + var search_fields = wn.model.get_value("DocType", this.doctype, "search_fields"); + if(this.doctype!="[Select]" && search_fields) { + this.dialog.fields_dict.search_field.$input.add_options(search_fields.split(",")); + } else { + this.dialog.fields_dict.search_field.$wrapper.toggle(false); + } + this.dialog.fields_dict.search.$input.on("click", function() { + + }) + this.dialog.show(); + } +}) \ No newline at end of file diff --git a/public/js/wn/ui/appframe.js b/public/js/wn/ui/appframe.js index c63ca413c1..ba9f97375d 100644 --- a/public/js/wn/ui/appframe.js +++ b/public/js/wn/ui/appframe.js @@ -30,8 +30,9 @@ wn.ui.AppFrame = Class.extend({ \
\ - \ + \ ').appendTo(this.$w); this.$w.find('.close').click(function() { @@ -187,7 +188,7 @@ wn.ui.AppFrame = Class.extend({ } this.buttons[label] = $(repl('', args)) - .appendTo(title_toolbar ? this.$w.find(".title-button-area") : this.toolbar) + .appendTo(title_toolbar ? this.$w.find(".title-button-area") : this.toolbar.find(".btn-group")) .attr("title", wn._(label)) .click(click); return this.buttons[label]; @@ -216,33 +217,29 @@ wn.ui.AppFrame = Class.extend({ }); }, add_label: function(label) { - return $(""+label+" ") - .appendTo($("