Skip to content
Snippets Groups Projects
Unverified Commit 9b110eeb authored by Jan Dageförde's avatar Jan Dageförde
Browse files

adminsettings: Refactored workflow table classes

Added an abstract class that defines most of the column rendering.
Added workflow title display to all tables.
Fixes #20
parent 5b3e547d
No related branches found
No related tags found
No related merge requests found
......@@ -135,12 +135,16 @@ class admin_settings {
echo $OUTPUT->heading(get_string('active_automatic_workflows_heading', 'tool_cleanupcourses'));
$table = new active_automatic_workflows_table('tool_cleanupcourses_active_automatic_workflows');
echo $OUTPUT->box_start("cleanupcourses-enable-overflow cleanupcourses-table");
$table->out(5000, false);
echo $OUTPUT->box_end();
echo $OUTPUT->heading(get_string('active_manual_workflows_heading', 'tool_cleanupcourses'));
$table = new active_manual_workflows_table('tool_cleanupcourses_manual_workflows');
echo $OUTPUT->box_start("cleanupcourses-enable-overflow cleanupcourses-table");
$table->out(5000, false);
echo $OUTPUT->box_end();
echo $OUTPUT->heading(get_string('workflow_definition_heading', 'tool_cleanupcourses'));
......@@ -149,7 +153,9 @@ class admin_settings {
get_string('add_workflow', 'tool_cleanupcourses'));
$table = new workflow_definition_table('tool_cleanupcourses_workflow_definitions');
echo $OUTPUT->box_start("cleanupcourses-enable-overflow cleanupcourses-table");
$table->out(5000, false);
echo $OUTPUT->box_end();
$this->view_footer();
}
......
......@@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir . '/tablelib.php');
require_once(__DIR__ . '/../../lib.php');
class active_automatic_workflows_table extends \table_sql {
class active_automatic_workflows_table extends workflow_table {
public function __construct($uniqueid) {
parent::__construct($uniqueid);
......@@ -42,7 +42,7 @@ class active_automatic_workflows_table extends \table_sql {
list($sqlwheremanual, $paramsmanual) = $DB->get_in_or_equal(false);
$sqlwhere = 'active ' . $sqlwhereactive . ' AND manual ' . $sqlwheremanual;
$params[1] = $paramsmanual[0];
$this->set_sql("id, title, timeactive, sortindex", '{tool_cleanupcourses_workflow}',
$this->set_sql("id, title, displaytitle, timeactive, sortindex", '{tool_cleanupcourses_workflow}',
$sqlwhere, $params);
$this->define_baseurl($PAGE->url);
$this->pageable(false);
......@@ -63,23 +63,6 @@ class active_automatic_workflows_table extends \table_sql {
$this->setup();
}
/**
* Render activate column.
* @param $row
* @return string activate time for workflows
*/
public function col_timeactive($row) {
global $OUTPUT, $PAGE;
if ($row->timeactive) {
return userdate($row->timeactive, get_string('strftimedatetime'), 0);
}
return $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('action' => ACTION_WORKFLOW_ACTIVATE,
'sesskey' => sesskey(),
'workflowid' => $row->id)),
get_string('activateworkflow', 'tool_cleanupcourses'));
}
/**
* Render sortindex column.
* @param $row
......@@ -110,64 +93,4 @@ class active_automatic_workflows_table extends \table_sql {
return $output;
}
/**
* Render the trigger column.
* @param $row
* @return string instancename of the trigger
*/
public function col_trigger($row) {
$trigger = trigger_manager::get_trigger_for_workflow($row->id);
if ($trigger) {
return $trigger->instancename;
}
}
/**
* Render the processes column. It shows the number of active processes for the workflow instance.
* @param $row
* @return string instancename of the trigger
*/
public function col_processes($row) {
return process_manager::count_processes_by_workflow($row->id);
}
/**
* Render tools column.
* @param $row
* @return string action buttons for workflows
*/
public function col_tools($row) {
global $OUTPUT;
$output = '';
$alt = get_string('viewsteps', 'tool_cleanupcourses');
$icon = 't/viewdetails';
$url = new \moodle_url('/admin/tool/cleanupcourses/workflowsettings.php',
array('workflowid' => $row->id, 'sesskey' => sesskey()));
$output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt));
return $output;
}
/**
* Util function for writing an action icon link
*
* @param string $action URL parameter to include in the link
* @param string $workflowid URL parameter to include in the link
* @param string $icon The key to the icon to use (e.g. 't/up')
* @param string $alt The string description of the link used as the title and alt text
* @return string The icon/link
*/
private function format_icon_link($action, $workflowid, $icon, $alt) {
global $PAGE, $OUTPUT;
return $OUTPUT->action_icon(new \moodle_url($PAGE->url,
array('action' => $action,
'sesskey' => sesskey(),
'workflowid' => $workflowid)),
new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt)) . ' ';
}
}
\ No newline at end of file
......@@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir . '/tablelib.php');
require_once(__DIR__ . '/../../lib.php');
class active_manual_workflows_table extends \table_sql {
class active_manual_workflows_table extends workflow_table {
public function __construct($uniqueid) {
parent::__construct($uniqueid);
......@@ -42,7 +42,7 @@ class active_manual_workflows_table extends \table_sql {
list($sqlwheremanual, $paramsmanual) = $DB->get_in_or_equal(true);
$sqlwhere = 'active ' . $sqlwhereactive . ' AND manual ' . $sqlwheremanual;
$params[1] = $paramsmanual[0];
$this->set_sql("id, title, timeactive", '{tool_cleanupcourses_workflow}',
$this->set_sql("id, title, displaytitle, timeactive", '{tool_cleanupcourses_workflow}',
$sqlwhere, $params);
$this->define_baseurl($PAGE->url);
$this->pageable(false);
......@@ -62,81 +62,4 @@ class active_manual_workflows_table extends \table_sql {
$this->setup();
}
/**
* Render activate column.
* @param $row
* @return string activate time for workflows
*/
public function col_timeactive($row) {
global $OUTPUT, $PAGE;
if ($row->timeactive) {
return userdate($row->timeactive, get_string('strftimedatetime'), 0);
}
return $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('action' => ACTION_WORKFLOW_ACTIVATE,
'sesskey' => sesskey(),
'workflowid' => $row->id)),
get_string('activateworkflow', 'tool_cleanupcourses'));
}
/**
* Render the trigger column.
* @param $row
* @return string instancename of the trigger
*/
public function col_trigger($row) {
$trigger = trigger_manager::get_trigger_for_workflow($row->id);
if ($trigger) {
return $trigger->instancename;
}
}
/**
* Render the processes column. It shows the number of active processes for the workflow instance.
* @param $row
* @return string instancename of the trigger
*/
public function col_processes($row) {
return process_manager::count_processes_by_workflow($row->id);
}
/**
* Render tools column.
* @param $row
* @return string action buttons for workflows
*/
public function col_tools($row) {
global $OUTPUT;
$output = '';
$alt = get_string('viewsteps', 'tool_cleanupcourses');
$icon = 't/viewdetails';
$url = new \moodle_url('/admin/tool/cleanupcourses/workflowsettings.php',
array('workflowid' => $row->id, 'sesskey' => sesskey()));
$output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt));
return $output;
}
/**
* Util function for writing an action icon link
*
* @param string $action URL parameter to include in the link
* @param string $workflowid URL parameter to include in the link
* @param string $icon The key to the icon to use (e.g. 't/up')
* @param string $alt The string description of the link used as the title and alt text
* @return string The icon/link
*/
private function format_icon_link($action, $workflowid, $icon, $alt) {
global $PAGE, $OUTPUT;
return $OUTPUT->action_icon(new \moodle_url($PAGE->url,
array('action' => $action,
'sesskey' => sesskey(),
'workflowid' => $workflowid)),
new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt)) . ' ';
}
}
\ No newline at end of file
......@@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir . '/tablelib.php');
require_once(__DIR__ . '/../../lib.php');
class workflow_definition_table extends \table_sql {
class workflow_definition_table extends workflow_table {
public function __construct($uniqueid) {
parent::__construct($uniqueid);
......@@ -41,7 +41,6 @@ class workflow_definition_table extends \table_sql {
$this->set_sql("id, title, timeactive, displaytitle", '{tool_cleanupcourses_workflow}', "TRUE");
$this->define_baseurl($PAGE->url);
$this->pageable(false);
$this->attributes['class'] .= " workflow_definition_table";
$this->init();
}
......@@ -56,14 +55,6 @@ class workflow_definition_table extends \table_sql {
$this->setup();
}
/**
* Render title column.
* @param $row
*/
public function col_title($row) {
return $row->title . '<br><span class="workflow_displaytitle">' . $row->displaytitle . '</span>';
}
/**
* Render activate column.
* @param $row
......@@ -128,24 +119,4 @@ class workflow_definition_table extends \table_sql {
return $output;
}
/**
* Util function for writing an action icon link
*
* @param string $action URL parameter to include in the link
* @param string $workflowid URL parameter to include in the link
* @param string $icon The key to the icon to use (e.g. 't/up')
* @param string $alt The string description of the link used as the title and alt text
* @return string The icon/link
*/
private function format_icon_link($action, $workflowid, $icon, $alt) {
global $PAGE, $OUTPUT;
return $OUTPUT->action_icon(new \moodle_url($PAGE->url,
array('action' => $action,
'sesskey' => sesskey(),
'workflowid' => $workflowid)),
new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt)) . ' ';
}
}
\ No newline at end of file
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Table listing all active automatically triggered workflows.
*
* @package tool_cleanupcourses
* @copyright 2018 Jan Dageförde WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\table;
use tool_cleanupcourses\manager\process_manager;
use tool_cleanupcourses\manager\step_manager;
use tool_cleanupcourses\manager\trigger_manager;
use tool_cleanupcourses\manager\workflow_manager;
defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir . '/tablelib.php');
require_once(__DIR__ . '/../../lib.php');
abstract class workflow_table extends \table_sql {
/**
* Render title column.
* @param $row
*/
public function col_title($row) {
return $row->title . '<br><span class="workflow_displaytitle">' . $row->displaytitle . '</span>';
}
/**
* Render activate column.
* @param $row
* @return string activate time for workflows
*/
public function col_timeactive($row) {
global $OUTPUT, $PAGE;
if ($row->timeactive) {
return userdate($row->timeactive, get_string('strftimedatetime'), 0);
}
return $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('action' => ACTION_WORKFLOW_ACTIVATE,
'sesskey' => sesskey(),
'workflowid' => $row->id)),
get_string('activateworkflow', 'tool_cleanupcourses'));
}
/**
* Render the trigger column.
* @param $row
* @return string instancename of the trigger
*/
public function col_trigger($row) {
$trigger = trigger_manager::get_trigger_for_workflow($row->id);
if ($trigger) {
return $trigger->instancename;
}
}
/**
* Render the processes column. It shows the number of active processes for the workflow instance.
* @param $row
* @return string instancename of the trigger
*/
public function col_processes($row) {
return process_manager::count_processes_by_workflow($row->id);
}
/**
* Render tools column.
* @param $row
* @return string action buttons for workflows
*/
public function col_tools($row) {
global $OUTPUT;
$output = '';
$alt = get_string('viewsteps', 'tool_cleanupcourses');
$icon = 't/viewdetails';
$url = new \moodle_url('/admin/tool/cleanupcourses/workflowsettings.php',
array('workflowid' => $row->id, 'sesskey' => sesskey()));
$output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt));
return $output;
}
/**
* Util function for writing an action icon link
*
* @param string $action URL parameter to include in the link
* @param string $workflowid URL parameter to include in the link
* @param string $icon The key to the icon to use (e.g. 't/up')
* @param string $alt The string description of the link used as the title and alt text
* @return string The icon/link
*/
protected function format_icon_link($action, $workflowid, $icon, $alt) {
global $PAGE, $OUTPUT;
return $OUTPUT->action_icon(new \moodle_url($PAGE->url,
array('action' => $action,
'sesskey' => sesskey(),
'workflowid' => $workflowid)),
new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt)) . ' ';
}
}
\ No newline at end of file
......@@ -96,7 +96,7 @@ class view_controller {
echo $renderer->heading(get_string('tablecoursesremaining', 'tool_cleanupcourses'), 3);
$table2 = new interaction_remaining_table('tool_cleanupcourses_remaining', $arrayofcourseids);
echo $renderer->box_start("cleanupcourses-enable-overflow managing_courses_tables");
echo $renderer->box_start("cleanupcourses-enable-overflow cleanupcourses-table");
$table2->out(50, false);
echo $renderer->box_end();
}
......
......@@ -2,8 +2,7 @@
overflow: initial;
}
.workflow_definition_table span.workflow_displaytitle,
.managing_courses_tables span.workflow_displaytitle {
.cleanupcourses-table span.workflow_displaytitle {
color: #888;
font-size: .9em;
padding: 0.5em;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment