summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-10-07 19:21:26 -0400
committerFrédéric Guillot <fred@kanboard.net>2014-10-07 19:21:26 -0400
commitf63984af1a1098f9d3925b5d5f1d0b98fdcf05e2 (patch)
treef72296b39352dd7a690987f43e250088550cac88
parentf7fa47fa35cde502317fbc92ca90278541cd628a (diff)
Allow quickly creating and changing state of subtask (pull-request #312)
-rw-r--r--app/Controller/Subtask.php22
-rw-r--r--app/Locales/de_DE/translations.php2
-rw-r--r--app/Locales/es_ES/translations.php2
-rw-r--r--app/Locales/fi_FI/translations.php2
-rw-r--r--app/Locales/fr_FR/translations.php2
-rw-r--r--app/Locales/it_IT/translations.php2
-rw-r--r--app/Locales/pl_PL/translations.php2
-rw-r--r--app/Locales/pt_BR/translations.php2
-rw-r--r--app/Locales/ru_RU/translations.php2
-rw-r--r--app/Locales/sv_SE/translations.php2
-rw-r--r--app/Locales/zh_CN/translations.php2
-rw-r--r--app/Model/Acl.php2
-rw-r--r--app/Templates/subtask_show.php32
13 files changed, 71 insertions, 5 deletions
diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php
index 63ca6303..da9acbab 100644
--- a/app/Controller/Subtask.php
+++ b/app/Controller/Subtask.php
@@ -184,4 +184,26 @@ class Subtask extends Base
$this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#subtasks');
}
+
+ /**
+ * Change status to the next status: Toto -> In Progress -> Done
+ *
+ * @access public
+ */
+ public function toggleStatus()
+ {
+ $task = $this->getTask();
+ $subtask = $this->getSubtask();
+
+ $value = array(
+ 'id' => $subtask['id'],
+ 'status' => ($subtask['status'] + 1) % 3
+ );
+
+ if (! $this->subTask->update($value)) {
+ $this->session->flashError(t('Unable to update your sub-task.'));
+ }
+
+ $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#subtasks');
+ }
}
diff --git a/app/Locales/de_DE/translations.php b/app/Locales/de_DE/translations.php
index 664e1c0e..0aaf5882 100644
--- a/app/Locales/de_DE/translations.php
+++ b/app/Locales/de_DE/translations.php
@@ -536,4 +536,6 @@ return array(
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
// 'New private project' => '',
// 'This project is private' => '',
+ // 'Type here to create a new sub-task' => '',
+ // 'Add' => '',
);
diff --git a/app/Locales/es_ES/translations.php b/app/Locales/es_ES/translations.php
index 218eef07..95e94075 100644
--- a/app/Locales/es_ES/translations.php
+++ b/app/Locales/es_ES/translations.php
@@ -536,4 +536,6 @@ return array(
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
// 'New private project' => '',
// 'This project is private' => '',
+ // 'Type here to create a new sub-task' => '',
+ // 'Add' => '',
);
diff --git a/app/Locales/fi_FI/translations.php b/app/Locales/fi_FI/translations.php
index cd384433..4364ddc5 100644
--- a/app/Locales/fi_FI/translations.php
+++ b/app/Locales/fi_FI/translations.php
@@ -536,4 +536,6 @@ return array(
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
// 'New private project' => '',
// 'This project is private' => '',
+ // 'Type here to create a new sub-task' => '',
+ // 'Add' => '',
);
diff --git a/app/Locales/fr_FR/translations.php b/app/Locales/fr_FR/translations.php
index 03f00474..573b8e89 100644
--- a/app/Locales/fr_FR/translations.php
+++ b/app/Locales/fr_FR/translations.php
@@ -536,4 +536,6 @@ return array(
'ISO format is always accepted, example: "%s" and "%s"' => 'Le format ISO est toujours accepté, exemple : « %s » et « %s »',
'New private project' => 'Nouveau projet privé',
'This project is private' => 'Ce projet est privé',
+ 'Type here to create a new sub-task' => 'Créer une sous-tâche en écrivant le titre ici',
+ 'Add' => 'Ajouter',
);
diff --git a/app/Locales/it_IT/translations.php b/app/Locales/it_IT/translations.php
index f63221dc..a7946872 100644
--- a/app/Locales/it_IT/translations.php
+++ b/app/Locales/it_IT/translations.php
@@ -536,4 +536,6 @@ return array(
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
// 'New private project' => '',
// 'This project is private' => '',
+ // 'Type here to create a new sub-task' => '',
+ // 'Add' => '',
);
diff --git a/app/Locales/pl_PL/translations.php b/app/Locales/pl_PL/translations.php
index 39df7b76..d2eff65d 100644
--- a/app/Locales/pl_PL/translations.php
+++ b/app/Locales/pl_PL/translations.php
@@ -536,4 +536,6 @@ return array(
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
// 'New private project' => '',
// 'This project is private' => '',
+ // 'Type here to create a new sub-task' => '',
+ // 'Add' => '',
);
diff --git a/app/Locales/pt_BR/translations.php b/app/Locales/pt_BR/translations.php
index cb158072..2093af95 100644
--- a/app/Locales/pt_BR/translations.php
+++ b/app/Locales/pt_BR/translations.php
@@ -536,4 +536,6 @@ return array(
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
// 'New private project' => '',
// 'This project is private' => '',
+ // 'Type here to create a new sub-task' => '',
+ // 'Add' => '',
);
diff --git a/app/Locales/ru_RU/translations.php b/app/Locales/ru_RU/translations.php
index fc0240ce..12a5bfe6 100644
--- a/app/Locales/ru_RU/translations.php
+++ b/app/Locales/ru_RU/translations.php
@@ -536,4 +536,6 @@ return array(
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
// 'New private project' => '',
// 'This project is private' => '',
+ // 'Type here to create a new sub-task' => '',
+ // 'Add' => '',
);
diff --git a/app/Locales/sv_SE/translations.php b/app/Locales/sv_SE/translations.php
index 98f208d0..96e4530d 100644
--- a/app/Locales/sv_SE/translations.php
+++ b/app/Locales/sv_SE/translations.php
@@ -536,4 +536,6 @@ return array(
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
// 'New private project' => '',
// 'This project is private' => '',
+ // 'Type here to create a new sub-task' => '',
+ // 'Add' => '',
);
diff --git a/app/Locales/zh_CN/translations.php b/app/Locales/zh_CN/translations.php
index ed45befc..c921eb47 100644
--- a/app/Locales/zh_CN/translations.php
+++ b/app/Locales/zh_CN/translations.php
@@ -536,4 +536,6 @@ return array(
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
// 'New private project' => '',
// 'This project is private' => '',
+ // 'Type here to create a new sub-task' => '',
+ // 'Add' => '',
);
diff --git a/app/Model/Acl.php b/app/Model/Acl.php
index 33fb13b7..0914cbd0 100644
--- a/app/Model/Acl.php
+++ b/app/Model/Acl.php
@@ -37,7 +37,7 @@ class Acl extends Base
'user' => array('edit', 'forbidden', 'logout', 'show', 'external', 'unlinkgoogle', 'unlinkgithub', 'sessions', 'removesession', 'last', 'notifications', 'password'),
'comment' => array('create', 'save', 'confirm', 'remove', 'update', 'edit', 'forbidden'),
'file' => array('create', 'save', 'download', 'confirm', 'remove', 'open', 'image'),
- 'subtask' => array('create', 'save', 'edit', 'update', 'confirm', 'remove'),
+ 'subtask' => array('create', 'save', 'edit', 'update', 'confirm', 'remove', 'togglestatus'),
'task' => array('show', 'create', 'save', 'edit', 'update', 'close', 'open', 'duplicate', 'remove', 'description', 'move', 'copy'),
'category' => array('index', 'save', 'edit', 'update', 'confirm', 'remove'),
'action' => array('index', 'event', 'params', 'create', 'confirm', 'remove'),
diff --git a/app/Templates/subtask_show.php b/app/Templates/subtask_show.php
index ffabbff4..112262bd 100644
--- a/app/Templates/subtask_show.php
+++ b/app/Templates/subtask_show.php
@@ -26,7 +26,22 @@
<?php foreach ($subtasks as $subtask): ?>
<tr>
<td><?= Helper\escape($subtask['title']) ?></td>
- <td><?= Helper\escape($subtask['status_name']) ?></td>
+ <td>
+ <?php if (!isset($not_editable)): ?>
+ <a href="<?= Helper\u('subtask', 'toggleStatus', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>">
+ <?php endif ?>
+ <?php if ($subtask['status'] == 0): ?>
+ <i class="fa fa-square-o fa-fw"></i><i class="fa">&nbsp;<?= Helper\escape($subtask['status_name']) ?></i>
+ <?php elseif ($subtask['status'] == 1): ?>
+ <i class="fa fa-gears fa-fw"></i><i class="fa">&nbsp;<?= Helper\escape($subtask['status_name']) ?></i>
+ <?php else: ?>
+ <i class="fa fa-check-square-o fa-fw"></i><i class="fa">&nbsp;<?= Helper\escape($subtask['status_name']) ?></i>
+ <?php endif ?>
+ <?php if (! isset($not_editable)): ?>
+ </a>
+ <?php endif ?>
+ </td>
+
<td>
<?php if (! empty($subtask['username'])): ?>
<?= Helper\escape($subtask['name'] ?: $subtask['username']) ?>
@@ -43,9 +58,9 @@
</td>
<?php if (! isset($not_editable)): ?>
<td>
- <a href="?controller=subtask&amp;action=edit&amp;task_id=<?= $task['id'] ?>&amp;subtask_id=<?= $subtask['id'] ?>"><?= t('Edit') ?></a>
+ <?= Helper\a(t('Edit'), 'subtask', 'edit', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
<?= t('or') ?>
- <a href="?controller=subtask&amp;action=confirm&amp;task_id=<?= $task['id'] ?>&amp;subtask_id=<?= $subtask['id'] ?>"><?= t('Remove') ?></a>
+ <?= Helper\a(t('Remove'), 'subtask', 'confirm', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
</td>
<?php endif ?>
</tr>
@@ -57,6 +72,15 @@
<?php endforeach ?>
</table>
+ <?php if (! isset($not_editable)): ?>
+ <form method="post" action="<?= Helper\u('subtask', 'save', array('task_id' => $task['id'])) ?>" autocomplete="off">
+ <?= Helper\form_csrf() ?>
+ <?= Helper\form_hidden('task_id', array('task_id' => $task['id'])) ?>
+ <?= Helper\form_text('title', array(), array(), array('required', 'placeholder="'.t('Type here to create a new sub-task').'"')) ?>
+ <input type="submit" value="<?= t('Add') ?>" class="btn btn-blue"/>
+ </form>
+ <?php endif ?>
+
<div class="subtasks-time-tracking">
<h4><?= t('Time tracking') ?></h4>
<ul>
@@ -67,4 +91,4 @@
</div>
</div>
-<?php endif ?> \ No newline at end of file
+<?php endif ?>