This commit is contained in:
Ilya Tregubov 2024-05-09 10:51:27 +08:00
commit 52f49f3d7e
4 changed files with 31 additions and 7 deletions

View File

@ -126,7 +126,6 @@ $string['filterdateafter'] = 'After';
$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';
@ -135,7 +134,6 @@ $string['filterdatemonths'] = 'month(s)';
$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}\'';
@ -143,6 +141,7 @@ $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';
@ -287,3 +286,7 @@ $string['viewreport'] = 'View report';
// Deprecated since Moodle 4.4.
$string['filterdurationunit'] = '{$a} unit';
// Deprecated since Moodle 4.5.
$string['filterdatefrom'] = 'Date from';
$string['filterdateto'] = 'Date to';

View File

@ -151,14 +151,14 @@ class date extends base {
->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);

View File

@ -72,6 +72,8 @@ class user extends base {
$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,
@ -80,7 +82,7 @@ class user extends base {
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);
}

View File

@ -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 |