diff --git a/course/classes/output/manage_categories_action_bar.php b/course/classes/output/manage_categories_action_bar.php index 44882bc141c..01314a2d6bf 100644 --- a/course/classes/output/manage_categories_action_bar.php +++ b/course/classes/output/manage_categories_action_bar.php @@ -154,11 +154,17 @@ class manage_categories_action_bar implements \renderable { * - renderedcontent Rendered content to be displayed in line with the tertiary nav */ public function export_for_template(\renderer_base $output): array { - return [ + $data = [ 'urlselect' => $this->get_dropdown($output), 'categoryselect' => $this->get_category_select($output), 'search' => $this->get_search_form(), 'heading' => $this->heading, ]; + + if ($this->searchvalue !== '') { + $backbutton = new \single_button(new moodle_url('/course/management.php'), get_string('back'), 'get'); + $data['backbutton'] = $backbutton->export_for_template($output); + } + return $data; } } diff --git a/course/templates/manage_category_actionbar.mustache b/course/templates/manage_category_actionbar.mustache index a88e40defc6..f35d067c78c 100644 --- a/course/templates/manage_category_actionbar.mustache +++ b/course/templates/manage_category_actionbar.mustache @@ -78,6 +78,12 @@ "helpicon":false, "attributes":[] }, + "backbutton": { + "url": "https://moodle.local/course/management.php", + "icon": "", + "title": "Back", + "classes": "btn btn-secondary" + }, "search": { "action": "https://moodle.local/admin/search.php", "extraclasses": "my-2", @@ -109,8 +115,13 @@ {{> core/url_select }} {{/categoryselect}} - {{#search}} + {{#backbutton}}
+ {{/backbutton}} + {{#search}} + {{/search}} diff --git a/course/tests/behat/course_search.feature b/course/tests/behat/course_search.feature index 6125955b7f5..c5856b6944d 100644 --- a/course/tests/behat/course_search.feature +++ b/course/tests/behat/course_search.feature @@ -20,12 +20,14 @@ Feature: Courses can be searched for and moved in bulk. Scenario: Search courses finds correct results Given I log in as "admin" And I go to the courses management page + And I should not see "Back" in the "region-main" "region" When I set the field "Search" to "Biology" And I press "Search" Then I should see "Biology Y1" And I should see "Biology Y2" And I should not see "English Y1" And I should not see "English Y2" + And I should see "Back" in the "region-main" "region" Scenario: Search courses displays contact names Given the following "users" exist: