mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
Merge branch 'MDL-74721' of https://github.com/lostrogit/moodle
This commit is contained in:
commit
d95071b537
@ -58,4 +58,9 @@ $settings->add(new admin_setting_configtext(
|
||||
new lang_string('customreportslimit', 'core_reportbuilder'),
|
||||
new lang_string('customreportslimit_desc', 'core_reportbuilder'), 0, PARAM_INT));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox(
|
||||
'customreportsliveediting',
|
||||
new lang_string('customreportsliveediting', 'core_reportbuilder'),
|
||||
new lang_string('customreportsliveediting_desc', 'core_reportbuilder'), 1));
|
||||
|
||||
$ADMIN->add('reportbuilder', $settings);
|
||||
|
@ -83,6 +83,9 @@ $string['customfieldcolumn'] = '{$a}';
|
||||
$string['customreports'] = 'Custom reports';
|
||||
$string['customreportslimit'] = 'Custom reports limit';
|
||||
$string['customreportslimit_desc'] = 'The number of custom reports may be limited for performance reasons. If set to zero, then there is no limit.';
|
||||
$string['customreportsliveediting'] = 'Custom reports live editing';
|
||||
$string['customreportsliveediting_desc'] = 'If enabled, users can view report data while editing the report. This may be disabled for performance reasons.';
|
||||
$string['customreportsliveeditingdisabled'] = 'Viewing of report data while editing is disabled by the site administrator. Switch to preview mode to view the report.';
|
||||
$string['customreportssettings'] = 'Custom report settings';
|
||||
$string['deleteaudience'] = 'Delete audience \'{$a}\'';
|
||||
$string['deleteaudienceconfirm'] = 'Are you sure you want to delete the audience \'{$a}\'?';
|
||||
|
@ -78,10 +78,11 @@ class custom_report_table extends base_report_table {
|
||||
$this->showdownloadbuttonsat = [TABLE_P_BOTTOM];
|
||||
$this->is_downloading($download ?? null, $this->persistent->get_formatted_name());
|
||||
|
||||
// Retrieve all report columns, exit early if there are none.
|
||||
// Retrieve all report columns, exit early if there are none. Defining empty columns prevents errors during out().
|
||||
$columns = $this->get_active_columns();
|
||||
if (empty($columns)) {
|
||||
$this->init_sql('*', "{{$maintable}} {$maintablealias}", [], '1=0', []);
|
||||
$this->define_columns([0]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -281,7 +282,16 @@ class custom_report_table extends base_report_table {
|
||||
echo html_writer::end_tag('div');
|
||||
$this->wrap_html_finish();
|
||||
|
||||
$notification = (new notification(get_string('nothingtodisplay'), notification::NOTIFY_INFO, false))
|
||||
// With the live editing disabled we need to notify user that data is shown only in preview mode.
|
||||
if ($this->editing && !self::show_live_editing()) {
|
||||
$notificationmsg = get_string('customreportsliveeditingdisabled', 'core_reportbuilder');
|
||||
$notificationtype = notification::NOTIFY_WARNING;
|
||||
} else {
|
||||
$notificationmsg = get_string('nothingtodisplay');
|
||||
$notificationtype = notification::NOTIFY_INFO;
|
||||
}
|
||||
|
||||
$notification = (new notification($notificationmsg, $notificationtype, false))
|
||||
->set_extra_classes(['mt-3']);
|
||||
echo $OUTPUT->render($notification);
|
||||
|
||||
@ -315,4 +325,35 @@ class custom_report_table extends base_report_table {
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overriding this method to handle live editing setting.
|
||||
* @param int $pagesize
|
||||
* @param bool $useinitialsbar
|
||||
* @param string $downloadhelpbutton
|
||||
*/
|
||||
public function out($pagesize, $useinitialsbar, $downloadhelpbutton = '') {
|
||||
$this->pagesize = $pagesize;
|
||||
$this->setup();
|
||||
|
||||
// If the live editing setting is disabled, we not need to fetch custom report data except in preview mode.
|
||||
if (!$this->editing || self::show_live_editing()) {
|
||||
$this->query_db($pagesize, $useinitialsbar);
|
||||
$this->build_table();
|
||||
$this->close_recordset();
|
||||
}
|
||||
|
||||
$this->finish_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not report data should be included in the table while in editing mode
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function show_live_editing(): bool {
|
||||
global $CFG;
|
||||
|
||||
return !empty($CFG->customreportsliveediting);
|
||||
}
|
||||
}
|
||||
|
@ -233,3 +233,17 @@ Feature: Manage custom reports
|
||||
| customreportslimit | 2 |
|
||||
And I reload the page
|
||||
And "New report" "button" should not exist
|
||||
|
||||
Scenario: Disable live editing of custom reports
|
||||
Given the following config values are set as admin:
|
||||
| customreportsliveediting | 0 |
|
||||
And the following "core_reportbuilder > Reports" exist:
|
||||
| name | source |
|
||||
| Report users | core_user\reportbuilder\datasource\users |
|
||||
When I am on the "Report users" "reportbuilder > Editor" page logged in as "admin"
|
||||
Then I should see "Viewing of report data while editing is disabled by the site administrator. Switch to preview mode to view the report." in the "[data-region='core_table/dynamic']" "css_element"
|
||||
And I click on "Switch to preview mode" "button"
|
||||
And I should see "admin" in the "reportbuilder-table" "table"
|
||||
And I click on "Close 'Report users' editor" "button"
|
||||
And I press "View" action in the "Report users" report row
|
||||
And I should see "admin" in the "reportbuilder-table" "table"
|
||||
|
Loading…
x
Reference in New Issue
Block a user