Skip to content

Commit

Permalink
Merge pull request #7346 from netchampfaris/report-column-width
Browse files Browse the repository at this point in the history
fix(ReportView): Remember column widths
  • Loading branch information
rmehta committed Apr 24, 2019
2 parents d676783 + d09b26b commit cbd3d56
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions frappe/public/js/frappe/views/reports/query_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
13 changes: 13 additions & 0 deletions frappe/public/js/frappe/views/reports/report_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit cbd3d56

Please sign in to comment.