From 606bb89188cee570fe2e33c2f4ace315b79688a2 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 25 Apr 2025 15:19:01 +0100 Subject: [PATCH] MDL-85286 reportbuilder: schedule report filter by enabled state. --- .../local/systemreports/report_schedules.php | 23 +++++++++++-------- .../tests/behat/schedules.feature | 23 +++++++++++++++++-- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/public/reportbuilder/classes/local/systemreports/report_schedules.php b/public/reportbuilder/classes/local/systemreports/report_schedules.php index 2a443881696..58167a184d4 100644 --- a/public/reportbuilder/classes/local/systemreports/report_schedules.php +++ b/public/reportbuilder/classes/local/systemreports/report_schedules.php @@ -26,14 +26,10 @@ use stdClass; use core_reportbuilder\permission; use core_reportbuilder\system_report; use core_reportbuilder\local\entities\user; -use core_reportbuilder\local\filters\date; -use core_reportbuilder\local\filters\text; +use core_reportbuilder\local\filters\{boolean_select, date, text}; use core_reportbuilder\local\helpers\format; -use core_reportbuilder\local\models\report; -use core_reportbuilder\local\models\schedule; -use core_reportbuilder\local\report\action; -use core_reportbuilder\local\report\column; -use core_reportbuilder\local\report\filter; +use core_reportbuilder\local\models\{report, schedule}; +use core_reportbuilder\local\report\{action, column, filter}; use core_reportbuilder\output\schedule_name_editable; /** @@ -253,14 +249,23 @@ class report_schedules extends system_report { protected function add_filters(): void { $tablealias = $this->get_main_table_alias(); + // Enabled filter. + $this->add_filter(new filter( + boolean_select::class, + 'enabled', + new lang_string('enabled', 'core_admin'), + $this->get_schedule_entity_name(), + "{$tablealias}.enabled", + )); + // Name filter. - $this->add_filter((new filter( + $this->add_filter(new filter( text::class, 'name', new lang_string('name'), $this->get_schedule_entity_name(), "{$tablealias}.name" - ))); + )); // Time last sent filter. $this->add_filter((new filter( diff --git a/public/reportbuilder/tests/behat/schedules.feature b/public/reportbuilder/tests/behat/schedules.feature index 1ff6daf9bf0..ca539b97a80 100644 --- a/public/reportbuilder/tests/behat/schedules.feature +++ b/public/reportbuilder/tests/behat/schedules.feature @@ -1,4 +1,4 @@ -@core_reportbuilder @javascript +@core @core_reportbuilder @javascript Feature: Manage custom report schedules In order ot manage custom report schedules As an admin @@ -107,7 +107,25 @@ Feature: Manage custom report schedules | Time last sent | | Time next send | - Scenario: Toggle report schedule + Scenario: Filter report schedules by enabled state + Given the following "core_reportbuilder > Schedules" exist: + | report | name | enabled | + | My report | My schedule 1 | 1 | + | My report | My schedule 2 | 0 | + And I am on the "My report" "reportbuilder > Editor" page logged in as "admin" + And I click on the "Schedules" dynamic tab + When I click on "Filters" "button" + And I set the field "Enabled operator" in the "Enabled" "core_reportbuilder > Filter" to "Yes" + And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element" + Then I should see "Filters applied" + And I should see "My schedule 1" in the "Report schedules" "table" + And I should not see "My schedule 2" in the "Report schedules" "table" + And I set the field "Enabled operator" in the "Enabled" "core_reportbuilder > Filter" to "No" + And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element" + And I should not see "My schedule 1" in the "Report schedules" "table" + And I should see "My schedule 2" in the "Report schedules" "table" + + Scenario: Toggle report schedule enabled state Given the following "core_reportbuilder > Schedules" exist: | report | name | | My report | My schedule | @@ -116,6 +134,7 @@ Feature: Manage custom report schedules When I click on "Disable schedule" "field" in the "My schedule" "table_row" Then the "class" attribute of "My schedule" "table_row" should contain "text-muted" And I click on "Enable schedule" "field" in the "My schedule" "table_row" + And the "class" attribute of "My schedule" "table_row" should be set Scenario: Edit report schedule Given the following "core_reportbuilder > Schedules" exist: