瀏覽代碼

[fix] Hide Editable Grid Columns (#4270)

* [fix] Hide Editable Grid Columns

This fixes a bug where set_column_disp does not hide editable grid columns.

* [fix] Hide Editable Grid Columns - Additional Fixes

This fixes a bug where set_column_disp does not hide editable grid columns.

* [fix] Hide Editable Grid Columns - Additional Fixes

This fixes a bug where set_column_disp does not hide editable grid columns.

* [fix] Hide Editable Grid Columns - Additional Fixes

This fixes a bug where set_column_disp does not hide editable grid columns.

* Codacy Fixes
version-14
Javier Wong 7 年之前
committed by Rushabh Mehta
父節點
當前提交
5c42aa996a
共有 2 個文件被更改,包括 45 次插入2 次删除
  1. +40
    -0
      frappe/public/js/frappe/form/grid.js
  2. +5
    -2
      frappe/public/js/frappe/form/grid_row.js

+ 40
- 0
frappe/public/js/frappe/form/grid.js 查看文件

@@ -350,13 +350,53 @@ frappe.ui.form.Grid = Class.extend({
for(var i=0, l=fieldname.length; i<l; i++) { for(var i=0, l=fieldname.length; i<l; i++) {
var fname = fieldname[i]; var fname = fieldname[i];
me.get_docfield(fname).hidden = show ? 0 : 1; me.get_docfield(fname).hidden = show ? 0 : 1;
this.set_editable_grid_column_disp(fname, show);
} }
} else { } else {
this.get_docfield(fieldname).hidden = show ? 0 : 1; this.get_docfield(fieldname).hidden = show ? 0 : 1;
this.set_editable_grid_column_disp(fieldname, show);
} }


this.refresh(true); this.refresh(true);
}, },
set_editable_grid_column_disp: function(fieldname, show) {
//Hide columns for editable grids
if (this.meta.editable_grid) {
this.grid_rows.forEach(function(row) {
row.columns_list.forEach(function(column) {
//Hide the column specified
if (column.df.fieldname == fieldname) {
if (show) {
column.df.hidden = false;

//Show the static area and hide field area if it is not the editable row
if (row != frappe.ui.form.editable_row) {
column.static_area.show();
column.field_area && column.field_area.toggle(false);
}
//Hide the static area and show field area if it is the editable row
else {
column.static_area.hide();
column.field_area && column.field_area.toggle(true);

//Format the editable column appropriately if it is now visible
if (column.field) {
column.field.refresh();
if (column.field.$input) column.field.$input.toggleClass('input-sm', true);
}
}
}
else {
column.df.hidden = true;
column.static_area.hide();
}
}
});
});
}

this.refresh();
},
toggle_reqd: function(fieldname, reqd) { toggle_reqd: function(fieldname, reqd) {
this.get_docfield(fieldname).reqd = reqd; this.get_docfield(fieldname).reqd = reqd;
this.refresh(); this.refresh();


+ 5
- 2
frappe/public/js/frappe/form/grid_row.js 查看文件

@@ -288,7 +288,7 @@ frappe.ui.form.GridRow = Class.extend({
// whether grid is editable // whether grid is editable
if(this.grid.allow_on_grid_editing() && this.grid.is_editable() && this.doc && show !== false) { if(this.grid.allow_on_grid_editing() && this.grid.is_editable() && this.doc && show !== false) {


// disable other editale row
// disable other editable row
if(frappe.ui.form.editable_row if(frappe.ui.form.editable_row
&& frappe.ui.form.editable_row !== this) { && frappe.ui.form.editable_row !== this) {
frappe.ui.form.editable_row.toggle_editable_row(false); frappe.ui.form.editable_row.toggle_editable_row(false);
@@ -308,7 +308,10 @@ frappe.ui.form.GridRow = Class.extend({
} else { } else {
this.row.toggleClass('editable-row', false); this.row.toggleClass('editable-row', false);
this.columns_list.forEach(function(column) { this.columns_list.forEach(function(column) {
column.static_area.toggle(true);
if (column.df.hidden == false) {
column.static_area.toggle(true);
}

column.field_area && column.field_area.toggle(false); column.field_area && column.field_area.toggle(false);
}); });
frappe.ui.form.editable_row = null; frappe.ui.form.editable_row = null;


Loading…
取消
儲存