* sort by priority
This commit is contained in:
parent
2e0f4936af
commit
4881bb98cf
@ -6,6 +6,20 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class KanbanBoard implements \JsonSerializable
|
||||
{
|
||||
const PRIO_TRIVIAL = 0;
|
||||
const PRIO_MINOR = 1;
|
||||
const PRIO_MAJOR = 2;
|
||||
const PRIO_CRITICAL = 3;
|
||||
const PRIO_BLOCKER = 4;
|
||||
|
||||
private $priorityMap = [
|
||||
'Trivial' => self::PRIO_TRIVIAL,
|
||||
'Minor' => self::PRIO_MINOR,
|
||||
'Major' => self::PRIO_MAJOR,
|
||||
'Critical' => self::PRIO_CRITICAL,
|
||||
'Blocker' => self::PRIO_BLOCKER,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var KanbanEntry[]|ArrayCollection
|
||||
*/
|
||||
@ -202,16 +216,28 @@ class KanbanBoard implements \JsonSerializable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param KanbanEntry[] $toSort
|
||||
* @return KanbanEntry[]
|
||||
*/
|
||||
private function prioSort(array $toSort): array
|
||||
{
|
||||
usort($toSort, function(KanbanEntry $a, KanbanEntry $b){
|
||||
return $this->priorityMap[$b->getIssuePriority()] <=> $this->priorityMap[$a->getIssuePriority()];
|
||||
});
|
||||
return $toSort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'inbox' => $this->inbox->getValues(),
|
||||
'inProgress' => $this->inProgress->getValues(),
|
||||
'verification' => $this->verification->getValues(),
|
||||
'done' => $this->done->getValues(),
|
||||
'inbox' => $this->prioSort($this->inbox->getValues()),
|
||||
'inProgress' => $this->prioSort($this->inProgress->getValues()),
|
||||
'verification' => $this->prioSort($this->verification->getValues()),
|
||||
'done' => $this->prioSort($this->done->getValues()),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user