Verified Commit f011accf authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: Feat(Tasks) - Dashboard v0.4

Updates for tasks dashboards. Fixes and proper format.
Adding custom columns and errors messages upon master tasks
modification.
Showing with 58 additions and 30 deletions
+58 -30
...@@ -45,7 +45,7 @@ class tasks extends simplePlugin ...@@ -45,7 +45,7 @@ class tasks extends simplePlugin
return [ return [
// Attributes are grouped by section // Attributes are grouped by section
'tasks' => [ 'tasks' => [
'name' => _('Tasks Generic'), 'name' => _('Tasks Generic | Saving will create un-modifiable subtasks'),
'attrs' => [ 'attrs' => [
new StringAttribute( new StringAttribute(
_('Task Name'), _('Name for this task'), _('Task Name'), _('Name for this task'),
......
...@@ -39,6 +39,12 @@ class tasksGranular extends simplePlugin ...@@ -39,6 +39,12 @@ class tasksGranular extends simplePlugin
]; ];
} }
/*
* Info : getAttributesInfo return is important for the management class.
* It is the return of that method which render the columns and data properly.
* Although not used by the interface directly, it is created by simpleTab during
* the save of mailTasks.
*/
static function getAttributesInfo (): array static function getAttributesInfo (): array
{ {
return [ return [
......
...@@ -148,7 +148,8 @@ class tasksMail extends simplePlugin ...@@ -148,7 +148,8 @@ class tasksMail extends simplePlugin
} }
/* /*
* Generate slave tasks, carefull that main task cannot be changed cause subtasks are not updated (for now). * Generate slave tasks, carefull that main task cannot be changed cause subtasks are not updated.
* It would be dangerous to edit subs tasks if some are under processed already.
*/ */
public function generateSlaveTasks () public function generateSlaveTasks ()
{ {
...@@ -156,25 +157,23 @@ class tasksMail extends simplePlugin ...@@ -156,25 +157,23 @@ class tasksMail extends simplePlugin
// Incremental id allowing creation of different CN for sub tasks // Incremental id allowing creation of different CN for sub tasks
$id = 0; $id = 0;
// Verification of set attributes required for granular tasks. // Take the attribute from the other tabs - attribute cannot be null or unset by default
if ( isset($this->attrs['fdTasksScheduleDate'][0]) && !empty($this->attrs['fdTasksScheduleDate'][0]) ) { $schedule = $this->parent->getBaseObject()->fdTasksScheduleDate ?? NULL;
$schedule = $this->attrs['fdTasksScheduleDate'][0];
} else {
// testing purposes.
$schedule = '20222222222200';
}
if (isset($emails) && !empty($emails)) { if (isset($emails) && !empty($emails)) {
foreach ($emails as $email) { foreach ($emails as $email) {
$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);
// only take the cn without dc
// only take the cn without dc
preg_match('/cn=(.*)/', $rmDn, $matches); preg_match('/cn=(.*)/', $rmDn, $matches);
$subTaskName = $matches[1].'-SubTask-'.$id;
$id ++; $subTaskName = $matches[1].'-SubTask-'.$id;
$values['tasksGranular'] = [ $values['tasksGranular'] = [
"cn" => $subTaskName, "cn" => $subTaskName,
...@@ -190,7 +189,7 @@ class tasksMail extends simplePlugin ...@@ -190,7 +189,7 @@ class tasksMail extends simplePlugin
} }
$error = $tabobject->by_object[$tab]->deserializeValues($tabvalues); $error = $tabobject->by_object[$tab]->deserializeValues($tabvalues);
if ($error !== TRUE) { if ($error !== TRUE) {
echo 'Error deserailizing' .PHP_EOL; echo 'Error during deserializing' .$error .PHP_EOL;
} }
$tabobject->current = $tab; $tabobject->current = $tab;
...@@ -200,9 +199,8 @@ class tasksMail extends simplePlugin ...@@ -200,9 +199,8 @@ class tasksMail extends simplePlugin
$errors = $tabobject->save(); $errors = $tabobject->save();
if (!empty($errors)) { if (!empty($errors)) {
Throw new FusionDirectoryError( $show_error = new SimplePluginError($this, htmlescape(sprintf(_('Error : "%s", already exist ! Editing existing tasks is forbidden.'), $subTaskName)));
htmlescape(sprintf( _('SubTasks DN already exist ! You cannot modify a saved task !'))) $show_error->display();
);
} }
} }
} }
......
...@@ -34,14 +34,21 @@ class TasksColumn extends Column ...@@ -34,14 +34,21 @@ class TasksColumn extends Column
case 'fdTasksStatus': case 'fdTasksStatus':
return static::filterStatus(intval($value)); return static::filterStatus(intval($value));
case 'fdTasksGranularStatus':
return static::filterStatus(intval($value));
// This case needs optimization
case 'fdTasksMailObject': case 'fdTasksMailObject':
return "Mail Object"; return "Mail Object";
case 'fdTasksScheduleDate': case 'fdTasksScheduleDate':
// Z is added to value to match ldap generaliseztime return static::generateDateFormat($value);
$datetime = (new LdapGeneralizedTime)->fromString($value.'Z');
$result = $datetime->format('Y-m-d H:i:s'); case 'fdTasksGranularSchedule':
return $result; return static::generateDateFormat($value);
case 'fdTasksGranularMaster':
return static::generateMasterTaskName($value);
default: default:
return parent::renderSingleValue($entry, $value); return parent::renderSingleValue($entry, $value);
...@@ -61,8 +68,25 @@ class TasksColumn extends Column ...@@ -61,8 +68,25 @@ class TasksColumn extends Column
default : default :
return "Error Encountered"; return "Error Encountered";
} }
} }
static function generateDateFormat ($value) : string
{
// Z is added to value to match ldap generaliseztime
$datetime = (new LdapGeneralizedTime)->fromString($value.'Z');
$result = $datetime->format('Y-m-d H:i:s');
return $result;
}
static function generateMasterTaskName ($value) : string
{
// remove 'dn' keeping only 'cn'
$rmDn = preg_replace('/(?=,).*/', '', $value);
// only take the cn without dc
preg_match('/cn=(.*)/', $rmDn, $matches);
return $matches[1];
}
} }
...@@ -24,18 +24,17 @@ class tasksDashboard extends management ...@@ -24,18 +24,17 @@ class tasksDashboard extends management
// Actions collumn are removed compared to parent. // Actions collumn are removed compared to parent.
public static $columns = [ public static $columns = [
['Column', ['attributes' => 'cn', 'label' => 'Tasks']], ['Column', ['attributes' => 'cn', 'label' => 'Tasks']],
['Column', ['attributes' => 'fdTasksGranularMaster', 'label' => 'Master Task']], ['TasksColumn', ['attributes' => 'fdTasksGranularMaster', 'label' => 'Master Task']],
['Column', ['attributes' => 'fdTasksGranularType', 'label' => 'Types']], ['Column', ['attributes' => 'fdTasksGranularType', 'label' => 'Types']],
['Column', ['attributes' => 'fdTasksGranularMail', 'label' => 'Email']], ['Column', ['attributes' => 'fdTasksGranularMail', 'label' => 'Email']],
['Column', ['attributes' => 'fdTasksGranularSchedule', 'label' => 'Schedule']], ['TasksColumn', ['attributes' => 'fdTasksGranularSchedule', 'label' => 'Schedule']],
['Column', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']], ['TasksColumn', ['attributes' => 'fdTasksGranularStatus', 'label' => 'Status']],
]; ];
// No modification tools are required. // No modification tools are required.
protected $skipCpHandler = TRUE; protected $skipCpHandler = TRUE;
public static $skipSnapshots = TRUE; public static $skipSnapshots = TRUE;
public static $skipTemplates = TRUE; public static $skipTemplates = TRUE;
protected $skipConfiguration = TRUE;
static function plInfo () static function plInfo ()
{ {
...@@ -59,7 +58,7 @@ class tasksDashboard extends management ...@@ -59,7 +58,7 @@ class tasksDashboard extends management
// 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. // Leaving empty as no default action allowed.
} }
// End of Class // End of Class
} }
...@@ -67,5 +66,5 @@ class tasksDashboard extends management ...@@ -67,5 +66,5 @@ class tasksDashboard extends management
// extending the class allows us to remove the rendering of filter. // extending the class allows us to remove the rendering of filter.
class tasksDashboardFilter extends managementFilter class tasksDashboardFilter extends managementFilter
{ {
// Filter will be // Filter will be set soon
} }
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
class tasksManagement extends management class tasksManagement extends management
{ {
/* 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
*/ */
...@@ -54,7 +56,6 @@ class tasksManagement extends management ...@@ -54,7 +56,6 @@ class tasksManagement extends management
{ {
/* Set baseMode to FALSE */ /* Set baseMode to FALSE */
$this->listing = new managementListing($this, FALSE); $this->listing = new managementListing($this, FALSE);
} }
} }
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