1 Commits
v1.1.2 ... v1.2

6 changed files with 124 additions and 47 deletions

View File

@@ -19,9 +19,10 @@ class RecurrenceController extends BaseController
{ {
$task = $this->getTask(); $task = $this->getTask();
$columns = $this->targetColumns($task); $columns = $this->targetColumns($task);
$meta = $this->taskMetadataModel->getAll($task['id']);
if (empty($values)) { if (empty($values)) {
$values = $this->getStoredValues($task, $columns); $values = $this->getStoredValues($meta, $task, $columns);
} }
$this->response->html($this->template->render('recoReco:recurrence/edit', array( $this->response->html($this->template->render('recoReco:recurrence/edit', array(
@@ -33,6 +34,8 @@ class RecurrenceController extends BaseController
'has_due_date' => ! empty($task['date_due']), 'has_due_date' => ! empty($task['date_due']),
'is_native' => $task['recurrence_status'] != TaskModel::RECURRING_STATUS_NONE, 'is_native' => $task['recurrence_status'] != TaskModel::RECURRING_STATUS_NONE,
'has_target' => ! empty($columns), 'has_target' => ! empty($columns),
'is_clone' => isset($meta['recoreco_clone']) && $meta['recoreco_clone'] == 1,
'source_id' => isset($meta['recoreco_source']) ? (int) $meta['recoreco_source'] : 0,
))); )));
} }
@@ -42,9 +45,14 @@ class RecurrenceController extends BaseController
$input = $this->request->getValues(); $input = $this->request->getValues();
$columns = $this->targetColumns($task); $columns = $this->targetColumns($task);
// Only a plain card (a due date, not native-recurring, and a valid target) may be enabled. // A clone can never be made recurring (that would recurse). Guard even though the modal
// hides the form for clones.
$is_clone = (int) $this->taskMetadataModel->get($task['id'], 'recoreco_clone', 0) === 1;
// Only a plain card (a due date, not native-recurring, not a clone, a valid target) may enable.
$can_recur = ! empty($task['date_due']) $can_recur = ! empty($task['date_due'])
&& $task['recurrence_status'] == TaskModel::RECURRING_STATUS_NONE && $task['recurrence_status'] == TaskModel::RECURRING_STATUS_NONE
&& ! $is_clone
&& ! empty($columns); && ! empty($columns);
$enabled = ($can_recur && isset($input['recoreco_enabled']) && $input['recoreco_enabled'] == 1) ? 1 : 0; $enabled = ($can_recur && isset($input['recoreco_enabled']) && $input['recoreco_enabled'] == 1) ? 1 : 0;
@@ -104,10 +112,8 @@ class RecurrenceController extends BaseController
return empty($keys) ? 0 : (int) $keys[0]; return empty($keys) ? 0 : (int) $keys[0];
} }
private function getStoredValues(array $task, array $columns) private function getStoredValues(array $meta, array $task, array $columns)
{ {
$meta = $this->taskMetadataModel->getAll($task['id']);
return array( return array(
'recoreco_enabled' => isset($meta['recoreco_enabled']) ? (int) $meta['recoreco_enabled'] : 0, 'recoreco_enabled' => isset($meta['recoreco_enabled']) ? (int) $meta['recoreco_enabled'] : 0,
'recoreco_target_column' => $this->resolveTarget(isset($meta['recoreco_target_column']) ? $meta['recoreco_target_column'] : 0, $columns), 'recoreco_target_column' => $this->resolveTarget(isset($meta['recoreco_target_column']) ? $meta['recoreco_target_column'] : 0, $columns),

38
Helper/RecoRecoHelper.php Normal file
View File

@@ -0,0 +1,38 @@
<?php
namespace Kanboard\Plugin\RecoReco\Helper;
use Kanboard\Core\Base;
use Kanboard\Model\TaskModel;
/**
* Board helper: which RecoReco icon a card should show.
*
* Single-icon rule -- RecoReco only renders when the card is NOT native-recurring
* (recurrence_status == NONE), so native's icon and RecoReco's icon can never appear together.
*/
class RecoRecoHelper extends Base
{
/**
* @param array $task A board task row (has recurrence_status and id).
* @return string 'template', 'clone', or '' (no RecoReco icon).
*/
public function iconType(array $task)
{
if ((int) $task['recurrence_status'] !== TaskModel::RECURRING_STATUS_NONE) {
return '';
}
$meta = $this->taskMetadataModel->getAll($task['id']);
if (isset($meta['recoreco_enabled']) && $meta['recoreco_enabled'] == 1) {
return 'template';
}
if (isset($meta['recoreco_clone']) && $meta['recoreco_clone'] == 1) {
return 'clone';
}
return '';
}
}

View File

@@ -17,6 +17,9 @@ class Plugin extends Base
'template' => 'plugins/RecoReco/Asset/js/recoreco-modal.js', 'template' => 'plugins/RecoReco/Asset/js/recoreco-modal.js',
)); ));
// Board card icon: black on a recurring template, white (inverse) on a generated copy.
$this->template->hook->attach('template:board:task:icons', 'recoReco:board/task_icon');
// The scheduling engine runs from the CLI (cron). Registered CLI-only so web requests do // The scheduling engine runs from the CLI (cron). Registered CLI-only so web requests do
// not build the console app. // not build the console app.
if (php_sapi_name() === 'cli') { if (php_sapi_name() === 'cli') {
@@ -24,6 +27,13 @@ class Plugin extends Base
} }
} }
public function getHelpers()
{
return array(
'Plugin\RecoReco\Helper' => array('RecoRecoHelper'),
);
}
public function getPluginName() public function getPluginName()
{ {
return 'RecoReco'; return 'RecoReco';
@@ -41,7 +51,7 @@ class Plugin extends Base
public function getPluginVersion() public function getPluginVersion()
{ {
return '1.1.2'; return '1.2.0';
} }
public function getPluginHomepage() public function getPluginHomepage()

View File

@@ -0,0 +1,10 @@
<?php $type = $this->RecoRecoHelper->iconType($task) ?>
<?php if ($type === 'template'): ?>
<span title="<?= t('RecoReco: recurring template') ?>">
<i class="fa fa-refresh fa-rotate-90" role="img" aria-label="<?= t('RecoReco: recurring template') ?>"></i>
</span>
<?php elseif ($type === 'clone'): ?>
<span title="<?= t('RecoReco: generated copy') ?>">
<i class="fa fa-refresh fa-rotate-90 fa-inverse" role="img" aria-label="<?= t('RecoReco: generated copy') ?>"></i>
</span>
<?php endif ?>

View File

@@ -9,6 +9,17 @@
</h2> </h2>
</div> </div>
<?php if ($is_clone): ?>
<p class="alert alert-info">
<?= t('This card is a copy generated by RecoReco, so it cannot itself be made recurring.') ?>
<?php if ($source_id): ?>
<?= $this->url->link(t('Open the recurring template'), 'TaskViewController', 'show', array('task_id' => $source_id)) ?>
<?php endif ?>
</p>
<?php else: ?>
<?php $can_recur = $has_due_date && ! $is_native && $has_target ?> <?php $can_recur = $has_due_date && ! $is_native && $has_target ?>
<?php if (! $has_due_date): ?> <?php if (! $has_due_date): ?>
@@ -53,3 +64,5 @@
<?= $this->modal->submitButtons() ?> <?= $this->modal->submitButtons() ?>
</form> </form>
<?php endif ?>

View File

@@ -1 +1 @@
RecoReco v1.1.2 RecoReco v1.2