MDL-73837 reportbuilder: use column attributes in system reports.

This commit is contained in:
Paul Holden
2022-02-10 13:17:01 +00:00
parent 6652ec135b
commit b393248400
2 changed files with 9 additions and 4 deletions
@@ -94,8 +94,7 @@ class custom_report_table extends base_report_table {
$hasaggregatedcolumns = !empty($aggregatedcolumns);
$showuniquerows = !$hasaggregatedcolumns && $this->persistent->get('uniquerows');
$columnheaders = [];
$columnsattributes = [];
$columnheaders = $columnsattributes = [];
foreach ($columns as $column) {
$columnheading = $column->get_persistent()->get_formatted_heading($this->report->get_context());
$columnheaders[$column->get_column_alias()] = $columnheading !== '' ? $columnheading : $column->get_title();
@@ -127,7 +126,7 @@ class custom_report_table extends base_report_table {
$column->add_attributes(['data-cardviewhidden' => '']);
}
// Generate row attributes to be included in each cell.
// Generate column attributes to be included in each cell.
$columnsattributes[$column->get_column_alias()] = $column->get_attributes();
}
@@ -94,7 +94,7 @@ class system_report_table extends base_report_table {
array_flip($this->report->get_exclude_columns_for_download()));
}
$columnheaders = [];
$columnheaders = $columnsattributes = [];
$columnindex = 1;
foreach ($columns as $identifier => $column) {
$column->set_index($columnindex++);
@@ -115,6 +115,9 @@ class system_report_table extends base_report_table {
if (!$column->get_is_sortable()) {
$this->no_sorting($column->get_column_alias());
}
// Generate column attributes to be included in each cell.
$columnsattributes[$column->get_column_alias()] = $column->get_attributes();
}
// If the report has any actions then append appropriate column, note that actions are excluded during download.
@@ -128,6 +131,9 @@ class system_report_table extends base_report_table {
$this->define_columns(array_keys($columnheaders));
$this->define_headers(array_values($columnheaders));
// Add column attributes to the table.
$this->set_columnsattributes($columnsattributes);
// Initial table sort column.
if ($sortcolumn = $this->report->get_initial_sort_column()) {
$this->sortable(true, $sortcolumn->get_column_alias(), $this->report->get_initial_sort_direction());