fix(ReportView): Remember column widths

This commit is contained in:
Faris Ansari 2019-04-24 12:38:13 +05:30
parent 08bf94677f
commit d09b26b563
4 changed files with 20 additions and 7 deletions

View file

@ -554,8 +554,8 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
function get_options(fields) {
return fields.map((field) => {
return {label: field.label, value: field.fieldname};
}
}
});
}
const numeric_fields = columns.filter((col, i) => indices.includes(i));
const non_numeric_fields = columns.filter((col, i) => !indices.includes(i))

View file

@ -796,7 +796,20 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
setup_columns() {
const hide_columns = ['docstatus'];
const fields = this.fields.filter(f => !hide_columns.includes(f[0]));
// apply previous column width
let column_widths = null;
if (this.columns) {
column_widths = this.get_column_widths();
}
this.columns = fields.map(f => this.build_column(f)).filter(Boolean);
if (column_widths) {
this.columns = this.columns.map(column => {
column.width = column_widths[column.id] || column.width;
return column;
});
}
}
build_column(c) {

View file

@ -20,7 +20,7 @@
"cookie": "^0.3.1",
"express": "^4.16.2",
"fast-deep-equal": "^2.0.1",
"frappe-datatable": "^1.12.1",
"frappe-datatable": "^1.12.2",
"frappe-gantt": "^0.1.0",
"fuse.js": "^3.2.0",
"highlight.js": "^9.12.0",

View file

@ -1224,10 +1224,10 @@ forwarded@~0.1.2:
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=
frappe-datatable@^1.12.1:
version "1.12.1"
resolved "https://registry.yarnpkg.com/frappe-datatable/-/frappe-datatable-1.12.1.tgz#6efe342346025ffeed822e188a05da6c9c9230c9"
integrity sha512-AC2sJDuJOr0nSfT+w7DPZd7zPW7PHGhg9XxdRNlaAYpy45r3owdJVF+R6lCMQRvFvvzmPMht02EOE6cFpkzLKw==
frappe-datatable@^1.12.2:
version "1.12.2"
resolved "https://registry.yarnpkg.com/frappe-datatable/-/frappe-datatable-1.12.2.tgz#cb7e32defd38426c63278249843baa91dcba79aa"
integrity sha512-e4prKv4klBW9I5iVIesoeJgt4LofzZDfDxP+eqvQN2GZRVs8KYEXgyPhcaH89FfuhIkzVK6kDbMHw+KbGfOJIA==
dependencies:
hyperlist "^1.0.0-beta"
lodash "^4.17.5"