1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Allow the workboard backlog column to be reordered

Summary:
Fixes T5677.

  - Instead of using `sequence == 0` to mean "this is the backlog column", flag the column explicitly.
  - Migrate existing sequence 0 columns to have the flag.
  - Add the flag when initializing or copying a board.
  - Remove special backlog logic when reordering columns.

Test Plan:
  - Migrated columns, viewed some boards, they looked identical.
  - Reordered the backlog column a bunch of times (first, last, middle, dragged other stuff around).
  - Added tasks to a project, saw them show up in the reordered backlog.
  - Initialized a new board and saw a backlog column show up.
  - Copied an existing board and saw the backlog column come over.
  - Tried to hide a backlog column.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5677

Differential Revision: https://secure.phabricator.com/D10189
This commit is contained in:
epriestley 2014-08-08 15:50:36 -07:00
parent 237b1d769b
commit 24a6eeb8d8
8 changed files with 56 additions and 27 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_project.project_column
ADD properties LONGTEXT NOT NULL COLLATE utf8_bin;

View file

@ -0,0 +1,2 @@
UPDATE {$NAMESPACE}_project.project_column
SET properties = '{}' WHERE properties = '';

View file

@ -0,0 +1,24 @@
<?php
$table = new PhabricatorProjectColumn();
$conn_w = $table->establishConnection('w');
foreach (new LiskMigrationIterator($table) as $column) {
$id = $column->getID();
echo "Adjusting column {$id}...\n";
if ($column->getSequence() == 0) {
$properties = $column->getProperties();
$properties['isDefault'] = true;
queryfx(
$conn_w,
'UPDATE %T SET properties = %s WHERE id = %d',
$table->getTableName(),
json_encode($properties),
$id);
}
}
echo "Done.\n";

View file

@ -60,6 +60,7 @@ final class PhabricatorProjectBoardImportController
->setSequence($import_column->getSequence()) ->setSequence($import_column->getSequence())
->setProjectPHID($project->getPHID()) ->setProjectPHID($project->getPHID())
->setName($import_column->getName()) ->setName($import_column->getName())
->setProperties($import_column->getProperties())
->save(); ->save();
} }
$table->saveTransaction(); $table->saveTransaction();

View file

@ -54,11 +54,9 @@ final class PhabricatorProjectBoardReorderController
return new Aphront404Response(); return new Aphront404Response();
} }
// TODO: We could let you move the backlog column around if you really
// want, but for now we use sequence position 0 as magic.
$target_column = $columns[$column_phid]; $target_column = $columns[$column_phid];
$new_sequence = $request->getInt('sequence'); $new_sequence = $request->getInt('sequence');
if ($target_column->isDefaultColumn() || $new_sequence < 1) { if ($new_sequence < 0) {
return new Aphront404Response(); return new Aphront404Response();
} }
@ -101,11 +99,6 @@ final class PhabricatorProjectBoardReorderController
$list_id = celerity_generate_unique_node_id(); $list_id = celerity_generate_unique_node_id();
$static_list = id(new PHUIObjectItemListView())
->setUser($viewer)
->setFlush(true)
->setStackable(true);
$list = id(new PHUIObjectItemListView()) $list = id(new PHUIObjectItemListView())
->setUser($viewer) ->setUser($viewer)
->setID($list_id) ->setID($list_id)
@ -120,10 +113,6 @@ final class PhabricatorProjectBoardReorderController
$item->setDisabled(true); $item->setDisabled(true);
} }
if ($column->isDefaultColumn()) {
$item->setDisabled(true);
$static_list->addItem($item);
} else {
$item->setGrippable(true); $item->setGrippable(true);
$item->addSigil('board-column'); $item->addSigil('board-column');
$item->setMetadata( $item->setMetadata(
@ -135,8 +124,6 @@ final class PhabricatorProjectBoardReorderController
$list->addItem($item); $list->addItem($item);
} }
}
Javelin::initBehavior( Javelin::initBehavior(
'reorder-columns', 'reorder-columns',
array( array(
@ -147,9 +134,7 @@ final class PhabricatorProjectBoardReorderController
return $this->newDialog() return $this->newDialog()
->setTitle(pht('Reorder Columns')) ->setTitle(pht('Reorder Columns'))
->setWidth(AphrontDialogView::WIDTH_FORM) ->setWidth(AphrontDialogView::WIDTH_FORM)
->appendParagraph(pht('This column can not be moved:')) ->appendParagraph(pht('Drag and drop columns to reorder them.'))
->appendChild($static_list)
->appendParagraph(pht('Drag and drop these columns to reorder them:'))
->appendChild($list) ->appendChild($list)
->addSubmitButton(pht('Done')); ->addSubmitButton(pht('Done'));
} }

View file

@ -74,6 +74,7 @@ final class PhabricatorProjectBoardViewController
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$column = PhabricatorProjectColumn::initializeNewColumn($viewer) $column = PhabricatorProjectColumn::initializeNewColumn($viewer)
->setSequence(0) ->setSequence(0)
->setProperty('isDefault', true)
->setProjectPHID($project->getPHID()) ->setProjectPHID($project->getPHID())
->save(); ->save();
$column->attachProject($project); $column->attachProject($project);

View file

@ -17,6 +17,7 @@ final class PhabricatorProjectColumn
protected $status; protected $status;
protected $projectPHID; protected $projectPHID;
protected $sequence; protected $sequence;
protected $properties = array();
private $project = self::ATTACHABLE; private $project = self::ATTACHABLE;
@ -29,6 +30,9 @@ final class PhabricatorProjectColumn
public function getConfiguration() { public function getConfiguration() {
return array( return array(
self::CONFIG_AUX_PHID => true, self::CONFIG_AUX_PHID => true,
self::CONFIG_SERIALIZATION => array(
'properties' => self::SERIALIZATION_JSON,
),
) + parent::getConfiguration(); ) + parent::getConfiguration();
} }
@ -47,7 +51,7 @@ final class PhabricatorProjectColumn
} }
public function isDefaultColumn() { public function isDefaultColumn() {
return ($this->getSequence() == 0); return (bool)$this->getProperty('isDefault');
} }
public function isHidden() { public function isHidden() {
@ -75,9 +79,19 @@ final class PhabricatorProjectColumn
if ($this->isDefaultColumn()) { if ($this->isDefaultColumn()) {
return PHUIActionHeaderView::HEADER_DARK_GREY; return PHUIActionHeaderView::HEADER_DARK_GREY;
} }
return PHUIActionHeaderView::HEADER_GREY; return PHUIActionHeaderView::HEADER_GREY;
} }
public function getProperty($key, $default = null) {
return idx($this->properties, $key, $default);
}
public function setProperty($key, $value) {
$this->properties[$key] = $value;
return $this;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -37,7 +37,7 @@ JX.behavior('reorder-columns', function(config) {
var parameters = { var parameters = {
columnPHID: node_data.columnPHID, columnPHID: node_data.columnPHID,
sequence: (sequence === null) ? 1 : (parseInt(sequence, 10) + 1) sequence: (sequence === null) ? 0 : (parseInt(sequence, 10) + 1)
}; };
new JX.Workflow(config.reorderURI, parameters) new JX.Workflow(config.reorderURI, parameters)