Merge pull-request #2707

This commit is contained in:
Frederic Guillot
2016-10-05 08:46:39 -04:00
9 changed files with 107 additions and 71 deletions

View File

@@ -27,10 +27,7 @@ class SubtaskController extends BaseController
$task = $this->getTask();
if (empty($values)) {
$values = array(
'task_id' => $task['id'],
'another_subtask' => $this->request->getIntegerParam('another_subtask', 0)
);
$values = $this->prepareValues($task);
}
$this->response->html($this->template->render('subtask/create', array(
@@ -40,6 +37,24 @@ class SubtaskController extends BaseController
'task' => $task,
)));
}
/**
* Prepare form values
*
* @access protected
* @param array $task
* @return array
*/
protected function prepareValues(array $task)
{
$values = array(
'task_id' => $task['id'],
'another_subtask' => $this->request->getIntegerParam('another_subtask', 0)
);
$values = $this->hook->merge('controller:subtask:form:default', $values, array('default_values' => $values));
return $values;
}
/**
* Validation and creation

View File

@@ -255,6 +255,7 @@ class SubtaskModel extends Base
{
$this->helper->model->removeFields($values, array('another_subtask'));
$this->helper->model->resetFields($values, array('time_estimated', 'time_spent'));
$this->hook->reference('model:subtask:modification:prepare', $values);
}
/**
@@ -272,6 +273,7 @@ class SubtaskModel extends Base
$values['time_estimated'] = isset($values['time_estimated']) ? $values['time_estimated'] : 0;
$values['time_spent'] = isset($values['time_spent']) ? $values['time_spent'] : 0;
$values['user_id'] = isset($values['user_id']) ? $values['user_id'] : 0;
$this->hook->reference('model:subtask:creation:prepare', $values);
}
/**

View File

@@ -1,7 +1,8 @@
<div class="tooltip-large">
<table class="table-small">
<tr>
<th class="column-80"><?= t('Subtask') ?></th>
<th class="column-70"><?= t('Subtask') ?></th>
<?= $this->hook->render('template:board:tooltip:subtasks:header:before-assignee') ?>
<th><?= t('Assignee') ?></th>
</tr>
<?php foreach ($subtasks as $subtask): ?>
@@ -9,6 +10,7 @@
<td>
<?= $this->subtask->toggleStatus($subtask, $task['project_id']) ?>
</td>
<?= $this->hook->render('template:board:tooltip:subtasks:rows', array('subtask' => $subtask)) ?>
<td>
<?php if (! empty($subtask['username'])): ?>
<?= $this->text->e($subtask['name'] ?: $subtask['username']) ?>

View File

@@ -10,6 +10,7 @@
<th class="column-20"><?= $paginator->order(t('Project'), 'project_name') ?></th>
<th><?= $paginator->order(t('Task'), 'task_name') ?></th>
<th><?= $paginator->order(t('Subtask'), \Kanboard\Model\SubtaskModel::TABLE.'.title') ?></th>
<?= $this->hook->render('template:dashboard:subtasks:header:before-timetracking', array('paginator' => $paginator)) ?>
<th class="column-20"><?= t('Time tracking') ?></th>
</tr>
<?php foreach ($paginator->getCollection() as $subtask): ?>
@@ -26,6 +27,7 @@
<td>
<?= $this->subtask->toggleStatus($subtask, $subtask['project_id']) ?>
</td>
<?= $this->hook->render('template:dashboard:subtasks:rows', array('subtask' => $subtask)) ?>
<td>
<?php if (! empty($subtask['time_spent'])): ?>
<strong><?= $this->text->e($subtask['time_spent']).'h' ?></strong> <?= t('spent') ?>

View File

@@ -9,7 +9,8 @@
<?= $this->subtask->selectTitle($values, $errors, array('autofocus')) ?>
<?= $this->subtask->selectAssignee($users_list, $values, $errors) ?>
<?= $this->subtask->selectTimeEstimated($values, $errors) ?>
<?= $this->hook->render('template:subtask:form:create', array('values' => $values, 'errors' => $errors)) ?>
<?= $this->form->checkbox('another_subtask', t('Create another sub-task'), 1, isset($values['another_subtask']) && $values['another_subtask'] == 1) ?>
<div class="form-actions">

View File

@@ -11,7 +11,8 @@
<?= $this->subtask->selectAssignee($users_list, $values, $errors) ?>
<?= $this->subtask->selectTimeEstimated($values, $errors) ?>
<?= $this->subtask->selectTimeSpent($values, $errors) ?>
<?= $this->hook->render('template:subtask:form:edit', array('values' => $values, 'errors' => $errors)) ?>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
<?= t('or') ?>

View File

@@ -7,6 +7,7 @@
<tr>
<th class="column-40"><?= t('Title') ?></th>
<th><?= t('Assignee') ?></th>
<?= $this->hook->render('template:subtask:table:header:before-timetracking') ?>
<th><?= t('Time tracking') ?></th>
<?php if ($editable): ?>
<th class="column-5"></th>
@@ -29,6 +30,7 @@
<?= $this->text->e($subtask['name'] ?: $subtask['username']) ?>
<?php endif ?>
</td>
<?= $this->hook->render('template:subtask:table:rows', array('subtask' => $subtask)) ?>
<td>
<ul class="no-bullet">
<li>

View File

@@ -10,13 +10,14 @@
<?= $this->task->selectTitle($values, $errors) ?>
<?= $this->task->selectDescription($values, $errors) ?>
<?= $this->task->selectTags($project) ?>
<?= $this->hook->render('template:task:form:first-column', array('values' => $values, 'errors' => $errors)) ?>
<?php if (! isset($duplicate)): ?>
<?= $this->form->checkbox('another_task', t('Create another task'), 1, isset($values['another_task']) && $values['another_task'] == 1) ?>
<?= $this->form->checkbox('duplicate_multiple_projects', t('Duplicate to multiple projects'), 1) ?>
<?php endif ?>
<?= $this->hook->render('template:task:form:first-column', array('values' => $values, 'errors' => $errors)) ?>
</div>
<div class="form-column">