Verified Commit 9d4bc406 authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: Feat(Tasks) - Adding restart options for tasks

Adding a restart icon option allowing the renewal of a tasks.
If failed or not the status will put back to initial values.
Showing with 51 additions and 10 deletions
+51 -10
...@@ -165,7 +165,7 @@ class tasksMail extends simplePlugin ...@@ -165,7 +165,7 @@ class tasksMail extends simplePlugin
$id ++; $id ++;
// Here we create the object taskGranular // Here we create the object taskGranular
$tabobject = objects::create('TasksGranular'); $tabObject = objects::create('TasksGranular');
// remove 'dn' keeping only 'cn' // remove 'dn' keeping only 'cn'
$rmDn = preg_replace('/(?=,).*/', '', $this->dn); $rmDn = preg_replace('/(?=,).*/', '', $this->dn);
...@@ -184,20 +184,20 @@ class tasksMail extends simplePlugin ...@@ -184,20 +184,20 @@ class tasksMail extends simplePlugin
]; ];
foreach ($values as $tab => $tabvalues) { foreach ($values as $tab => $tabvalues) {
if (!isset($tabobject->by_object[$tab])) { if (!isset($tabObject->by_object[$tab])) {
echo "Error tab does not contains attributes values" .PHP_EOL; echo "Error tab does not contains attributes values" .PHP_EOL;
} }
$error = $tabobject->by_object[$tab]->deserializeValues($tabvalues); $error = $tabObject->by_object[$tab]->deserializeValues($tabvalues);
if ($error !== TRUE) { if ($error !== TRUE) {
echo 'Error during deserializing' .$error .PHP_EOL; echo 'Error during deserializing' .$error .PHP_EOL;
} }
$tabobject->current = $tab; $tabObject->current = $tab;
$tabobject->update(); $tabObject->update();
$tabobject->loadTabs(); $tabObject->loadTabs();
} }
$errors = $tabobject->save(); $errors = $tabObject->save();
if (!empty($errors)) { if (!empty($errors)) {
$show_error = new SimplePluginError($this, htmlescape(sprintf(_('Error : "%s", already exist ! Editing existing tasks is forbidden.'), $subTaskName))); $show_error = new SimplePluginError($this, htmlescape(sprintf(_('Error : "%s", already exist ! Editing existing tasks is forbidden.'), $subTaskName)));
$show_error->display(); $show_error->display();
......
...@@ -29,6 +29,7 @@ class tasksDashboard extends management ...@@ -29,6 +29,7 @@ class tasksDashboard extends management
['Column', ['attributes' => 'fdTasksGranularMail', 'label' => 'Email']], ['Column', ['attributes' => 'fdTasksGranularMail', 'label' => 'Email']],
['TasksColumn', ['attributes' => 'fdTasksGranularSchedule', 'label' => 'Schedule']], ['TasksColumn', ['attributes' => 'fdTasksGranularSchedule', 'label' => 'Schedule']],
['TasksColumn', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']], ['TasksColumn', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']],
['ActionsColumn', ['label' => 'Actions']],
]; ];
// No modification tools are required. // No modification tools are required.
...@@ -52,14 +53,54 @@ class tasksDashboard extends management ...@@ -52,14 +53,54 @@ class tasksDashboard extends management
protected function setUpFilter (array $filterElementDefinitions) protected function setUpFilter (array $filterElementDefinitions)
{ {
$this->filter = new tasksDashboardFilter($this, NULL, $filterElementDefinitions); $this->filter = new tasksDashboardFilter($this, NULL, $filterElementDefinitions);
} }
// Allowing us to add additional actions and remove unrequired ones. // Allowing us to add additional actions and remove unrequired ones.
protected function configureActions () protected function configureActions ()
{ {
// Leaving empty as no default action allowed. $this->registerAction(
new Action(
'tasksRenew',
_('Renew the selected task'),
'geticon.php?context=actions&icon=view-refresh&size=16',
'+',
'tasksRenew'
)
);
$this->actions['tasksRenew']->setSeparator(TRUE);
$this->actions['tasksRenew']->setEnableFunction([$this, 'setTasksActionStatus']);
} }
// This method is triggered by the user action click on tasksRenew
function tasksRenew (array $action)
{
foreach ((array)$action['targets'] as $dn) {
$this->tasksUpdate($dn, 1);
}
}
function tasksUpdate ($dn)
{
$tabObject = objects::open($dn, 'tasksGranular');
$tabObject->by_object['tasksGranular']->attributesAccess['fdTasksGranularStatus']->setValue(1);
$errors = $tabObject->save();
if (!empty($errors)) {
$show_error = new SimplePluginError($this, htmlescape(sprintf(_('Error updating: "%s" !.'), $dn)));
$show_error->display();
}
}
// This method is triggered during initiation of the dashboard, allowing proper icons status
function setTasksActionStatus () : BOOL
{
echo "setTasksActionStatus" .PHP_EOL;
return TRUE;
}
// End of Class // End of Class
} }
......
...@@ -23,7 +23,7 @@ class tasksManagement extends management ...@@ -23,7 +23,7 @@ class tasksManagement extends management
protected $skipCpHandler = TRUE; protected $skipCpHandler = TRUE;
/* /*
* LinkColumn exists by class collumn * LinkColumn exists by class collumn
* TasksColumn is a new class for Tasks bassed on argonaut column definition * TasksColumn is a new class for Tasks bassed on argonaut column definition
*/ */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment