mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-84016 reportbuilder: column methods for setting help icons.
This change exposes the underlying table library API for setting help icon for table headers, via column instance getter/setter. Support added for rendering said icons in system reports.
This commit is contained in:
parent
bcf06a0484
commit
0c090789f9
3 changed files with 38 additions and 5 deletions
7
.upgradenotes/MDL-84016-2025012911500034.yml
Normal file
7
.upgradenotes/MDL-84016-2025012911500034.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
issueNumber: MDL-84016
|
||||
notes:
|
||||
core_reportbuilder:
|
||||
- message: >-
|
||||
Columns added to system reports can render help icons in table headers
|
||||
via `[set|get]_help_icon` column instance methods
|
||||
type: improved
|
|
@ -20,6 +20,7 @@ namespace core_reportbuilder\local\report;
|
|||
|
||||
use core\exception\coding_exception;
|
||||
use core\lang_string;
|
||||
use core\output\help_icon;
|
||||
use core_reportbuilder\local\helpers\{aggregation, database, join_trait};
|
||||
use core_reportbuilder\local\aggregation\base;
|
||||
use core_reportbuilder\local\models\column as column_model;
|
||||
|
@ -89,6 +90,9 @@ final class column {
|
|||
/** @var array $attributes */
|
||||
private $attributes = [];
|
||||
|
||||
/** @var help_icon|null $helpicon */
|
||||
private $helpicon = null;
|
||||
|
||||
/** @var bool $available Used to know if column is available to the current user or not */
|
||||
private $available = true;
|
||||
|
||||
|
@ -699,6 +703,26 @@ final class column {
|
|||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set column help icon
|
||||
*
|
||||
* @param help_icon $helpicon
|
||||
* @return self
|
||||
*/
|
||||
public function set_help_icon(help_icon $helpicon): self {
|
||||
$this->helpicon = $helpicon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return column help icon
|
||||
*
|
||||
* @return help_icon|null
|
||||
*/
|
||||
public function get_help_icon(): ?help_icon {
|
||||
return $this->helpicon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return available state of the column for the current user. For instance the column may be added to a report with the
|
||||
* expectation that only some users are able to see it
|
||||
|
|
|
@ -109,7 +109,7 @@ class system_report_table extends base_report_table {
|
|||
$groupby = $fields;
|
||||
}
|
||||
|
||||
$columnheaders = $columnsattributes = [];
|
||||
$columnheaders = $columnattributes = $columnicons = [];
|
||||
|
||||
// Check whether report has checkbox toggle defined, note that select all is excluded during download.
|
||||
if (($checkbox = $this->report->get_checkbox_toggleall(true)) && !$this->is_downloading()) {
|
||||
|
@ -144,8 +144,9 @@ class system_report_table extends base_report_table {
|
|||
$this->no_sorting($column->get_column_alias());
|
||||
}
|
||||
|
||||
// Generate column attributes to be included in each cell.
|
||||
$columnsattributes[$column->get_column_alias()] = $column->get_attributes();
|
||||
// Generate column attributes/icons for the table.
|
||||
$columnattributes[$column->get_column_alias()] = $column->get_attributes();
|
||||
$columnicons[] = $column->get_help_icon();
|
||||
}
|
||||
|
||||
// If the report has any actions then append appropriate column, note that actions are excluded during download.
|
||||
|
@ -159,8 +160,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);
|
||||
// Add column attributes/icons to the table.
|
||||
$this->set_columnsattributes($columnattributes);
|
||||
$this->define_help_for_headers($columnicons);
|
||||
|
||||
// Initial table sort column.
|
||||
if ($sortcolumn = $this->report->get_initial_sort_column()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue