From 9bcf97a6c9110afd62b542b92d07d27f945eda96 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 26 Feb 2017 14:34:03 -0500 Subject: Project priority is always rendered now --- ChangeLog | 1 + app/Helper/TaskHelper.php | 26 +++++++++----------------- app/Template/board/task_footer.php | 2 +- app/Template/project_edit/show.php | 1 - app/Template/task_list/task_icons.php | 2 +- tests/units/Helper/TaskHelperTest.php | 11 ++++------- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08b293bb..75537485 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ New features: Improvements: * Change users list layout +* Project priority is always rendered now Version 1.0.40 (Feb 24 2017) ---------------------------- diff --git a/app/Helper/TaskHelper.php b/app/Helper/TaskHelper.php index 9484a479..69520c03 100644 --- a/app/Helper/TaskHelper.php +++ b/app/Helper/TaskHelper.php @@ -143,16 +143,12 @@ class TaskHelper extends Base public function renderPriorityField(array $project, array $values) { - $html = ''; - - if ($project['priority_end'] != $project['priority_start']) { - $range = range($project['priority_start'], $project['priority_end']); - $options = array_combine($range, $range); - $values += array('priority' => $project['priority_default']); + $range = range($project['priority_start'], $project['priority_end']); + $options = array_combine($range, $range); + $values += array('priority' => $project['priority_default']); - $html .= $this->helper->form->label(t('Priority'), 'priority'); - $html .= $this->helper->form->select('priority', $options, $values, array(), array('tabindex="7"')); - } + $html = $this->helper->form->label(t('Priority'), 'priority'); + $html .= $this->helper->form->select('priority', $options, $values, array(), array('tabindex="7"')); return $html; } @@ -211,15 +207,11 @@ class TaskHelper extends Base return $this->helper->form->date(t('Due Date'), 'date_due', $values, $errors, $attributes); } - public function formatPriority(array $project, array $task) + public function renderPriority($priority) { - $html = ''; - - if ($project['priority_end'] != $project['priority_start']) { - $html .= ''; - $html .= $task['priority'] >= 0 ? 'P'.$task['priority'] : '-P'.abs($task['priority']); - $html .= ''; - } + $html = ''; + $html .= $this->helper->text->e($priority >= 0 ? 'P'.$priority : '-P'.abs($priority)); + $html .= ''; return $html; } diff --git a/app/Template/board/task_footer.php b/app/Template/board/task_footer.php index 79b7c3e9..1ad1c9f1 100644 --- a/app/Template/board/task_footer.php +++ b/app/Template/board/task_footer.php @@ -125,7 +125,7 @@ - task->formatPriority($project, $task) ?> + task->renderPriority($task['priority']) ?> hook->render('template:board:task:icons', array('task' => $task)) ?> diff --git a/app/Template/project_edit/show.php b/app/Template/project_edit/show.php index 074f1d37..62bd9af6 100644 --- a/app/Template/project_edit/show.php +++ b/app/Template/project_edit/show.php @@ -61,7 +61,6 @@ form->label(t('Highest priority'), 'priority_end') ?> form->number('priority_end', $values, $errors, array('tabindex="10"')) ?> -

modal->submitButtons(array('tabindex' => 11)) ?> diff --git a/app/Template/task_list/task_icons.php b/app/Template/task_list/task_icons.php index da08a43f..8694d147 100644 --- a/app/Template/task_list/task_icons.php +++ b/app/Template/task_list/task_icons.php @@ -90,5 +90,5 @@ - task->formatPriority($project, $task) ?> + task->renderPriority($task['priority']) ?> diff --git a/tests/units/Helper/TaskHelperTest.php b/tests/units/Helper/TaskHelperTest.php index 8609983e..d2bd6ea9 100644 --- a/tests/units/Helper/TaskHelperTest.php +++ b/tests/units/Helper/TaskHelperTest.php @@ -11,7 +11,6 @@ class TaskHelperTest extends Base $helper = new TaskHelper($this->container); $this->assertNotEmpty($helper->renderPriorityField(array('priority_end' => '1', 'priority_start' => '5', 'priority_default' => '2'), array())); $this->assertNotEmpty($helper->renderPriorityField(array('priority_end' => '3', 'priority_start' => '1', 'priority_default' => '2'), array())); - $this->assertEmpty($helper->renderPriorityField(array('priority_end' => '3', 'priority_start' => '3', 'priority_default' => '2'), array())); } public function testFormatPriority() @@ -19,15 +18,13 @@ class TaskHelperTest extends Base $helper = new TaskHelper($this->container); $this->assertEquals( - 'P2', - $helper->formatPriority(array('priority_end' => '3', 'priority_start' => '1', 'priority_default' => '2'), array('priority' => 2)) + 'P2', + $helper->renderPriority(2) ); $this->assertEquals( - '-P6', - $helper->formatPriority(array('priority_end' => '3', 'priority_start' => '1', 'priority_default' => '2'), array('priority' => -6)) + '-P6', + $helper->renderPriority(-6) ); - - $this->assertEmpty($helper->formatPriority(array('priority_end' => '3', 'priority_start' => '3', 'priority_default' => '2'), array())); } } -- cgit v1.2.3