diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-03-21 13:22:08 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-03-21 13:22:08 -0400 |
commit | 28a1461f6509ff604c723a044d52f7be3bf75b19 (patch) | |
tree | 0e36e4d2fc9379013ecca633ff2a499c5f20b314 /app/Model/Swimlane.php | |
parent | 9e4eac94fc7ccc75109782ae45a39082572bd2c6 (diff) |
Add swimlane dropdown in task creation form
Diffstat (limited to 'app/Model/Swimlane.php')
-rw-r--r-- | app/Model/Swimlane.php | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/app/Model/Swimlane.php b/app/Model/Swimlane.php index 8f417fca..cf2103c2 100644 --- a/app/Model/Swimlane.php +++ b/app/Model/Swimlane.php @@ -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'); + } + + if (! empty($default)) { + $swimlanes[0] = $default === 'Default swimlane' ? t($default) : $default; + } - return $prepend ? array(-1 => t('All swimlanes')) + $swimlanes : $swimlanes; + return $swimlanes + $this->db->hashtable(self::TABLE)->eq('project_id', $project_id)->orderBy('position', 'asc')->getAll('id', 'name'); } /** |