Skip to content

Commit

Permalink
Merge pull request #14 from creecros/creecros-patch-1
Browse files Browse the repository at this point in the history
do not duplicate option
  • Loading branch information
creecros authored Jan 24, 2019
2 parents 749ed28 + 7765e49 commit d956b88
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
18 changes: 14 additions & 4 deletions Action/AutoCreateSubtask.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function getActionRequiredParameters()
'multitasktitles' => t('Subtask Title(s)'),
'time_estimated' => t('Estimated Time in Hours'),
'duration' => t('Duration in days'),
'check_box' => t('Apply to all Columns'),
'check_box_all_columns' => t('Apply to all Columns'),
'check_box_no_duplicates' => t('Do not duplicate subtasks'),
);
}

Expand Down Expand Up @@ -63,11 +64,20 @@ public function doAction(array $data)
'due_date' => strtotime('+'.$this->getParam('duration').'days'),
);

$subtasks = explode("\r\n", isset($values['title']) ? $values['title'] : '');
$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]);
}
}
}

foreach ($subtasks as $subtask) {
$subtask = trim($subtask);

if (! empty($subtask)) {
$subtaskValues = $values;
Expand Down Expand Up @@ -102,7 +112,7 @@ public function doAction(array $data)
public function hasRequiredCondition(array $data)
{

if ($this->getParam('check_box')) {
if ($this->getParam('check_box_all_columns')) {
return $data['task']['column_id'] == $data['task']['column_id'];
} else {
return $data['task']['column_id'] == $this->getParam('column_id');
Expand Down
18 changes: 14 additions & 4 deletions Action/AutoCreateSubtaskVanilla.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function getActionRequiredParameters()
'user_id' => t('Assignee'),
'multitasktitles' => t('Subtask Title(s)'),
'time_estimated' => t('Estimated Time in Hours'),
'check_box' => t('Apply to all Columns'),
'check_box_all_columns' => t('Apply to all Columns'),
'check_box_no_duplicates' => t('Do not duplicate subtasks'),
);
}

Expand Down Expand Up @@ -61,11 +62,20 @@ public function doAction(array $data)
'status' => 0,
);

$subtasks = explode("\r\n", isset($values['title']) ? $values['title'] : '');
$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]);
}
}
}

foreach ($subtasks as $subtask) {
$subtask = trim($subtask);

if (! empty($subtask)) {
$subtaskValues = $values;
Expand Down Expand Up @@ -100,7 +110,7 @@ public function doAction(array $data)
public function hasRequiredCondition(array $data)
{

if ($this->getParam('check_box')) {
if ($this->getParam('check_box_all_columns')) {
return $data['task']['column_id'] == $data['task']['column_id'];
} else {
return $data['task']['column_id'] == $this->getParam('column_id');
Expand Down
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '1.0.4';
return '2.0.0';
}

public function getPluginDescription()
Expand Down

0 comments on commit d956b88

Please sign in to comment.