From b393248400370f024c42f523a9ca4e7f481edd7b Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Thu, 10 Feb 2022 13:11:39 +0000 Subject: [PATCH] MDL-73837 reportbuilder: use column attributes in system reports. --- reportbuilder/classes/table/custom_report_table.php | 5 ++--- reportbuilder/classes/table/system_report_table.php | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/reportbuilder/classes/table/custom_report_table.php b/reportbuilder/classes/table/custom_report_table.php index e99c955e1a9..c689c91d024 100644 --- a/reportbuilder/classes/table/custom_report_table.php +++ b/reportbuilder/classes/table/custom_report_table.php @@ -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(); } diff --git a/reportbuilder/classes/table/system_report_table.php b/reportbuilder/classes/table/system_report_table.php index 4d706646f35..79709e49b92 100644 --- a/reportbuilder/classes/table/system_report_table.php +++ b/reportbuilder/classes/table/system_report_table.php @@ -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());