mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-67685 core_admin: use autocomplete filter in task log
This commit is contained in:
parent
f32913dc65
commit
7c3e78ca3c
3 changed files with 23 additions and 8 deletions
|
@ -20,12 +20,14 @@ use core_reportbuilder\local\filters\date;
|
|||
use core_reportbuilder\local\filters\duration;
|
||||
use core_reportbuilder\local\filters\select;
|
||||
use core_reportbuilder\local\filters\text;
|
||||
use core_reportbuilder\local\filters\autocomplete;
|
||||
use core_reportbuilder\local\helpers\format;
|
||||
use lang_string;
|
||||
use core_reportbuilder\local\entities\base;
|
||||
use core_reportbuilder\local\report\column;
|
||||
use core_reportbuilder\local\report\filter;
|
||||
use stdClass;
|
||||
use core_collator;
|
||||
|
||||
/**
|
||||
* Task log entity class implementation
|
||||
|
@ -241,13 +243,28 @@ class task_log extends base {
|
|||
|
||||
// Name filter (Filter by classname).
|
||||
$filters[] = (new filter(
|
||||
text::class,
|
||||
autocomplete::class,
|
||||
'name',
|
||||
new lang_string('classname', 'tool_task'),
|
||||
$this->get_entity_name(),
|
||||
"{$tablealias}.classname"
|
||||
))
|
||||
->add_joins($this->get_joins());
|
||||
->add_joins($this->get_joins())
|
||||
->set_options_callback(static function(): array {
|
||||
global $DB;
|
||||
$classnames = $DB->get_fieldset_sql('SELECT DISTINCT classname FROM {task_log} ORDER BY classname ASC');
|
||||
|
||||
$options = [];
|
||||
foreach ($classnames as $classname) {
|
||||
if (class_exists($classname)) {
|
||||
$task = new $classname;
|
||||
$options[$classname] = $task->get_name();
|
||||
}
|
||||
}
|
||||
|
||||
core_collator::asort($options);
|
||||
return $options;
|
||||
});
|
||||
|
||||
// Type filter.
|
||||
$filters[] = (new filter(
|
||||
|
|
|
@ -60,8 +60,7 @@ $report = system_report_factory::create(task_logs::class, context_system::instan
|
|||
|
||||
if (!empty($filter)) {
|
||||
$report->set_filter_values([
|
||||
'task_log:name_operator' => \core_reportbuilder\local\filters\text::IS_EQUAL_TO,
|
||||
'task_log:name_value' => $filter,
|
||||
'task_log:name_values' => $filter,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ Feature: View task logs report and use its filters
|
|||
And I navigate to "Server > Tasks > Task logs" in site administration
|
||||
When I click on "Filters" "button"
|
||||
And I set the following fields in the "Class name" "core_reportbuilder > Filter" to these values:
|
||||
| Class name operator | Contains |
|
||||
| Class name value | <name> |
|
||||
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
|
||||
Then I should see "Filters applied"
|
||||
|
@ -27,9 +26,9 @@ Feature: View task logs report and use its filters
|
|||
| Type | Name |
|
||||
| Scheduled | <nonmatch> |
|
||||
Examples:
|
||||
| name | match | nonmatch |
|
||||
| task\\clean_events | Cleanup event monitor events | Incoming email pickup |
|
||||
| task\\pickup_task | Incoming email pickup | Cleanup event monitor events |
|
||||
| name | match | nonmatch |
|
||||
| Cleanup event monitor events | Cleanup event monitor events | Incoming email pickup |
|
||||
| Incoming email pickup | Incoming email pickup | Cleanup event monitor events |
|
||||
|
||||
@javascript
|
||||
# Task duration is dependent on many factors, we are asserting here that no task has a duration >2 minutes.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue