Skip to content

Commit

Permalink
MDL-81754 reportbuilder: consistent filter field comparison labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed May 1, 2024
1 parent 792698a commit 260b786
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
7 changes: 5 additions & 2 deletions lang/en/reportbuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
$string['filterdatebefore'] = 'Before';
$string['filterdatecurrent'] = 'Current';
$string['filterdatedays'] = 'day(s)';
$string['filterdatefrom'] = 'Date from';
$string['filterdatefuture'] = 'In the future';
$string['filterdatehours'] = 'hour(s)';
$string['filterdatelast'] = 'Last';
Expand All @@ -135,14 +134,14 @@
$string['filterdatenext'] = 'Next';
$string['filterdatepast'] = 'In the past';
$string['filterdateseconds'] = 'second(s)';
$string['filterdateto'] = 'Date to';
$string['filterdateweeks'] = 'week(s)';
$string['filterdateyears'] = 'year(s)';
$string['filterdeleted'] = 'Deleted filter \'{$a}\'';
$string['filterdoesnotcontain'] = 'Does not contain';
$string['filterendswith'] = 'Ends with';
$string['filterequalorgreaterthan'] = 'Greater than or equal';
$string['filterequalorlessthan'] = 'Less than or equal';
$string['filterfieldfrom'] = '{$a} from';
$string['filterfieldoperator'] = '{$a} operator';
$string['filterfieldto'] = '{$a} to';
$string['filterfieldunit'] = '{$a} unit';
Expand Down Expand Up @@ -287,3 +286,7 @@

// Deprecated since Moodle 4.4.
$string['filterdurationunit'] = '{$a} unit';

// Deprecated since Moodle 4.5.
$string['filterdatefrom'] = 'Date from';
$string['filterdateto'] = 'Date to';
8 changes: 4 additions & 4 deletions reportbuilder/classes/local/filters/date.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ public function setup_form(MoodleQuickForm $mform): void {
->setHiddenLabel(true);

// Date selectors for range operator.
$mform->addElement('date_selector', "{$this->name}_from", get_string('filterdatefrom', 'core_reportbuilder'),
['optional' => true]);
$mform->addElement('date_selector', "{$this->name}_from",
get_string('filterfieldfrom', 'core_reportbuilder', $this->get_header()), ['optional' => true]);
$mform->setType("{$this->name}_from", PARAM_INT);
$mform->setDefault("{$this->name}_from", 0);
$mform->hideIf("{$this->name}_from", "{$this->name}_operator", 'neq', self::DATE_RANGE);

$mform->addElement('date_selector', "{$this->name}_to", get_string('filterdateto', 'core_reportbuilder'),
['optional' => true]);
$mform->addElement('date_selector', "{$this->name}_to",
get_string('filterfieldto', 'core_reportbuilder', $this->get_header()), ['optional' => true]);
$mform->setType("{$this->name}_to", PARAM_INT);
$mform->setDefault("{$this->name}_to", 0);
$mform->hideIf("{$this->name}_to", "{$this->name}_operator", 'neq', self::DATE_RANGE);
Expand Down
4 changes: 3 additions & 1 deletion reportbuilder/classes/local/filters/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public function setup_form(MoodleQuickForm $mform): void {
$mform->setType("{$this->name}_operator", PARAM_INT);
$mform->setDefault("{$this->name}_operator", self::USER_ANY);

// Specific user selection.
$valuelabel = get_string('filterfieldvalue', 'core_reportbuilder', $this->get_header());
$options = [
'ajax' => 'core_user/form_user_selector',
'multiple' => true,
Expand All @@ -80,7 +82,7 @@ public function setup_form(MoodleQuickForm $mform): void {
return fullname($user, has_capability('moodle/site:viewfullnames', context_system::instance()));
}
];
$mform->addElement('autocomplete', "{$this->name}_value", get_string('user'), [], $options)
$mform->addElement('autocomplete', "{$this->name}_value", $valuelabel, [], $options)
->setHiddenLabel(true);
$mform->hideIf("{$this->name}_value", "{$this->name}_operator", 'neq', self::USER_SELECT);
}
Expand Down
19 changes: 19 additions & 0 deletions reportbuilder/tests/behat/customreports.feature
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,25 @@ Feature: Manage custom reports
| Report source | Users |
| Tags | Cat |

Scenario: Filter custom reports by date
Given the following "core_reportbuilder > Report" exists:
| name | My report |
| source | core_user\reportbuilder\datasource\users |
And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "Filters" "button"
And I set the following fields in the "Time created" "core_reportbuilder > Filter" to these values:
| Time created operator | Range |
| Time created from | ##2 days ago## |
| Time created to | ##tomorrow## |
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 report" in the "Reports list" "table"
And I set the field "Time created to" in the "Time created" "core_reportbuilder > Filter" to "##yesterday##"
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Nothing to display"
And "Reports list" "table" should not exist

Scenario: Custom report tags are not displayed if tagging is disabled
Given the following config values are set as admin:
| usetags | 0 |
Expand Down

0 comments on commit 260b786

Please sign in to comment.