MDL-72061 reportbuilder: Report actions are shown in action menus

This commit is contained in:
David Matamoros
2022-01-20 10:09:58 +01:00
parent 5897242361
commit 48a6e92700
5 changed files with 43 additions and 19 deletions

View File

@ -125,7 +125,7 @@ final class action {
$this->attributes['data-popup-action'] = json_encode(new popup_action('click', $url)); $this->attributes['data-popup-action'] = json_encode(new popup_action('click', $url));
} }
return $OUTPUT->action_icon($url, $this->icon, null, self::replace_placeholders($this->attributes, $row)); return $OUTPUT->action_link($url, $this->title, null, self::replace_placeholders($this->attributes, $row), $this->icon);
} }
/** /**

View File

@ -18,6 +18,7 @@ declare(strict_types=1);
namespace core_reportbuilder\table; namespace core_reportbuilder\table;
use action_menu;
use core_table\local\filter\filterset; use core_table\local\filter\filterset;
use html_writer; use html_writer;
use moodle_exception; use moodle_exception;
@ -212,11 +213,14 @@ class system_report_table extends base_report_table {
* @return string * @return string
*/ */
private function format_row_actions(stdClass $row): string { private function format_row_actions(stdClass $row): string {
$actions = array_map(static function(action $action) use ($row): string { global $OUTPUT;
return (string) $action->get_action_link($row);
}, $this->report->get_actions());
return implode('', $actions); $menu = new action_menu();
$menu->set_menu_trigger($OUTPUT->pix_icon('a/setting', get_string('actions', 'core_reportbuilder')));
foreach ($this->report->get_actions() as $action) {
$menu->add($action->get_action_link($row));
}
return $OUTPUT->render($menu);
} }
/** /**

View File

@ -95,4 +95,17 @@ class behat_reportbuilder extends behat_base {
$editlabel = get_string('aggregatecolumn', 'core_reportbuilder', $column); $editlabel = get_string('aggregatecolumn', 'core_reportbuilder', $column);
$this->execute('behat_forms::i_set_the_field_to', [$this->escape($editlabel), $this->escape($aggregation)]); $this->execute('behat_forms::i_set_the_field_to', [$this->escape($editlabel), $this->escape($aggregation)]);
} }
/**
* Press a given action from the action menu in a given report row
*
* @When I press :action action in the :row report row
*
* @param string $action
* @param string $row
*/
public function i_press_action_in_the_report_row(string $action, string $row): void {
$this->execute('behat_action_menu::i_open_the_action_menu_in', [$this->escape($row), 'table_row']);
$this->execute('behat_action_menu::i_choose_in_the_open_action_menu', [$this->escape($action)]);
}
} }

View File

@ -75,7 +75,7 @@ Feature: Manage custom reports
| My report | core_user\reportbuilder\datasource\users | | My report | core_user\reportbuilder\datasource\users |
And I log in as "admin" And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration When I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "Edit report details" "link" in the "My report" "table_row" When I press "Edit report details" action in the "My report" report row
And I set the following fields in the "Edit report details" "dialogue" to these values: And I set the following fields in the "Edit report details" "dialogue" to these values:
| Name | My renamed report | | Name | My renamed report |
And I click on "Save" "button" in the "Edit report details" "dialogue" And I click on "Save" "button" in the "Edit report details" "dialogue"
@ -108,7 +108,7 @@ Feature: Manage custom reports
| My report | core_user\reportbuilder\datasource\users | | My report | core_user\reportbuilder\datasource\users |
And I log in as "admin" And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration When I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "Delete report" "link" in the "My report" "table_row" And I press "Delete report" action in the "My report" report row
And I click on "Delete" "button" in the "Delete report" "dialogue" And I click on "Delete" "button" in the "Delete report" "dialogue"
Then I should see "Report deleted" Then I should see "Report deleted"
And I should see "Nothing to display" And I should see "Nothing to display"
@ -130,17 +130,24 @@ Feature: Manage custom reports
Then I should see "Preview" in the "[data-region='core_reportbuilder/report-header']" "css_element" Then I should see "Preview" in the "[data-region='core_reportbuilder/report-header']" "css_element"
And I should not see "Edit" in the "[data-region='core_reportbuilder/report-header']" "css_element" And I should not see "Edit" in the "[data-region='core_reportbuilder/report-header']" "css_element"
Scenario Outline: Access report clicking on the report name or view icon Scenario: Access report clicking on the report name
Given the following "core_reportbuilder > Reports" exist: Given the following "core_reportbuilder > Reports" exist:
| name | source | | name | source |
| My report | core_user\reportbuilder\datasource\users | | My report | core_user\reportbuilder\datasource\users |
When I log in as "admin" When I log in as "admin"
And I navigate to "Reports > Report builder > Custom reports" in site administration And I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "<link>" "link" in the "My report" "table_row" And I click on "My report" "link" in the "My report" "table_row"
Then <previewvisible> "Preview" in the "[data-region='core_reportbuilder/report']" "css_element" Then I should see "Preview" in the "[data-region='core_reportbuilder/report']" "css_element"
And <editvisible> "Edit" in the "[data-region='core_reportbuilder/report']" "css_element" And I should not see "Edit" in the "[data-region='core_reportbuilder/report']" "css_element"
And "button[title='Filters']" "css_element" <filtersvisible> in the "[data-region='core_reportbuilder/report']" "css_element" And "button[title='Filters']" "css_element" should not exist in the "[data-region='core_reportbuilder/report']" "css_element"
Examples:
| link | previewvisible | editvisible | filtersvisible | Scenario: Access report clicking on the view icon
| My report | I should see | I should not see | should not exist | Given the following "core_reportbuilder > Reports" exist:
| View | I should not see | I should not see | should exist | | name | source |
| My report | core_user\reportbuilder\datasource\users |
When I log in as "admin"
And I navigate to "Reports > Report builder > Custom reports" in site administration
And I press "View" action in the "My report" report row
Then I should not see "Preview" in the "[data-region='core_reportbuilder/report']" "css_element"
And I should not see "Edit" in the "[data-region='core_reportbuilder/report']" "css_element"
And "button[title='Filters']" "css_element" should exist in the "[data-region='core_reportbuilder/report']" "css_element"

View File

@ -70,7 +70,7 @@ Feature: Manage custom report schedules
| My report | My schedule | | My report | My schedule |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin" And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab And I click on the "Schedules" dynamic tab
When I click on "Edit schedule details" "link" in the "My schedule" "table_row" When I press "Edit schedule details" action in the "My schedule" report row
And I set the following fields in the "Edit schedule details" "dialogue" to these values: And I set the following fields in the "Edit schedule details" "dialogue" to these values:
| Name | My updated schedule | | Name | My updated schedule |
| Starting from | ##tomorrow 11:00## | | Starting from | ##tomorrow 11:00## |
@ -87,7 +87,7 @@ Feature: Manage custom report schedules
| My report | My schedule | | My report | My schedule |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin" And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab And I click on the "Schedules" dynamic tab
When I click on "Send schedule" "link" in the "My schedule" "table_row" When I press "Send schedule" action in the "My schedule" report row
And I click on "Confirm" "button" in the "Send schedule" "dialogue" And I click on "Confirm" "button" in the "Send schedule" "dialogue"
Then I should see "Schedule sent" Then I should see "Schedule sent"
@ -97,7 +97,7 @@ Feature: Manage custom report schedules
| My report | My schedule | | My report | My schedule |
And I am on the "My report" "reportbuilder > Editor" page logged in as "admin" And I am on the "My report" "reportbuilder > Editor" page logged in as "admin"
And I click on the "Schedules" dynamic tab And I click on the "Schedules" dynamic tab
When I click on "Delete schedule" "link" in the "My schedule" "table_row" When I press "Delete schedule" action in the "My schedule" report row
And I click on "Delete" "button" in the "Delete schedule" "dialogue" And I click on "Delete" "button" in the "Delete schedule" "dialogue"
Then I should see "Schedule deleted" Then I should see "Schedule deleted"
And I should see "Nothing to display" And I should see "Nothing to display"