Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
695a147
Initial commit of new magical-parameters-feature
manne65-hd Mar 29, 2020
6a88a24
Introduced HelperClass for magical params
manne65-hd Mar 31, 2020
b7889ae
added some DEBUG-output for testing
manne65-hd Mar 31, 2020
01fb0f6
use new helper in all actions
manne65-hd Mar 31, 2020
797c011
removed debug-output
manne65-hd Mar 31, 2020
424d9f9
allow appending magic params
manne65-hd Mar 31, 2020
0e9e1a0
Added checks to prevent assinging to user without permission to the p…
manne65-hd Mar 31, 2020
9bb63ca
Added new helper-method to remove duplicate auto-subtasks
manne65-hd Mar 31, 2020
94f5e41
Added another helper to avoid need for 2 different action-templates
manne65-hd Mar 31, 2020
121a6e7
fixed typo
manne65-hd Mar 31, 2020
619c63f
moved var-assignment down some lines for better semantic context
manne65-hd Mar 31, 2020
834708a
finally (hopefully) really fixed new method to avoid duplicate subtasks
manne65-hd Mar 31, 2020
0816a5e
Removed the need to register different actions for vanilla or Subtask…
manne65-hd Apr 1, 2020
df0c90c
fixed some errors
manne65-hd Apr 1, 2020
fe99bf2
inject duration ONLY if Subtaskdue-plugin is present!
manne65-hd Apr 1, 2020
f92d65f
inject duration ONLY if Subtaskdue-plugin is present!
manne65-hd Apr 1, 2020
b1512e7
explain magic-param duration only if Subtaskdate-plugin is present
manne65-hd Apr 1, 2020
e040676
Updated readme to introduce magical-params
manne65-hd Apr 1, 2020
6e438a9
removed DEBUG-output
manne65-hd Apr 1, 2020
6dfec8b
Merge branch 'MagicalParams-v2'
manne65-hd Apr 1, 2020
eeb4054
removed last special "vanilla"-code
manne65-hd Apr 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 48 additions & 31 deletions Action/AutoCreateSubtask.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,26 @@ public function getCompatibleEvents()
public function getActionRequiredParameters()
{
//changed 'titles' to 'multitasktitles' to have a clean way to render the title-textfield as a textarea
return array(
'column_id' => t('Column'),
'user_id' => t('Assignee'),
'multitasktitles' => t('Subtask Title(s)'),
'time_estimated' => t('Estimated Time in Hours'),
'duration' => t('Duration in days'),
'check_box_all_columns' => t('Apply to all Columns'),
'check_box_no_duplicates' => t('Do not duplicate subtasks'),
);
if ( $this->helper->checkCoworkerPlugins->checkSubtaskdate() ){
return array(
'column_id' => t('Column'),
'user_id' => t('Assignee'),
'multitasktitles' => t('Subtask Title(s)'),
'time_estimated' => t('Estimated Time in Hours'),
'duration' => t('Duration in days'),
'check_box_all_columns' => t('Apply to all Columns'),
'check_box_no_duplicates' => t('Do not duplicate subtasks'),
);
} else {
return array(
'column_id' => t('Column'),
'user_id' => t('Assignee'),
'multitasktitles' => t('Subtask Title(s)'),
'time_estimated' => t('Estimated Time in Hours'),
'check_box_all_columns' => t('Apply to all Columns'),
'check_box_no_duplicates' => t('Do not duplicate subtasks'),
);
}
}

public function getEventRequiredParameters()
Expand All @@ -54,34 +65,40 @@ public function doAction(array $data)
$title_test = $this->getParam('multitasktitles');
$title_test = preg_replace("/^\s+/m", $data['task']['title'] . "\r\n", $title_test);

$values = array(
'title' => $title_test,
'task_id' => $data['task_id'],
'user_id' => $this->getParam('user_id'),
'time_estimated' => $this->getParam('time_estimated'),
'time_spent' => 0,
'status' => 0,
'due_date' => strtotime('+'.$this->getParam('duration').'days'),
);
if ( $this->helper->checkCoworkerPlugins->checkSubtaskdate() ){
$values = array(
'title' => $title_test,
'task_id' => $data['task_id'],
'user_id' => $this->getParam('user_id'),
'time_estimated' => $this->getParam('time_estimated'),
'time_spent' => 0,
'status' => 0,
'due_date' => strtotime('+'.$this->getParam('duration').'days'),
);
} else {
$values = array(
'title' => $title_test,
'task_id' => $data['task_id'],
'user_id' => $this->getParam('user_id'),
'time_estimated' => $this->getParam('time_estimated'),
'time_spent' => 0,
'status' => 0,
);

$subtasks = array_map('trim', explode("\r\n", isset($values['title']) ? $values['title'] : ''));
}
$raw_subtasks = array_map('trim', explode("\r\n", isset($values['title']) ? $values['title'] : ''));
$subtasksAdded = 0;

if ($this->getParam('check_box_no_duplicates') == true ){
$current_subtasks = $this->subtaskModel->getAll($data['task_id']);
foreach ($current_subtasks as $current_subtask) {
if (in_array($current_subtask['title'], $subtasks)) {
$title = array_search($current_subtask['title'], $subtasks);
unset($subtasks[$title]);
}
}
$subtasks = $this->helper->magicalParams->removeDuplicateSubtasks($raw_subtasks, $this->subtaskModel->getAll($data['task_id']));
} else {
$subtasks = $raw_subtasks;
}

foreach ($subtasks as $subtask) {

if (! empty($subtask)) {
$subtaskValues = $values;
$subtaskValues['title'] = $subtask;
$subtaskValues = $this->helper->magicalParams->injectMagicalParams($values, $subtask, $data['task']['project_id']);

list($valid, $errors) = $this->subtaskValidator->validateCreation($subtaskValues);

Expand All @@ -99,7 +116,7 @@ public function doAction(array $data)
$subtasksAdded++;
}
}
//restore the messaging with a flash but this message doesn't seem to appear in the flash area. Only the create message from (kanboard/app/Controller/ActionCreationController.php).
//restore the messaging with a flash but this message doesn't seem to appear in the flash area. Only the create message from (kanboard/app/Controller/ActionCreationController.php).
if ($subtasksAdded > 0) {
if ($subtasksAdded === 1) {
$this->flash->success(t('Subtask added successfully.'));
Expand All @@ -111,7 +128,7 @@ public function doAction(array $data)

public function hasRequiredCondition(array $data)
{

if ($this->getParam('check_box_all_columns')) {
return $data['task']['column_id'] == $data['task']['column_id'];
} else {
Expand Down
119 changes: 0 additions & 119 deletions Action/AutoCreateSubtaskVanilla.php

This file was deleted.

76 changes: 46 additions & 30 deletions Action/CategoryAutoSubtask.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,25 @@ public function getCompatibleEvents()
public function getActionRequiredParameters()
{
//changed 'titles' to 'multitasktitles' to have a clean way to render the title-textfield as a textarea
return array(
'category_id' => t('Category'),
'user_id' => t('Assignee'),
'multitasktitles' => t('Subtask Title(s)'),
'time_estimated' => t('Estimated Time in Hours'),
'duration' => t('Duration in days'),
'check_box_no_duplicates' => t('Do not duplicate subtasks'),
);
}
if ( $this->helper->checkCoworkerPlugins->checkSubtaskdate() ){
return array(
'category_id' => t('Category'),
'user_id' => t('Assignee'),
'multitasktitles' => t('Subtask Title(s)'),
'time_estimated' => t('Estimated Time in Hours'),
'duration' => t('Duration in days'),
'check_box_no_duplicates' => t('Do not duplicate subtasks'),
);
} else {
return array(
'category_id' => t('Category'),
'user_id' => t('Assignee'),
'multitasktitles' => t('Subtask Title(s)'),
'time_estimated' => t('Estimated Time in Hours'),
'check_box_no_duplicates' => t('Do not duplicate subtasks'),
);
}
}

public function getEventRequiredParameters()
{
Expand All @@ -52,34 +62,40 @@ public function doAction(array $data)
$title_test = $this->getParam('multitasktitles');
$title_test = preg_replace("/^\s+/m", $data['task']['title'] . "\r\n", $title_test);

$values = array(
'title' => $title_test,
'task_id' => $data['task_id'],
'user_id' => $this->getParam('user_id'),
'time_estimated' => $this->getParam('time_estimated'),
'time_spent' => 0,
'status' => 0,
'due_date' => strtotime('+'.$this->getParam('duration').'days'),
);
if ( $this->helper->checkCoworkerPlugins->checkSubtaskdate() ){
$values = array(
'title' => $title_test,
'task_id' => $data['task_id'],
'user_id' => $this->getParam('user_id'),
'time_estimated' => $this->getParam('time_estimated'),
'time_spent' => 0,
'status' => 0,
'due_date' => strtotime('+'.$this->getParam('duration').'days'),
);
} else {
$values = array(
'title' => $title_test,
'task_id' => $data['task_id'],
'user_id' => $this->getParam('user_id'),
'time_estimated' => $this->getParam('time_estimated'),
'time_spent' => 0,
'status' => 0,
);
}

$subtasks = array_map('trim', explode("\r\n", isset($values['title']) ? $values['title'] : ''));
$raw_subtasks = array_map('trim', explode("\r\n", isset($values['title']) ? $values['title'] : ''));
$subtasksAdded = 0;

if ($this->getParam('check_box_no_duplicates') == true ){
$current_subtasks = $this->subtaskModel->getAll($data['task_id']);
foreach ($current_subtasks as $current_subtask) {
if (in_array($current_subtask['title'], $subtasks)) {
$title = array_search($current_subtask['title'], $subtasks);
unset($subtasks[$title]);
}
}
$subtasks = $this->helper->magicalParams->removeDuplicateSubtasks($raw_subtasks, $this->subtaskModel->getAll($data['task_id']));
} else {
$subtasks = $raw_subtasks;
}

foreach ($subtasks as $subtask) {

if (! empty($subtask)) {
$subtaskValues = $values;
$subtaskValues['title'] = $subtask;
$subtaskValues = $this->helper->magicalParams->injectMagicalParams($values, $subtask, $data['task']['project_id']);

list($valid, $errors) = $this->subtaskValidator->validateCreation($subtaskValues);

Expand All @@ -97,7 +113,7 @@ public function doAction(array $data)
$subtasksAdded++;
}
}
//restore the messaging with a flash but this message doesn't seem to appear in the flash area. Only the create message from (kanboard/app/Controller/ActionCreationController.php).
//restore the messaging with a flash but this message doesn't seem to appear in the flash area. Only the create message from (kanboard/app/Controller/ActionCreationController.php).
if ($subtasksAdded > 0) {
if ($subtasksAdded === 1) {
$this->flash->success(t('Subtask added successfully.'));
Expand Down
Loading