grid recursive change bugfix
This commit is contained in:
parent
bb21e8b08f
commit
3f1e1fa01b
7 changed files with 37 additions and 13 deletions
|
|
@ -136,6 +136,7 @@
|
|||
"lib/js/wn/ui/appframe.js",
|
||||
"lib/js/wn/ui/dialog.js",
|
||||
"lib/js/wn/ui/button.js",
|
||||
"lib/js/wn/ui/search.js",
|
||||
"lib/js/legacy/widgets/dialog.js",
|
||||
"lib/js/legacy/widgets/layout.js",
|
||||
"lib/js/legacy/widgets/tabbedpage.js",
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ DataField.prototype.make_input = function() {
|
|||
this.input.name = this.df.fieldname;
|
||||
|
||||
$(this.input).change(function() {
|
||||
me.set_value($(this).val());
|
||||
me.set_value(me.get_value && me.get_value() || $(this.input).val());
|
||||
});
|
||||
|
||||
this.set_value = function(val) {
|
||||
|
|
@ -694,7 +694,6 @@ LinkField.prototype.setup_buttons = function() {
|
|||
}
|
||||
|
||||
LinkField.prototype.set_input_value = function(val) {
|
||||
|
||||
var me = this;
|
||||
var from_selector = false;
|
||||
if(selector && selector.display) from_selector = true;
|
||||
|
|
@ -725,7 +724,7 @@ LinkField.prototype.set_input_value = function(val) {
|
|||
_f.cur_grid_cell.grid.cell_deselect();
|
||||
|
||||
// run trigger if value is cleared
|
||||
if(!val) {
|
||||
if(locals[me.doctype][me.docname][me.df.fieldname] && !val) {
|
||||
me.run_trigger();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -364,14 +364,14 @@ _f.Grid.prototype.remove_template = function(cell) {
|
|||
if(!hc.template)return;
|
||||
if(!hc.template.activated)return;
|
||||
|
||||
if(hc.template.df.fieldtype=='Date') {
|
||||
/*if(hc.template.df.fieldtype=='Date') {
|
||||
// for calendar popup. the value will come after this
|
||||
_f.grid_date_cell = cell;
|
||||
setTimeout('_f.grid_refresh_date()', 100);
|
||||
} else {
|
||||
var input = hc.template.txt || hc.template.input;
|
||||
_f.grid_refresh_field(hc.template, input)
|
||||
}
|
||||
}*/
|
||||
|
||||
if(hc.template && hc.template.wrapper.parentNode)
|
||||
cell.div.removeChild(hc.template.wrapper);
|
||||
|
|
|
|||
11
js/wn/tmp.js
11
js/wn/tmp.js
|
|
@ -104,4 +104,15 @@ render_grid: function() {
|
|||
show: function(label) {
|
||||
return this.change_to(label);
|
||||
}
|
||||
});
|
||||
|
||||
////
|
||||
|
||||
me.set_get_query();
|
||||
new wn.ui.Search({
|
||||
query: me.get_query ? me.get_query() : null,
|
||||
doctype:me.df.options,
|
||||
callback: function(val) {
|
||||
me.set_input_value(val)
|
||||
}
|
||||
});
|
||||
2
js/wn/ui/toolbar.min.js
vendored
2
js/wn/ui/toolbar.min.js
vendored
|
|
@ -12,7 +12,7 @@ wn.ui.toolbar.NewDialog=wn.ui.toolbar.SelectorDialog.extend({init:function(){thi
|
|||
/*
|
||||
* lib/js/wn/ui/toolbar/search.js
|
||||
*/
|
||||
wn.ui.toolbar.Search=wn.ui.toolbar.SelectorDialog.extend({init:function(){this._super({title:"Search",execute:function(val){selector.set_search(val);selector.show();},});this.set_values(wn.boot.profile.can_search.join(',').split(','));makeselector();}});
|
||||
wn.ui.toolbar.Search=wn.ui.toolbar.SelectorDialog.extend({init:function(){this._super({title:"Search",execute:function(val){new wn.ui.Search({doctype:val});},});this.set_values(wn.boot.profile.can_search.join(',').split(','));makeselector();}});
|
||||
/*
|
||||
* lib/js/wn/ui/toolbar/report.js
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ wn.ui.toolbar.Search = wn.ui.toolbar.SelectorDialog.extend({
|
|||
this._super({
|
||||
title: "Search",
|
||||
execute: function(val) {
|
||||
selector.set_search(val);
|
||||
selector.show();
|
||||
new wn.ui.Search({doctype:val});
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ def get(arg=None):
|
|||
data = webnotes.form_dict
|
||||
global tables
|
||||
|
||||
if 'query' in data:
|
||||
return run_custom_query(data)
|
||||
|
||||
filters = json.loads(data['filters'])
|
||||
fields = json.loads(data['fields'])
|
||||
tables = get_tables()
|
||||
|
|
@ -61,6 +64,13 @@ def get(arg=None):
|
|||
order by %(order_by)s %(limit)s""" % data
|
||||
return webnotes.conn.sql(query, as_dict=1)
|
||||
|
||||
def run_custom_query(data):
|
||||
"""run custom query"""
|
||||
query = data['query']
|
||||
if '%(key)s' in query:
|
||||
query = query.replace('%(key)s', 'name')
|
||||
return webnotes.conn.sql(query, as_dict=1, debug=1)
|
||||
|
||||
def load_doctypes():
|
||||
"""load all doctypes and roles"""
|
||||
global doctypes, roles
|
||||
|
|
@ -133,13 +143,17 @@ def build_filter_conditions(data, filters, conditions):
|
|||
def build_match_conditions(data, conditions):
|
||||
"""add match conditions if applicable"""
|
||||
match_conditions = []
|
||||
match = True
|
||||
for d in doctypes[data['doctype']]:
|
||||
if d.doctype == 'DocPerm' and d.match:
|
||||
if d.role in roles: # role applicable
|
||||
for v in webnotes.user.defaults.get(d.match, ['**No Match**']):
|
||||
match_conditions.append('`tab%s`.%s="%s"' % (data['doctype'], d.match,v))
|
||||
if d.doctype == 'DocPerm':
|
||||
if d.role in roles:
|
||||
if d.match: # role applicable
|
||||
for v in webnotes.user.defaults.get(d.match, ['**No Match**']):
|
||||
match_conditions.append('`tab%s`.%s="%s"' % (data['doctype'], d.match,v))
|
||||
else:
|
||||
match = False
|
||||
|
||||
if match_conditions:
|
||||
if match_conditions and match:
|
||||
conditions.append('('+ ' or '.join(match_conditions) +')')
|
||||
|
||||
def get_tables():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue