Преглед изворни кода

grid recursive change bugfix

version-14
Rushabh Mehta пре 13 година
родитељ
комит
3f1e1fa01b
7 измењених фајлова са 37 додато и 13 уклоњено
  1. +1
    -0
      build.json
  2. +2
    -3
      js/legacy/widgets/form/fields.js
  3. +2
    -2
      js/legacy/widgets/form/grid.js
  4. +11
    -0
      js/wn/tmp.js
  5. +1
    -1
      js/wn/ui/toolbar.min.js
  6. +1
    -2
      js/wn/ui/toolbar/search.js
  7. +19
    -5
      py/webnotes/widgets/doclistview.py

+ 1
- 0
build.json Прегледај датотеку

@@ -136,6 +136,7 @@
"lib/js/wn/ui/appframe.js", "lib/js/wn/ui/appframe.js",
"lib/js/wn/ui/dialog.js", "lib/js/wn/ui/dialog.js",
"lib/js/wn/ui/button.js", "lib/js/wn/ui/button.js",
"lib/js/wn/ui/search.js",
"lib/js/legacy/widgets/dialog.js", "lib/js/legacy/widgets/dialog.js",
"lib/js/legacy/widgets/layout.js", "lib/js/legacy/widgets/layout.js",
"lib/js/legacy/widgets/tabbedpage.js", "lib/js/legacy/widgets/tabbedpage.js",


+ 2
- 3
js/legacy/widgets/form/fields.js Прегледај датотеку

@@ -404,7 +404,7 @@ DataField.prototype.make_input = function() {
this.input.name = this.df.fieldname; this.input.name = this.df.fieldname;
$(this.input).change(function() { $(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) { this.set_value = function(val) {
@@ -694,7 +694,6 @@ LinkField.prototype.setup_buttons = function() {
} }


LinkField.prototype.set_input_value = function(val) { LinkField.prototype.set_input_value = function(val) {
var me = this; var me = this;
var from_selector = false; var from_selector = false;
if(selector && selector.display) from_selector = true; 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(); _f.cur_grid_cell.grid.cell_deselect();
// run trigger if value is cleared // run trigger if value is cleared
if(!val) {
if(locals[me.doctype][me.docname][me.df.fieldname] && !val) {
me.run_trigger(); me.run_trigger();
return; return;
} }


+ 2
- 2
js/legacy/widgets/form/grid.js Прегледај датотеку

@@ -364,14 +364,14 @@ _f.Grid.prototype.remove_template = function(cell) {
if(!hc.template)return; if(!hc.template)return;
if(!hc.template.activated)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 // for calendar popup. the value will come after this
_f.grid_date_cell = cell; _f.grid_date_cell = cell;
setTimeout('_f.grid_refresh_date()', 100); setTimeout('_f.grid_refresh_date()', 100);
} else { } else {
var input = hc.template.txt || hc.template.input; var input = hc.template.txt || hc.template.input;
_f.grid_refresh_field(hc.template, input) _f.grid_refresh_field(hc.template, input)
}
}*/


if(hc.template && hc.template.wrapper.parentNode) if(hc.template && hc.template.wrapper.parentNode)
cell.div.removeChild(hc.template.wrapper); cell.div.removeChild(hc.template.wrapper);


+ 11
- 0
js/wn/tmp.js Прегледај датотеку

@@ -104,4 +104,15 @@ render_grid: function() {
show: function(label) { show: function(label) {
return this.change_to(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)
}
}); });

+ 1
- 1
js/wn/ui/toolbar.min.js Прегледај датотеку

@@ -12,7 +12,7 @@ wn.ui.toolbar.NewDialog=wn.ui.toolbar.SelectorDialog.extend({init:function(){thi
/* /*
* lib/js/wn/ui/toolbar/search.js * 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 * lib/js/wn/ui/toolbar/report.js
*/ */


+ 1
- 2
js/wn/ui/toolbar/search.js Прегледај датотеку

@@ -27,8 +27,7 @@ wn.ui.toolbar.Search = wn.ui.toolbar.SelectorDialog.extend({
this._super({ this._super({
title: "Search", title: "Search",
execute: function(val) { execute: function(val) {
selector.set_search(val);
selector.show();
new wn.ui.Search({doctype:val});
}, },
}); });


+ 19
- 5
py/webnotes/widgets/doclistview.py Прегледај датотеку

@@ -39,6 +39,9 @@ def get(arg=None):
data = webnotes.form_dict data = webnotes.form_dict
global tables global tables
if 'query' in data:
return run_custom_query(data)
filters = json.loads(data['filters']) filters = json.loads(data['filters'])
fields = json.loads(data['fields']) fields = json.loads(data['fields'])
tables = get_tables() tables = get_tables()
@@ -61,6 +64,13 @@ def get(arg=None):
order by %(order_by)s %(limit)s""" % data order by %(order_by)s %(limit)s""" % data
return webnotes.conn.sql(query, as_dict=1) 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(): def load_doctypes():
"""load all doctypes and roles""" """load all doctypes and roles"""
global doctypes, roles global doctypes, roles
@@ -133,13 +143,17 @@ def build_filter_conditions(data, filters, conditions):
def build_match_conditions(data, conditions): def build_match_conditions(data, conditions):
"""add match conditions if applicable""" """add match conditions if applicable"""
match_conditions = [] match_conditions = []
match = True
for d in doctypes[data['doctype']]: 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) +')') conditions.append('('+ ' or '.join(match_conditions) +')')


def get_tables(): def get_tables():


Loading…
Откажи
Сачувај