mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-17 05:48:43 +02:00
Issue #46 - Added behat tests to actions in manage page.
This commit is contained in:
@@ -56,7 +56,7 @@ class base_table extends flexible_table {
|
||||
* @param bool $editdelete If it should display the edit and delete button.
|
||||
* @return string The HTML code of the action buttons.
|
||||
*/
|
||||
protected function set_data_buttons(outage $outage, $editdelete) {
|
||||
protected function create_data_buttons(outage $outage, $editdelete) {
|
||||
global $OUTPUT;
|
||||
$buttons = '';
|
||||
|
||||
@@ -126,6 +126,6 @@ class base_table extends flexible_table {
|
||||
);
|
||||
}
|
||||
|
||||
return '<nobr>'.$buttons.'</nobr>';
|
||||
return html_writer::tag('nobr', $buttons);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class history_table extends base_table {
|
||||
* Sets the data of the table.
|
||||
* @param outage[] $outages An array with outage objects.
|
||||
*/
|
||||
public function set_data(array $outages) {
|
||||
public function show_data(array $outages) {
|
||||
foreach ($outages as $outage) {
|
||||
$finished = $outage->get_duration_actual();
|
||||
$finished = is_null($finished) ? '-' : format_time($finished);
|
||||
@@ -66,7 +66,7 @@ class history_table extends base_table {
|
||||
format_time($outage->get_duration_planned()),
|
||||
$finished,
|
||||
$outage->get_title(),
|
||||
$this->set_data_buttons($outage, false),
|
||||
$this->create_data_buttons($outage, false),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,13 +42,12 @@ class planned_table extends base_table {
|
||||
$this->define_columns(['warning', 'starts', 'duration', 'title', 'actions']);
|
||||
|
||||
$this->define_headers([
|
||||
get_string('tableheaderwarnbefore', 'auth_outage'),
|
||||
get_string('tableheaderstarttime', 'auth_outage'),
|
||||
get_string('tableheaderduration', 'auth_outage'),
|
||||
get_string('tableheadertitle', 'auth_outage'),
|
||||
get_string('actions'),
|
||||
]
|
||||
);
|
||||
get_string('tableheaderwarnbefore', 'auth_outage'),
|
||||
get_string('tableheaderstarttime', 'auth_outage'),
|
||||
get_string('tableheaderduration', 'auth_outage'),
|
||||
get_string('tableheadertitle', 'auth_outage'),
|
||||
get_string('actions'),
|
||||
]);
|
||||
|
||||
$this->setup();
|
||||
}
|
||||
@@ -57,7 +56,7 @@ class planned_table extends base_table {
|
||||
* Sets the data of the table.
|
||||
* @param outage[] $outages An array with outage objects.
|
||||
*/
|
||||
public function set_data(array $outages) {
|
||||
public function show_data(array $outages) {
|
||||
foreach ($outages as $outage) {
|
||||
$title = html_writer::link(
|
||||
new moodle_url('/auth/outage/edit.php', ['id' => $outage->id]),
|
||||
@@ -70,7 +69,7 @@ class planned_table extends base_table {
|
||||
userdate($outage->starttime, get_string('datetimeformat', 'auth_outage')),
|
||||
format_time($outage->get_duration_planned()),
|
||||
$title,
|
||||
$this->set_data_buttons($outage, true),
|
||||
$this->create_data_buttons($outage, true),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,44 +108,6 @@ class renderer extends plugin_renderer_base {
|
||||
$this->renderoutage($outage, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the HTML data listing all given outages.
|
||||
* @param outage[] $future Outages to list as planned.
|
||||
* @param outage[] $past Outages to list as history.
|
||||
*/
|
||||
public function renderoutagelist(array $future, array $past) {
|
||||
global $OUTPUT;
|
||||
|
||||
echo html_writer::start_tag('section', ['id' => 'section_planned_outages']);
|
||||
echo $this->rendersubtitle('outageslistfuture');
|
||||
if (empty($future)) {
|
||||
echo html_writer::tag('p', html_writer::tag('small', get_string('notfound', 'auth_outage')));
|
||||
} else {
|
||||
$table = new planned_table();
|
||||
$table->set_data($future);
|
||||
$table->finish_output();
|
||||
}
|
||||
$url = new moodle_url('/auth/outage/new.php');
|
||||
echo html_writer::empty_tag('input', [
|
||||
'class' => 'form-submit',
|
||||
'type' => 'button',
|
||||
'value' => get_string('outagecreate', 'auth_outage'),
|
||||
'onclick' => "location.href='${url}';"
|
||||
]);
|
||||
echo html_writer::end_tag('section');
|
||||
|
||||
echo html_writer::start_tag('section', ['id' => 'section_outage_history']);
|
||||
echo $this->rendersubtitle('outageslistpast');
|
||||
if (empty($past)) {
|
||||
echo html_writer::tag('p', html_writer::tag('small', get_string('notfound', 'auth_outage')));
|
||||
} else {
|
||||
$table = new history_table();
|
||||
$table->set_data($past);
|
||||
$table->finish_output();
|
||||
}
|
||||
echo html_writer::end_tag('section');
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the warning bar.
|
||||
* @param outage $outage The outage to show in the warning bar.
|
||||
|
||||
Reference in New Issue
Block a user