Skip to content
Snippets Groups Projects
Commit c14be4fe authored by Justus Dieckmann's avatar Justus Dieckmann
Browse files

Start with implementing editing active workflows

parent 970932c4
Branches
Tags
No related merge requests found
...@@ -636,17 +636,18 @@ class workflow_settings { ...@@ -636,17 +636,18 @@ class workflow_settings {
\core\notification::add( \core\notification::add(
get_string('active_workflow_not_changeable', 'tool_lifecycle'), get_string('active_workflow_not_changeable', 'tool_lifecycle'),
\core\notification::WARNING); \core\notification::WARNING);
} else { }
if (!empty($data->id)) { if (!empty($data->id)) {
$step = step_manager::get_step_instance($data->id); $step = step_manager::get_step_instance($data->id);
if ($data->instancename) {
$step->instancename = $data->instancename; $step->instancename = $data->instancename;
}
} else { } else {
$step = step_subplugin::from_record($data); $step = step_subplugin::from_record($data);
} }
step_manager::insert_or_update($step); step_manager::insert_or_update($step);
// Save local subplugin settings. // Save local subplugin settings.
settings_manager::save_settings($step->id, settings_type::STEP, $form->subpluginname, $data); settings_manager::save_settings($step->id, settings_type::STEP, $form->subpluginname, $data);
}
} else { } else {
$this->view_step_instance_form($form); $this->view_step_instance_form($form);
return true; return true;
......
...@@ -130,12 +130,8 @@ class form_step_instance extends \moodleform { ...@@ -130,12 +130,8 @@ class form_step_instance extends \moodleform {
} }
// For active workflows, we do not want the form to be editable. // For active workflows, we do not want the form to be editable.
if ($this->workflowid && !workflow_manager::is_editable($this->workflowid)) {
$this->add_cancel_button();
} else {
$this->add_action_buttons(); $this->add_action_buttons();
} }
}
/** /**
* In case of read only mode only the cancel button is rendered. * In case of read only mode only the cancel button is rendered.
...@@ -183,7 +179,13 @@ class form_step_instance extends \moodleform { ...@@ -183,7 +179,13 @@ class form_step_instance extends \moodleform {
// For active workflows, we do not want the form to be editable. // For active workflows, we do not want the form to be editable.
if ($this->workflowid && !workflow_manager::is_editable($this->workflowid)) { if ($this->workflowid && !workflow_manager::is_editable($this->workflowid)) {
// The group buttonar is the array of submit buttons. For inactive workflows this is only a cancel button. // The group buttonar is the array of submit buttons. For inactive workflows this is only a cancel button.
$mform->hardFreezeAllVisibleExcept(array('buttonar')); $notfreeze = ['buttonar'];
foreach ($this->lib->instance_settings() as $setting) {
if ($setting->editable) {
$notfreeze[] = $setting->name;
}
}
$mform->hardFreezeAllVisibleExcept($notfreeze);
} }
} }
......
...@@ -63,6 +63,8 @@ class settings_manager { ...@@ -63,6 +63,8 @@ class settings_manager {
global $DB; global $DB;
self::validate_type($type); self::validate_type($type);
// TODO before PR merges: Saveguard for changing settings
if (!$data) { if (!$data) {
return; return;
} }
......
...@@ -221,10 +221,10 @@ class email extends libbase { ...@@ -221,10 +221,10 @@ class email extends libbase {
*/ */
public function instance_settings() { public function instance_settings() {
return array( return array(
new instance_setting('responsetimeout', PARAM_INT), new instance_setting('responsetimeout', PARAM_INT, true),
new instance_setting('subject', PARAM_TEXT), new instance_setting('subject', PARAM_TEXT, true),
new instance_setting('content', PARAM_RAW), new instance_setting('content', PARAM_RAW, true),
new instance_setting('contenthtml', PARAM_RAW), new instance_setting('contenthtml', PARAM_RAW, true),
); );
} }
......
...@@ -149,14 +149,19 @@ class instance_setting { ...@@ -149,14 +149,19 @@ class instance_setting {
/** @var string param type of the setting, e.g. PARAM_INT */ /** @var string param type of the setting, e.g. PARAM_INT */
public $paramtype; public $paramtype;
/** @var bool if editable after activation */
public $editable;
/** /**
* Create a local settings object. * Create a local settings object.
* @param string $name name of the setting * @param string $name name of the setting
* @param string $paramtype param type. Used for cleansing and parsing, e.g. PARAM_INT. * @param string $paramtype param type. Used for cleansing and parsing, e.g. PARAM_INT.
* @param bool $editable if setting is editable after activation
*/ */
public function __construct($name, $paramtype) { public function __construct(string $name, string $paramtype, bool $editable = false) {
$this->name = $name; $this->name = $name;
$this->paramtype = $paramtype; $this->paramtype = $paramtype;
$this->editable = $editable;
} }
} }
...@@ -179,14 +179,19 @@ class instance_setting { ...@@ -179,14 +179,19 @@ class instance_setting {
/** @var string param type of the setting, e.g. PARAM_INT */ /** @var string param type of the setting, e.g. PARAM_INT */
public $paramtype; public $paramtype;
/** @var bool if editable after activation */
public $editable;
/** /**
* Create a local settings object. * Create a local settings object.
* @param string $name name of the setting * @param string $name name of the setting
* @param string $paramtype param type. Used for cleansing and parsing, e.g. PARAM_INT. * @param string $paramtype param type. Used for cleansing and parsing, e.g. PARAM_INT.
* @param bool $editable if setting is editable after activation
*/ */
public function __construct($name, $paramtype) { public function __construct(string $name, string $paramtype, bool $editable = false) {
$this->name = $name; $this->name = $name;
$this->paramtype = $paramtype; $this->paramtype = $paramtype;
$this->editable = $editable;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment