[grid] render_on_display

This commit is contained in:
Rushabh Mehta 2015-02-25 15:08:06 +05:30
parent 2e53a15bda
commit 583cb4d155
3 changed files with 25 additions and 5 deletions

View file

@ -222,6 +222,12 @@ class Document(BaseDocument):
else:
self.db_update()
self.update_children()
self.run_post_save_methods()
return self
def update_children(self):
# children
child_map = {}
ignore_children_type = self.flags.ignore_children_type or []
@ -241,10 +247,6 @@ class Document(BaseDocument):
frappe.db.sql("""delete from `tab%s` where parent=%s and parenttype=%s""" \
% (df.options, '%s', '%s'), (self.name, self.doctype))
self.run_post_save_methods()
return self
def set_new_name(self):
"""Calls `frappe.naming.se_new_name` for parent and child docs."""
set_new_name(self)

View file

@ -454,6 +454,7 @@ frappe.ui.form.GridRow = Class.extend({
return this;
},
show_form: function() {
var me = this;
if(!this.form_panel) {
this.form_panel = $('<div class="form-in-grid"></div>')
.appendTo(this.wrapper);
@ -474,6 +475,7 @@ frappe.ui.form.GridRow = Class.extend({
}
cur_frm.cur_grid = this;
this.wrapper.addClass("grid-row-open");
me.frm.script_manager.trigger(me.doc.parentfield + "_on_form_rendered");
},
hide_form: function() {
// if(this.form_panel)
@ -527,7 +529,6 @@ frappe.ui.form.GridRow = Class.extend({
this.toggle_add_delete_button_display(this.wrapper);
this.grid.open_grid_row = this;
this.frm.script_manager.trigger(this.doc.parentfield + "_on_form_rendered", this);
},
make_form: function() {
if(!this.form_area) {
@ -581,5 +582,17 @@ frappe.ui.form.GridRow = Class.extend({
return visible ? df : null;
});
return visible_columns;
},
toggle_reqd: function(fieldname, reqd) {
var field = this.fields_dict[fieldname];
field.df.reqd = reqd ? 1 : 0;
field.refresh();
this.layout.refresh_sections();
},
toggle_display: function(fieldname, show) {
var field = this.fields_dict[fieldname];
field.df.hidden = show ? 0 : 1;
field.refresh();
this.layout.refresh_sections();
}
});

View file

@ -305,3 +305,8 @@ _f.Frm.prototype.get_formatted = function(fieldname) {
frappe.meta.get_docfield(this.doctype, fieldname, this.docname),
{no_icon:true}, this.doc);
}
_f.Frm.prototype.open_grid_row = function() {
return frappe.ui.form.get_open_grid_form();
}