-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inddex reports #35605
Fix inddex reports #35605
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,12 +15,22 @@ class MultiTabularReport(DatespanMixin, CustomProjectReport, GenericTabularRepor | |
exportable = True | ||
exportable_all = True | ||
export_only = False | ||
fix_left_col = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and |
||
|
||
@property | ||
def data_providers(self): | ||
# data providers should supply a title, slug, headers, and rows | ||
return [] | ||
|
||
@property | ||
def fixed_cols_spec(self): | ||
""" | ||
Override | ||
Returns a dict formatted like: | ||
dict(num=<num_cols_to_fix>, width=<width_of_total_fixed_cols>) | ||
""" | ||
return dict(num=1, width=130) | ||
|
||
@property | ||
def report_context(self): | ||
|
||
|
@@ -34,10 +44,11 @@ def _to_context_dict(data_provider): | |
'rows': list(data_provider.rows), | ||
} | ||
|
||
context = { | ||
context = super().report_context | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pulls in the |
||
context.update({ | ||
'name': self.name, | ||
'export_only': self.export_only | ||
} | ||
}) | ||
if not self.export_only and not self.needs_filters: | ||
try: | ||
context['data_providers'] = list(map(_to_context_dict, self.data_providers)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,9 @@ | ||
hqDefine("inddex/js/main", function () { | ||
$(function () { | ||
$("[data-report-table]").each(function (table) { | ||
const $table = $(table), | ||
reportTable = $table.data("report-table"); | ||
|
||
if (!reportTable || !reportTable.datatables) { | ||
return; | ||
} | ||
|
||
let options = { | ||
dataTableElem: '#report_table_' + reportTable.slug, | ||
defaultRows: reportTable.default_rows || 10, | ||
startAtRowNum: reportTable.default_rows || 10, | ||
showAllRowsOption: reportTable.show_all_rows, | ||
loadingTemplateSelector: '#js-template-loading-report', | ||
defaultSort: true, | ||
autoWidth: reportTable.headers.auto_width, | ||
fixColumns: true, | ||
fixColsNumLeft: 1, | ||
fixColsWidth: 130, | ||
}; | ||
if (reportTable.headers.render_aoColumns) { | ||
options.aoColumns = reportTable.headers.render_aoColumns; | ||
} | ||
if (reportTable.headers.custom_sort) { | ||
options.customSort = reportTable.headers.custom_sort; | ||
} | ||
if (reportTable.pagination.is_on) { | ||
options.ajaxSource = reportTable.pagination.source; | ||
options.ajaxParams = reportTable.pagination.params; | ||
} | ||
if (reportTable.bad_request_error_text) { | ||
options.badRequestErrorText = "<span class='label label-danger'>Sorry!</span> " + reportTable.bad_request_error_text; | ||
} | ||
|
||
var reportTables = hqImport("reports/js/bootstrap3/datatables_config").HQReportDataTables(options); | ||
var standardHQReport = hqImport("reports/js/bootstrap3/standard_hq_report").getStandardHQReport(); | ||
if (typeof standardHQReport !== 'undefined') { | ||
standardHQReport.handleTabularReportCookies(reportTables); | ||
} | ||
reportTables.render(); | ||
const initialPageData = hqImport("hqwebapp/js/initial_page_data"), | ||
tabular = hqImport("reports/js/bootstrap3/tabular"); | ||
$(document).on('ajaxSuccess', function (e, xhr, ajaxOptions, data) { | ||
$(".datatable[data-slug]").each(function (index, table) { | ||
Check failure on line 5 in custom/inddex/static/inddex/js/main.js GitHub Actions / Lint Javascript
|
||
tabular.renderPage(data.slug, initialPageData.get("report_table_js_options")); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
inddex/main
is now importing this file, it gets this event handler, which it doesn't need, and which errors sometimes (presumably because there are ajax requests happening that aren't the same as what this handler expects). But checking fordata.slug
is pretty innocuous and fixes the issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner to put the event handlers in an
init
function, and make code that imports this module explicitly call it, but I wanted to limit changes to core reports as much as possible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of putting this comment in the code? This seems far away from
inddex/main
, and it might be nice to know why this check was added.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - 715c441