1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Generate a default "Backlog" column for boards and put all tasks into it

Summary:
Ref T1344. Autogenerates a "Backlog" column if one does not exist. Assigns all tasks to the backlog column.

For now, this column is always called "Backlog", but we could let it be called other things later.

Test Plan: Loaded a project, got a backlog column, created some columns.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T1344

Differential Revision: https://secure.phabricator.com/D7938
This commit is contained in:
epriestley 2014-01-12 21:40:02 -08:00
parent 3f180496e5
commit a751073d11
4 changed files with 52 additions and 12 deletions

View file

@ -30,7 +30,21 @@ final class PhabricatorProjectBoardController
->withProjectPHIDs(array($project->getPHID()))
->execute();
msort($columns, 'getSequence');
$columns = mpull($columns, null, 'getSequence');
// If there's no default column, create one now.
if (empty($columns[0])) {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$column = PhabricatorProjectColumn::initializeNewColumn($viewer)
->setSequence(0)
->setProjectPHID($project->getPHID())
->save();
$column->attachProject($project);
$columns[0] = $column;
unset($unguarded);
}
ksort($columns);
$tasks = id(new ManiphestTaskQuery())
->setViewer($viewer)
@ -40,15 +54,11 @@ final class PhabricatorProjectBoardController
->execute();
$tasks = mpull($tasks, null, 'getPHID');
// TODO: This is so made up.
$task_map = array();
$default_phid = $columns[0]->getPHID();
foreach ($tasks as $task) {
if ($columns) {
$random_column = $columns[array_rand($columns)]->getPHID();
} else {
$random_column = 0;
}
$task_map[$random_column][] = $task->getPHID();
$task_map[$default_phid][] = $task->getPHID();
}
$board = id(new PHUIWorkboardView())
@ -57,7 +67,8 @@ final class PhabricatorProjectBoardController
foreach ($columns as $column) {
$panel = id(new PHUIWorkpanelView())
->setHeader($column->getName())
->setHeader($column->getDisplayName())
->setHeaderColor($column->getHeaderColor())
->setEditURI('edit/'.$column->getID().'/');
$cards = id(new PHUIObjectItemListView())
@ -114,7 +125,7 @@ final class PhabricatorProjectBoardController
$board_box,
),
array(
'title' => pht('Board'),
'title' => pht('%s Board', $project->getName()),
'device' => true,
));
}

View file

@ -45,7 +45,7 @@ final class PhabricatorProjectBoardEditController
return new Aphront404Response();
}
} else {
$column = new PhabricatorProjectColumn();
$column = PhabricatorProjectColumn::initializeNewColumn($viewer);
}
$errors = array();

View file

@ -10,6 +10,11 @@ final class PhabricatorProjectColumn
private $project = self::ATTACHABLE;
public static function initializeNewColumn(PhabricatorUser $user) {
return id(new PhabricatorProjectColumn())
->setName('');
}
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
@ -30,6 +35,24 @@ final class PhabricatorProjectColumn
return $this->assertAttached($this->project);
}
public function isDefaultColumn() {
return ($this->getSequence() == 0);
}
public function getDisplayName() {
if ($this->isDefaultColumn()) {
return pht('Backlog');
}
return $this->getName();
}
public function getHeaderColor() {
if ($this->isDefaultColumn()) {
return PhabricatorActionHeaderView::HEADER_DARK_GREY;
}
return PhabricatorActionHeaderView::HEADER_GREY;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -6,6 +6,7 @@ final class PHUIWorkpanelView extends AphrontView {
private $header;
private $editURI;
private $footerAction;
private $headerColor = PhabricatorActionHeaderView::HEADER_GREY;
public function setCards(PHUIObjectItemListView $cards) {
$this->cards[] = $cards;
@ -27,6 +28,11 @@ final class PHUIWorkpanelView extends AphrontView {
return $this;
}
public function setHeaderColor($header_color) {
$this->headerColor = $header_color;
return $this;
}
public function render() {
require_celerity_resource('phui-workpanel-view-css');
@ -48,7 +54,7 @@ final class PHUIWorkpanelView extends AphrontView {
$header = id(new PhabricatorActionHeaderView())
->setHeaderTitle($this->header)
->setHeaderColor(PhabricatorActionHeaderView::HEADER_GREY)
->setHeaderColor($this->headerColor)
->addAction($header_edit);
$body = phutil_tag(