mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
Merge branch 'MDL-75729' of https://github.com/paulholden/moodle
This commit is contained in:
commit
42e53489d7
@ -256,6 +256,7 @@ $string['selectareportsource'] = 'Select a report source';
|
||||
$string['sendschedule'] = 'Send schedule';
|
||||
$string['sendscheduleconfirm'] = 'Are you sure you want to queue the schedule \'{$a}\' for sending immediately?';
|
||||
$string['showhide'] = 'Show/hide \'{$a}\'';
|
||||
$string['showhidecard'] = 'Show/hide card';
|
||||
$string['sorting'] = 'Sorting';
|
||||
$string['sorting_help'] = 'Sorting defines the initial sort order of columns in the report. The order can be reversed by toggling the Up/down icon. Users can then define their own sort order by clicking on a column name.';
|
||||
$string['switchedit'] = 'Switch to edit mode';
|
||||
|
@ -336,14 +336,20 @@ class custom_report_table extends base_report_table {
|
||||
$visiblecolumns = $this->report->get_settings_values()['cardview_visiblecolumns'] ?? 1;
|
||||
if ($visiblecolumns < count($this->columns)) {
|
||||
$buttonicon = html_writer::tag('i', '', ['class' => 'fa fa-angle-down']);
|
||||
$buttonatttributes = [
|
||||
|
||||
// We need a cleaned version (without tags/entities) of the first row column to use as toggle button.
|
||||
$rowfirstcolumn = strip_tags(reset($row));
|
||||
$buttontitle = $rowfirstcolumn !== ''
|
||||
? get_string('showhide', 'core_reportbuilder', html_entity_decode($rowfirstcolumn))
|
||||
: get_string('showhidecard', 'core_reportbuilder');
|
||||
|
||||
$button = html_writer::tag('button', $buttonicon, [
|
||||
'type' => 'button',
|
||||
'class' => 'btn collapsed',
|
||||
'title' => get_string('showhide', 'core_reportbuilder', reset($row)),
|
||||
'title' => $buttontitle,
|
||||
'data-toggle' => 'collapse',
|
||||
'data-action' => 'toggle-card'
|
||||
];
|
||||
$button = html_writer::tag('button', $buttonicon, $buttonatttributes);
|
||||
]);
|
||||
$html .= html_writer::tag('td', $button, ['class' => 'card-toggle d-none']);
|
||||
}
|
||||
return $html;
|
||||
|
@ -12,10 +12,10 @@ Feature: Manage card view settings in the report editor
|
||||
| report | uniqueidentifier |
|
||||
| My report | user:fullname |
|
||||
| My report | user:email |
|
||||
| My report | user:city |
|
||||
| My report | user:city |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email | city |
|
||||
| l.smith | Lionel | Smith | lionel@smith.com | Bilbao |
|
||||
| l.smith | Lionel | Smith | lionel@example.com | Bilbao |
|
||||
|
||||
Scenario: Edit card view settings form
|
||||
When I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
|
||||
@ -50,9 +50,11 @@ Feature: Manage card view settings in the report editor
|
||||
And I change window size to "530x812"
|
||||
# Card view should just show user fullname while collapsed with default settings.
|
||||
And I should see "Lionel Smith" in the "reportbuilder-table" "table"
|
||||
And I should not see "lionel@smith.com" in the "reportbuilder-table" "table"
|
||||
And I press "Show/hide 'Lionel Smith'"
|
||||
And I should see "lionel@smith.com" in the "reportbuilder-table" "table"
|
||||
And I should not see "lionel@example.com" in the "reportbuilder-table" "table"
|
||||
And I should not see "Bilbao" in the "reportbuilder-table" "table"
|
||||
And I click on "Show/hide 'Lionel Smith'" "button" in the "reportbuilder-table" "table"
|
||||
And I should see "Lionel Smith" in the "reportbuilder-table" "table"
|
||||
And I should see "lionel@example.com" in the "reportbuilder-table" "table"
|
||||
And I should see "Bilbao" in the "reportbuilder-table" "table"
|
||||
# Card view do not show first column title with default settings.
|
||||
And "[data-cardtitle=\"Full name\"]" "css_element" should not exist in the "reportbuilder-table" "table"
|
||||
@ -70,9 +72,39 @@ Feature: Manage card view settings in the report editor
|
||||
And I press "Switch to preview mode"
|
||||
And I change window size to "530x812"
|
||||
And I should see "Lionel Smith" in the "reportbuilder-table" "table"
|
||||
And I should see "lionel@smith.com" in the "reportbuilder-table" "table"
|
||||
And I should see "lionel@example.com" in the "reportbuilder-table" "table"
|
||||
And I should see "Bilbao" in the "reportbuilder-table" "table"
|
||||
And "[data-cardtitle=\"Full name\"]" "css_element" should exist in the "reportbuilder-table" "table"
|
||||
And "[data-cardtitle=\"Email address\"]" "css_element" should exist in the "reportbuilder-table" "table"
|
||||
And "[data-cardtitle=\"City/town\"]" "css_element" should exist in the "reportbuilder-table" "table"
|
||||
And "Show/hide 'Lionel Smith'" "button" should not exist
|
||||
|
||||
Scenario Outline: Toggle card view according to content of first column
|
||||
Given the following "core_reportbuilder > Reports" exist:
|
||||
| name | source | default |
|
||||
| New report | core_user\reportbuilder\datasource\users | 0 |
|
||||
And the following "core_reportbuilder > Columns" exist:
|
||||
| report | uniqueidentifier |
|
||||
| New report | <firstcolumn> |
|
||||
| New report | user:email |
|
||||
And the following "core_reportbuilder > Conditions" exist:
|
||||
| report | uniqueidentifier |
|
||||
| New report | user:username |
|
||||
When I am on the "New report" "reportbuilder > Editor" page logged in as "admin"
|
||||
And I click on "Show/hide 'Conditions'" "button"
|
||||
# Make sure we're only viewing our test user in the report.
|
||||
And I set the following fields in the "Username" "core_reportbuilder > Condition" to these values:
|
||||
| Username operator | Is equal to |
|
||||
| Username value | l.smith |
|
||||
And I click on "Apply" "button" in the "[data-region='settings-conditions']" "css_element"
|
||||
# Now use the card show/hide toggle.
|
||||
And I change window size to "530x812"
|
||||
And I press "Switch to preview mode"
|
||||
And I should not see "lionel@example.com" in the "reportbuilder-table" "table"
|
||||
And I click on "<togglebutton>" "button" in the "reportbuilder-table" "table"
|
||||
Then I should see "lionel@example.com" in the "reportbuilder-table" "table"
|
||||
Examples:
|
||||
| firstcolumn | togglebutton |
|
||||
| user:fullnamewithlink | Show/hide 'Lionel Smith' |
|
||||
| user:firstname | Show/hide 'Lionel' |
|
||||
| user:idnumber | Show/hide card |
|
||||
|
Loading…
x
Reference in New Issue
Block a user