Project priority is always rendered now

This commit is contained in:
Frederic Guillot
2017-02-26 14:34:03 -05:00
parent 27328255cd
commit 9bcf97a6c9
6 changed files with 16 additions and 27 deletions

View File

@@ -8,6 +8,7 @@ New features:
Improvements: Improvements:
* Change users list layout * Change users list layout
* Project priority is always rendered now
Version 1.0.40 (Feb 24 2017) Version 1.0.40 (Feb 24 2017)
---------------------------- ----------------------------

View File

@@ -143,16 +143,12 @@ class TaskHelper extends Base
public function renderPriorityField(array $project, array $values) public function renderPriorityField(array $project, array $values)
{ {
$html = ''; $range = range($project['priority_start'], $project['priority_end']);
$options = array_combine($range, $range);
$values += array('priority' => $project['priority_default']);
if ($project['priority_end'] != $project['priority_start']) { $html = $this->helper->form->label(t('Priority'), 'priority');
$range = range($project['priority_start'], $project['priority_end']); $html .= $this->helper->form->select('priority', $options, $values, array(), array('tabindex="7"'));
$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"'));
}
return $html; return $html;
} }
@@ -211,15 +207,11 @@ class TaskHelper extends Base
return $this->helper->form->date(t('Due Date'), 'date_due', $values, $errors, $attributes); 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 = ''; $html = '<span class="task-priority" title="'.t('Task priority').'">';
$html .= $this->helper->text->e($priority >= 0 ? 'P'.$priority : '-P'.abs($priority));
if ($project['priority_end'] != $project['priority_start']) { $html .= '</span>';
$html .= '<span class="task-board-priority" title="'.t('Task priority').'">';
$html .= $task['priority'] >= 0 ? 'P'.$task['priority'] : '-P'.abs($task['priority']);
$html .= '</span>';
}
return $html; return $html;
} }

View File

@@ -125,7 +125,7 @@
<span class="task-board-closed"><i class="fa fa-ban fa-fw"></i><?= t('Closed') ?></span> <span class="task-board-closed"><i class="fa fa-ban fa-fw"></i><?= t('Closed') ?></span>
<?php endif ?> <?php endif ?>
<?= $this->task->formatPriority($project, $task) ?> <?= $this->task->renderPriority($task['priority']) ?>
<?= $this->hook->render('template:board:task:icons', array('task' => $task)) ?> <?= $this->hook->render('template:board:task:icons', array('task' => $task)) ?>
</div> </div>

View File

@@ -61,7 +61,6 @@
<?= $this->form->label(t('Highest priority'), 'priority_end') ?> <?= $this->form->label(t('Highest priority'), 'priority_end') ?>
<?= $this->form->number('priority_end', $values, $errors, array('tabindex="10"')) ?> <?= $this->form->number('priority_end', $values, $errors, array('tabindex="10"')) ?>
<p class="form-help"><?= t('If you put zero to the low and high priority, this feature will be disabled.') ?></p>
</fieldset> </fieldset>
<?= $this->modal->submitButtons(array('tabindex' => 11)) ?> <?= $this->modal->submitButtons(array('tabindex' => 11)) ?>

View File

@@ -90,5 +90,5 @@
<span class="task-board-closed"><i class="fa fa-ban fa-fw"></i><?= t('Closed') ?></span> <span class="task-board-closed"><i class="fa fa-ban fa-fw"></i><?= t('Closed') ?></span>
<?php endif ?> <?php endif ?>
<?= $this->task->formatPriority($project, $task) ?> <?= $this->task->renderPriority($task['priority']) ?>
</div> </div>

View File

@@ -11,7 +11,6 @@ class TaskHelperTest extends Base
$helper = new TaskHelper($this->container); $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' => '1', 'priority_start' => '5', 'priority_default' => '2'), array()));
$this->assertNotEmpty($helper->renderPriorityField(array('priority_end' => '3', 'priority_start' => '1', '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() public function testFormatPriority()
@@ -19,15 +18,13 @@ class TaskHelperTest extends Base
$helper = new TaskHelper($this->container); $helper = new TaskHelper($this->container);
$this->assertEquals( $this->assertEquals(
'<span class="task-board-priority" title="Task priority">P2</span>', '<span class="task-priority" title="Task priority">P2</span>',
$helper->formatPriority(array('priority_end' => '3', 'priority_start' => '1', 'priority_default' => '2'), array('priority' => 2)) $helper->renderPriority(2)
); );
$this->assertEquals( $this->assertEquals(
'<span class="task-board-priority" title="Task priority">-P6</span>', '<span class="task-priority" title="Task priority">-P6</span>',
$helper->formatPriority(array('priority_end' => '3', 'priority_start' => '1', 'priority_default' => '2'), array('priority' => -6)) $helper->renderPriority(-6)
); );
$this->assertEmpty($helper->formatPriority(array('priority_end' => '3', 'priority_start' => '3', 'priority_default' => '2'), array()));
} }
} }