search selector fix for link

This commit is contained in:
Rushabh Mehta 2012-03-09 17:51:39 +05:30
parent 519f70b384
commit 9f89e35ebe
6 changed files with 64 additions and 28 deletions

View File

@ -1577,6 +1577,11 @@ div.list-row:hover {
background-color: #eef background-color: #eef
} }
div.paging-button {
text-align: center;
padding: 11px 0px;
}
div.show_filters { div.show_filters {
display: none; display: none;
} }

View File

@ -108,12 +108,19 @@ cur_frm.cscript.customer = function(doc,dt,dn) {
cur_frm.refresh(); cur_frm.refresh();
} }
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback); if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name),
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']); 'get_default_customer_address', '', callback);
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name',
'address_display','contact_display','contact_mobile','contact_email','territory',
'customer_group']);
} }
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1); if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({
customer: doc.customer,
address: doc.customer_address,
contact: doc.contact_person
}),'', doc, dt, dn, 1);
} }
cur_frm.fields_dict.customer_address.on_new = function(dn) { cur_frm.fields_dict.customer_address.on_new = function(dn) {

View File

@ -212,13 +212,16 @@ cur_frm.cscript.price_list_currency = cur_frm.cscript.currency;
cur_frm.cscript.conversion_rate = cur_frm.cscript.currency; cur_frm.cscript.conversion_rate = cur_frm.cscript.currency;
cur_frm.cscript.plc_conversion_rate = cur_frm.cscript.currency; cur_frm.cscript.plc_conversion_rate = cur_frm.cscript.currency;
cur_frm.cscript.company = function(doc, dt, dn) { cur_frm.cscript.company = function(doc, cdt, cdn) {
wn.call({ wn.call({
method: 'selling.doctype.sales_common.sales_common.get_comp_base_currency', method: 'selling.doctype.sales_common.sales_common.get_comp_base_currency',
args: {company:doc.company}, args: {company:doc.company},
callback: function(r, rt) { callback: function(r, rt) {
var doc = locals[dt][dn]; var doc = locals[cdt][cdn];
set_multiple(doc.doctype, doc.name, {currency:r.message, price_list_currency:r.message}); set_multiple(doc.doctype, doc.name, {
currency:r.message,
price_list_currency:r.message
});
cur_frm.cscript.currency(doc, cdt, cdn); cur_frm.cscript.currency(doc, cdt, cdn);
} }
}); });
@ -249,9 +252,20 @@ cur_frm.cscript.price_list_name = function(doc, cdt, cdn) {
// ******************** ITEM CODE ******************************** // ******************** ITEM CODE ********************************
cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
if (doc.order_type == 'Maintenance') if (doc.order_type == 'Maintenance')
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50'; return 'SELECT tabItem.name,tabItem.item_name,tabItem.description \
FROM tabItem WHERE tabItem.is_service_item="Yes" \
AND tabItem.docstatus != 2 \
AND (ifnull(`tabItem`.`end_of_life`,"") = "" \
OR `tabItem`.`end_of_life` > NOW() \
OR `tabItem`.`end_of_life`="0000-00-00") \
AND tabItem.%(key)s LIKE "%s" LIMIT 50';
else else
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50'; return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem \
WHERE tabItem.is_sales_item="Yes" AND tabItem.docstatus != 2 \
AND (ifnull(`tabItem`.`end_of_life`,"") = "" \
OR `tabItem`.`end_of_life` > NOW() \
OR `tabItem`.`end_of_life`="0000-00-00") \
AND tabItem.%(key)s LIKE "%s" LIMIT 50';
} }
@ -267,8 +281,14 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var callback = function(r, rt){ var callback = function(r, rt){
cur_frm.cscript.recalc(doc, 1); cur_frm.cscript.recalc(doc, 1);
} }
var args = {'item_code':d.item_code, 'income_account':d.income_account, 'cost_center': d.cost_center, 'warehouse': d.warehouse}; var args = {
get_server_fields('get_item_details',JSON.stringify(args), fname,doc,cdt,cdn,1,callback); 'item_code':d.item_code,
'income_account':d.income_account,
'cost_center': d.cost_center,
'warehouse': d.warehouse
};
get_server_fields('get_item_details',JSON.stringify(args),
fname,doc,cdt,cdn,1,callback);
} }
} }
if(cur_frm.cscript.custom_item_code){ if(cur_frm.cscript.custom_item_code){
@ -358,8 +378,14 @@ cur_frm.cscript.recalc = function(doc, n) {
var sales_team = cur_frm.cscript.sales_team_fname; var sales_team = cur_frm.cscript.sales_team_fname;
var other_fname = cur_frm.cscript.other_fname; var other_fname = cur_frm.cscript.other_fname;
if(!flt(doc.conversion_rate)) { doc.conversion_rate = 1; refresh_field('conversion_rate'); } if(!flt(doc.conversion_rate)) {
if(!flt(doc.plc_conversion_rate)) { doc.plc_conversion_rate = 1; refresh_field('plc_conversion_rate'); } doc.conversion_rate = 1;
refresh_field('conversion_rate');
}
if(!flt(doc.plc_conversion_rate)) {
doc.plc_conversion_rate = 1;
refresh_field('plc_conversion_rate');
}
if(n > 0) cur_frm.cscript.update_fname_table(doc , tname , fname , n, other_fname); // updates all values in table (i.e. amount, export amount, net total etc.) if(n > 0) cur_frm.cscript.update_fname_table(doc , tname , fname , n, other_fname); // updates all values in table (i.e. amount, export amount, net total etc.)
@ -378,7 +404,7 @@ cur_frm.cscript.recalc = function(doc, n) {
} }
cur_frm.cscript.calc_other_charges(doc , tname , fname , other_fname); // calculate other charges cur_frm.cscript.calc_other_charges(doc , tname , fname , other_fname); // calculate other charges
} }
cur_frm.cscript.calc_doc_values(doc, cdt, cdn, tname, fname, other_fname); // calculates total amounts cur_frm.cscript.calc_doc_values(doc, null, null, tname, fname, other_fname); // calculates total amounts
// ******************* calculate allocated amount of sales person ************************ // ******************* calculate allocated amount of sales person ************************
cl = getchildren('Sales Team', doc.name, sales_team); cl = getchildren('Sales Team', doc.name, sales_team);

View File

@ -1028,7 +1028,7 @@ var docname=history_get_name(t);if(t[0]=='Form'){_history_current=newLocation;if
/* /*
* lib/js/legacy/webpage/search.js * lib/js/legacy/webpage/search.js
*/ */
search_fields={};function setlinkvalue(name){selector.input.set_input(name);selector.hide();} search_fields={};function setlinkvalue(name){selector.input.set_input_value(name);selector.hide();}
function makeselector(){var d=new Dialog(540,440,'Search');d.make_body([['Data','Beginning With','Tip: You can use wildcard "%"'],['Select','Search By'],['Button','Search'],['HTML','Help'],['HTML','Result']]);var inp=d.widgets['Beginning With'];var field_sel=d.widgets['Search By'];var btn=d.widgets['Search'];d.sel_type='';d.values_len=0;d.set=function(input,type,label){d.sel_type=type;d.input=input;if(d.style!='Link'){d.rows['Result'].innerHTML='';d.values_len=0;} function makeselector(){var d=new Dialog(540,440,'Search');d.make_body([['Data','Beginning With','Tip: You can use wildcard "%"'],['Select','Search By'],['Button','Search'],['HTML','Help'],['HTML','Result']]);var inp=d.widgets['Beginning With'];var field_sel=d.widgets['Search By'];var btn=d.widgets['Search'];d.sel_type='';d.values_len=0;d.set=function(input,type,label){d.sel_type=type;d.input=input;if(d.style!='Link'){d.rows['Result'].innerHTML='';d.values_len=0;}
d.style='Link';d.set_query_description() d.style='Link';d.set_query_description()
if(!d.sel_type)d.sel_type='Value';d.set_title('Select a "'+d.sel_type+'" for field "'+label+'"');} if(!d.sel_type)d.sel_type='Value';d.set_title('Select a "'+d.sel_type+'" for field "'+label+'"');}
@ -1042,8 +1042,7 @@ inp.value='';if(d.input&&d.input.txt.value){inp.value=d.input.txt.value;}
try{inp.focus();}catch(e){} try{inp.focus();}catch(e){}
if(d.input)d.input.set_get_query();var get_sf_list=function(dt){var l=[];var lf=search_fields[dt];for(var i=0;i<lf.length;i++)l.push(lf[i][1]);return l;} if(d.input)d.input.set_get_query();var get_sf_list=function(dt){var l=[];var lf=search_fields[dt];for(var i=0;i<lf.length;i++)l.push(lf[i][1]);return l;}
$ds(d.rows['Search By']);if(search_fields[d.sel_type]){empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type),'ID');}else{empty_select(field_sel);add_sel_options(field_sel,['ID'],'ID');$c('webnotes.widgets.search.getsearchfields',{'doctype':d.sel_type},function(r,rt){search_fields[d.sel_type]=r.searchfields;empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type));field_sel.selectedIndex=0;});}} $ds(d.rows['Search By']);if(search_fields[d.sel_type]){empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type),'ID');}else{empty_select(field_sel);add_sel_options(field_sel,['ID'],'ID');$c('webnotes.widgets.search.getsearchfields',{'doctype':d.sel_type},function(r,rt){search_fields[d.sel_type]=r.searchfields;empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type));field_sel.selectedIndex=0;});}}
d.onhide=function(){if(d.input&&d.input.txt) d.onhide=function(){}
d.input.txt.onchange()}
btn.onclick=function(){if(this.disabled)return;this.args.is_ajax=true;this.set_working();d.set_doctype=d.sel_type;var q='';args={};if(d.input&&d.input.get_query){var doc={};args.is_simple=1;if(cur_frm)doc=locals[cur_frm.doctype][cur_frm.docname];var q=d.input.get_query(doc,d.input.doctype,d.input.docname);if(!q){return'';}} btn.onclick=function(){if(this.disabled)return;this.args.is_ajax=true;this.set_working();d.set_doctype=d.sel_type;var q='';args={};if(d.input&&d.input.get_query){var doc={};args.is_simple=1;if(cur_frm)doc=locals[cur_frm.doctype][cur_frm.docname];var q=d.input.get_query(doc,d.input.doctype,d.input.docname);if(!q){return'';}}
var get_sf_fieldname=function(v){var lf=search_fields[d.sel_type];if(!lf) var get_sf_fieldname=function(v){var lf=search_fields[d.sel_type];if(!lf)
return'name' return'name'

View File

@ -720,21 +720,21 @@ $.extend(this,this.opts);this.prepare_opts();$(this.parent).html(repl('\
\ \
<div class="result">\ <div class="result">\
<div class="result-list"></div>\ <div class="result-list"></div>\
<div class="result-grid"></div>\ <div class="result-grid hide"></div>\
</div>\ </div>\
\ \
<div class="paging-button hide">\ <div class="paging-button">\
<button class="btn btn-small btn-more">More...</div>\ <button class="btn btn-small btn-more hide">More...</div>\
</div>\ </div>\
</div>\ </div>\
',this.opts));this.$w=$(this.parent).find('.wnlist');this.set_events();this.make_filters();},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-refresh').click(function(){me.run();});this.$w.find('.btn-more').click(function(){me.run({append:true});});this.$w.find('.btn-list').click(function(){me.show_view($(this),me.$w.find('.result-list'),me.$w.find('.btn-grid'),me.$w.find('.result-grid'))});this.$w.find('.btn-grid').click(function(){me.show_view($(this),me.$w.find('.result-grid'),me.$w.find('.btn-list'),me.$w.find('.result-list'))});if(this.title){this.$w.find('h3').html(this.title).toggle(true);} ',this.opts));this.$w=$(this.parent).find('.wnlist');this.set_events();this.make_filters();},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-refresh').click(function(){me.run();});this.$w.find('.btn-more').click(function(){me.run({append:true});});this.$w.find('.btn-list').click(function(){me.show_view($(this),me.$w.find('.result-list'),me.$w.find('.btn-grid'),me.$w.find('.result-grid'))});this.$w.find('.btn-grid').click(function(){me.show_view($(this),me.$w.find('.result-grid'),me.$w.find('.btn-list'),me.$w.find('.result-list'))});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
if(this.new_doctype){this.$w.find('.btn-new').toggle(true).click(function(){newdoc(me.new_doctype);})}else{this.$w.find('.btn-new').toggle(false).attr('hidden','true');} if(this.new_doctype){this.$w.find('.btn-new').toggle(true).click(function(){newdoc(me.new_doctype);})}else{this.$w.find('.btn-new').toggle(false).attr('hidden','hidden');}
if(!me.show_filters){this.$w.find('.btn-filter').toggle(false).attr('hidden','true');} if(!me.show_filters){this.$w.find('.btn-filter').toggle(false).attr('hidden','hidden');}
if(this.hide_refresh||this.no_refresh){this.$w.find('.btn-refresh').toggle(false).attr('hidden','true');} if(this.hide_refresh||this.no_refresh){this.$w.find('.btn-refresh').toggle(false).attr('hidden','hidden');}
if(this.show_grid){this.$w.find('.select-view').toggle(true);} if(this.show_grid){this.$w.find('.select-view').toggle(true);}
if(this.$w.find('.list-toolbar [hidden!="true"]').length>1){this.$w.find('.list-toolbar').addClass('btn-group')}},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') if(this.$w.find('.list-toolbar a[hidden!="hidden"]').length>1){this.$w.find('.list-toolbar').addClass('btn-group')}},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) this.onrun=a0;if(a0&&a0.callback)
this.onrun=a0.callback;if(!a1||(a0&&a0.append)) this.onrun=a0.callback;if(!a1&&!(a0&&a0.append))
this.start=0;me.$w.find('.img-load').toggle(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(),callback:function(r){me.$w.find('.img-load').toggle(false);me.render_results(r)},no_spinner:this.opts.no_loading,btn:this.run_btn});},get_call_args:function(){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1} this.start=0;me.$w.find('.img-load').toggle(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(),callback:function(r){me.$w.find('.img-load').toggle(false);me.render_results(r)},no_spinner:this.opts.no_loading,btn:this.run_btn});},get_call_args:function(){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}} args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
if(this.args) if(this.args)
@ -834,7 +834,7 @@ var docname=history_get_name(t);if(t[0]=='Form'){_history_current=newLocation;if
/* /*
* lib/js/legacy/webpage/search.js * lib/js/legacy/webpage/search.js
*/ */
search_fields={};function setlinkvalue(name){selector.input.set_input(name);selector.hide();} search_fields={};function setlinkvalue(name){selector.input.set_input_value(name);selector.hide();}
function makeselector(){var d=new Dialog(540,440,'Search');d.make_body([['Data','Beginning With','Tip: You can use wildcard "%"'],['Select','Search By'],['Button','Search'],['HTML','Help'],['HTML','Result']]);var inp=d.widgets['Beginning With'];var field_sel=d.widgets['Search By'];var btn=d.widgets['Search'];d.sel_type='';d.values_len=0;d.set=function(input,type,label){d.sel_type=type;d.input=input;if(d.style!='Link'){d.rows['Result'].innerHTML='';d.values_len=0;} function makeselector(){var d=new Dialog(540,440,'Search');d.make_body([['Data','Beginning With','Tip: You can use wildcard "%"'],['Select','Search By'],['Button','Search'],['HTML','Help'],['HTML','Result']]);var inp=d.widgets['Beginning With'];var field_sel=d.widgets['Search By'];var btn=d.widgets['Search'];d.sel_type='';d.values_len=0;d.set=function(input,type,label){d.sel_type=type;d.input=input;if(d.style!='Link'){d.rows['Result'].innerHTML='';d.values_len=0;}
d.style='Link';d.set_query_description() d.style='Link';d.set_query_description()
if(!d.sel_type)d.sel_type='Value';d.set_title('Select a "'+d.sel_type+'" for field "'+label+'"');} if(!d.sel_type)d.sel_type='Value';d.set_title('Select a "'+d.sel_type+'" for field "'+label+'"');}
@ -848,8 +848,7 @@ inp.value='';if(d.input&&d.input.txt.value){inp.value=d.input.txt.value;}
try{inp.focus();}catch(e){} try{inp.focus();}catch(e){}
if(d.input)d.input.set_get_query();var get_sf_list=function(dt){var l=[];var lf=search_fields[dt];for(var i=0;i<lf.length;i++)l.push(lf[i][1]);return l;} if(d.input)d.input.set_get_query();var get_sf_list=function(dt){var l=[];var lf=search_fields[dt];for(var i=0;i<lf.length;i++)l.push(lf[i][1]);return l;}
$ds(d.rows['Search By']);if(search_fields[d.sel_type]){empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type),'ID');}else{empty_select(field_sel);add_sel_options(field_sel,['ID'],'ID');$c('webnotes.widgets.search.getsearchfields',{'doctype':d.sel_type},function(r,rt){search_fields[d.sel_type]=r.searchfields;empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type));field_sel.selectedIndex=0;});}} $ds(d.rows['Search By']);if(search_fields[d.sel_type]){empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type),'ID');}else{empty_select(field_sel);add_sel_options(field_sel,['ID'],'ID');$c('webnotes.widgets.search.getsearchfields',{'doctype':d.sel_type},function(r,rt){search_fields[d.sel_type]=r.searchfields;empty_select(field_sel);add_sel_options(field_sel,get_sf_list(d.sel_type));field_sel.selectedIndex=0;});}}
d.onhide=function(){if(d.input&&d.input.txt) d.onhide=function(){}
d.input.txt.onchange()}
btn.onclick=function(){if(this.disabled)return;this.args.is_ajax=true;this.set_working();d.set_doctype=d.sel_type;var q='';args={};if(d.input&&d.input.get_query){var doc={};args.is_simple=1;if(cur_frm)doc=locals[cur_frm.doctype][cur_frm.docname];var q=d.input.get_query(doc,d.input.doctype,d.input.docname);if(!q){return'';}} btn.onclick=function(){if(this.disabled)return;this.args.is_ajax=true;this.set_working();d.set_doctype=d.sel_type;var q='';args={};if(d.input&&d.input.get_query){var doc={};args.is_simple=1;if(cur_frm)doc=locals[cur_frm.doctype][cur_frm.docname];var q=d.input.get_query(doc,d.input.doctype,d.input.docname);if(!q){return'';}}
var get_sf_fieldname=function(v){var lf=search_fields[d.sel_type];if(!lf) var get_sf_fieldname=function(v){var lf=search_fields[d.sel_type];if(!lf)
return'name' return'name'

View File

@ -1 +1 @@
926 932