Add swimlane dropdown in task creation form

This commit is contained in:
Frederic Guillot 2015-03-21 13:22:08 -04:00
parent 9e4eac94fc
commit 28a1461f65
3 changed files with 30 additions and 12 deletions

View File

@ -93,11 +93,12 @@ class Task extends Base
{
$project = $this->getProject();
$method = $this->request->isAjax() ? 'render' : 'layout';
$swimlanes_list = $this->swimlane->getList($project['id']);
if (empty($values)) {
$values = array(
'swimlane_id' => $this->request->getIntegerParam('swimlane_id'),
'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)),
'column_id' => $this->request->getIntegerParam('column_id'),
'color_id' => $this->request->getStringParam('color_id'),
'owner_id' => $this->request->getIntegerParam('owner_id'),
@ -114,6 +115,7 @@ class Task extends Base
'users_list' => $this->projectPermission->getMemberList($project['id'], true, false, true),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($project['id']),
'swimlanes_list' => $swimlanes_list,
'date_format' => $this->config->get('application_date_format'),
'date_formats' => $this->dateParser->getAvailableFormats(),
'title' => $project['name'].' > '.t('New task')

View File

@ -99,10 +99,16 @@ class Swimlane extends Base
*/
public function getDefault($project_id)
{
return $this->db->table(Project::TABLE)
->eq('id', $project_id)
->columns('id', 'default_swimlane', 'show_default_swimlane')
->findOne();
$result = $this->db->table(Project::TABLE)
->eq('id', $project_id)
->columns('id', 'default_swimlane', 'show_default_swimlane')
->findOne();
if ($result['default_swimlane'] === 'Default swimlane') {
$result['default_swimlane'] = t($result['default_swimlane']);
}
return $result;
}
/**
@ -166,6 +172,11 @@ class Swimlane extends Base
->findOneColumn('default_swimlane');
if ($default_swimlane) {
if ($default_swimlane === 'Default swimlane') {
$default_swimlane = t($default_swimlane);
}
array_unshift($swimlanes, array('id' => 0, 'name' => $default_swimlane));
}
@ -183,14 +194,17 @@ class Swimlane extends Base
public function getList($project_id, $prepend = false)
{
$swimlanes = array();
$swimlanes[] = $this->db->table(Project::TABLE)->eq('id', $project_id)->findOneColumn('default_swimlane');
$default = $this->db->table(Project::TABLE)->eq('id', $project_id)->eq('show_default_swimlane', 1)->findOneColumn('default_swimlane');
$swimlanes = array_merge(
$swimlanes,
$this->db->hashtable(self::TABLE)->eq('project_id', $project_id)->orderBy('name', 'asc')->getAll('id', 'name')
);
if ($prepend) {
$swimlanes[-1] = t('All swimlanes');
}
return $prepend ? array(-1 => t('All swimlanes')) + $swimlanes : $swimlanes;
if (! empty($default)) {
$swimlanes[0] = $default === 'Default swimlane' ? t($default) : $default;
}
return $swimlanes + $this->db->hashtable(self::TABLE)->eq('project_id', $project_id)->orderBy('position', 'asc')->getAll('id', 'name');
}
/**

View File

@ -47,7 +47,6 @@
<div class="form-column">
<?= $this->formHidden('project_id', $values) ?>
<?= $this->formHidden('swimlane_id', $values) ?>
<?= $this->formLabel(t('Assignee'), 'owner_id') ?>
<?= $this->formSelect('owner_id', $users_list, $values, $errors) ?><br/>
@ -55,6 +54,9 @@
<?= $this->formLabel(t('Category'), 'category_id') ?>
<?= $this->formSelect('category_id', $categories_list, $values, $errors) ?><br/>
<?= $this->formLabel(t('Swimlane'), 'swimlane_id') ?>
<?= $this->formSelect('swimlane_id', $swimlanes_list, $values, $errors) ?><br/>
<?= $this->formLabel(t('Column'), 'column_id') ?>
<?= $this->formSelect('column_id', $columns_list, $values, $errors) ?><br/>