1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +01:00

"Hide" columns instead of "Deleting" them

Summary:
Fixes T5342. Fixes T5161. Previously, we were a bit strict about deleting columns because you could orphan tasks. Let users recover these columns more easily so they can't shoot themselves in the foot.

  - Change "Delete" language to "Hide".
  - Add a button to let you see hidden columns.
  - Remove restriction that you can only delete empty columns.

The new button is a little funky, but maybe it merges into the "Add Column" button and that becomes a dropdown with board actions? The rest of this feels OK to me.

Test Plan: See screenshot.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5342, T5161

Differential Revision: https://secure.phabricator.com/D9719
This commit is contained in:
epriestley 2014-06-25 12:30:20 -07:00
parent ad22508e4f
commit a823d143b4
6 changed files with 72 additions and 62 deletions

View file

@ -41,34 +41,16 @@ final class PhabricatorProjectBoardDeleteController
return new Aphront404Response();
}
$error_view = null;
$column_phid = $column->getPHID();
$has_task_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$column_phid,
PhabricatorEdgeConfig::TYPE_COLUMN_HAS_OBJECT);
if ($has_task_phids) {
$error_view = id(new AphrontErrorView())
->setTitle(pht('Column has Tasks!'));
if ($column->isDeleted()) {
$error_view->setErrors(array(pht(
'A column can not be activated if it has tasks '.
'in it. Please remove the tasks and try again.')));
} else {
$error_view->setErrors(array(pht(
'A column can not be deleted if it has tasks '.
'in it. Please remove the tasks and try again.')));
}
}
$view_uri = $this->getApplicationURI(
'/board/'.$this->projectID.'/column/'.$this->id.'/');
if ($request->isFormPost() && !$error_view) {
if ($column->isDeleted()) {
if ($request->isFormPost()) {
if ($column->isHidden()) {
$new_status = PhabricatorProjectColumn::STATUS_ACTIVE;
} else {
$new_status = PhabricatorProjectColumn::STATUS_DELETED;
$new_status = PhabricatorProjectColumn::STATUS_HIDDEN;
}
$type_status = PhabricatorProjectColumnTransaction::TYPE_STATUS;
@ -85,31 +67,29 @@ final class PhabricatorProjectBoardDeleteController
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
if ($column->isDeleted()) {
$title = pht('Activate Column');
if ($column->isHidden()) {
$title = pht('Show Column');
} else {
$title = pht('Delete Column');
}
$submit = $title;
if ($error_view) {
$body = $error_view;
} else if ($column->isDeleted()) {
$body = pht('Are you sure you want to activate this column?');
} else {
$body = pht('Are you sure you want to delete this column?');
$title = pht('Hide Column');
}
$dialog = id(new AphrontDialogView())
->setUser($viewer)
if ($column->isHidden()) {
$body = pht(
'Are you sure you want to show this column?');
} else {
$body = pht(
'Are you sure you want to hide this column? It will no longer '.
'appear on the workboard.');
}
$dialog = $this->newDialog()
->setWidth(AphrontDialogView::WIDTH_FORM)
->setTitle($title)
->appendChild($body)
->setDisableWorkflowOnCancel(true)
->addSubmitButton($title)
->addCancelButton($view_uri);
return id(new AphrontDialogResponse())
->setDialog($dialog);
->addCancelButton($view_uri)
->addSubmitButton($title);
return $dialog;
}
}

View file

@ -24,6 +24,8 @@ final class PhabricatorProjectBoardViewController
$request = $this->getRequest();
$viewer = $request->getUser();
$show_hidden = $request->getBool('hidden');
$project = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->needImages(true);
@ -39,12 +41,16 @@ final class PhabricatorProjectBoardViewController
$this->setProject($project);
$columns = id(new PhabricatorProjectColumnQuery())
$column_query = id(new PhabricatorProjectColumnQuery())
->setViewer($viewer)
->withProjectPHIDs(array($project->getPHID()))
->withStatuses(array(PhabricatorProjectColumn::STATUS_ACTIVE))
->execute();
->withProjectPHIDs(array($project->getPHID()));
if (!$show_hidden) {
$column_query->withStatuses(
array(PhabricatorProjectColumn::STATUS_ACTIVE));
}
$columns = $column_query->execute();
$columns = mpull($columns, null, 'getSequence');
// If there's no default column, create one now.
@ -168,9 +174,11 @@ final class PhabricatorProjectBoardViewController
$panel = id(new PHUIWorkpanelView())
->setHeader($column->getDisplayName())
->setHeaderColor($column->getHeaderColor());
if (!$column->isDefaultColumn()) {
$panel->setEditURI($board_uri.'column/'.$column->getID().'/');
}
$panel->setHeaderAction(id(new PHUIIconView())
->setIconFont('fa-plus')
->setHref('/maniphest/task/create/')
@ -187,6 +195,7 @@ final class PhabricatorProjectBoardViewController
array(
'columnPHID' => $column->getPHID(),
));
$task_phids = idx($task_map, $column->getPHID(), array());
foreach (array_select_keys($tasks, $task_phids) as $task) {
$owner = null;
@ -282,8 +291,6 @@ final class PhabricatorProjectBoardViewController
->setWorkflow(true)
->setName(pht('Advanced Filter...'));
$filter_menu = id(new PhabricatorActionListView())
->setUser($viewer);
foreach ($items as $item) {
@ -296,7 +303,6 @@ final class PhabricatorProjectBoardViewController
->setTag('a')
->setHref('#')
->addSigil('boards-filter-menu')
->setMetadata(
array(
'items' => hsprintf('%s', $filter_menu),
@ -309,12 +315,33 @@ final class PhabricatorProjectBoardViewController
),
$project->getName());
if ($show_hidden) {
$hidden_uri = $request->getRequestURI()
->setQueryParam('hidden', null);
$hidden_icon = id(new PHUIIconView())
->setIconFont('fa-eye-slash bluegrey');
$hidden_text = pht('Hide Hidden Columns');
} else {
$hidden_uri = $request->getRequestURI()
->setQueryParam('hidden', 'true');
$hidden_icon = id(new PHUIIconView())
->setIconFont('fa-eye bluegrey');
$hidden_text = pht('Show Hidden Columns');
}
$hidden_button = id(new PHUIButtonView())
->setText($hidden_text)
->setIcon($hidden_icon)
->setTag('a')
->setHref($hidden_uri);
$header = id(new PHUIHeaderView())
->setHeader($header_link)
->setUser($viewer)
->setNoBackground(true)
->setImage($project->getProfileImageURI())
->setImageURL($this->getApplicationURI('view/'.$project->getID().'/'))
->addActionLink($hidden_button)
->addActionLink($filter_button)
->addActionLink($add_button)
->setPolicyObject($project);

View file

@ -88,8 +88,8 @@ final class PhabricatorProjectColumnDetailController
->setHeader($column->getName())
->setPolicyObject($column);
if ($column->isDeleted()) {
$header->setStatus('fa-ban', 'dark', pht('Deleted'));
if ($column->isHidden()) {
$header->setStatus('fa-ban', 'dark', pht('Hidden'));
}
return $header;
@ -113,25 +113,25 @@ final class PhabricatorProjectColumnDetailController
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit column'))
->setName(pht('Edit Column'))
->setIcon('fa-pencil')
->setHref($this->getApplicationURI($base_uri.'edit/'.$id.'/'))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
if (!$column->isDeleted()) {
if (!$column->isHidden()) {
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Delete column'))
->setIcon('fa-times')
->setName(pht('Hide Column'))
->setIcon('fa-eye-slash')
->setHref($this->getApplicationURI($base_uri.'delete/'.$id.'/'))
->setDisabled(!$can_edit)
->setWorkflow(true));
} else {
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Activate column'))
->setIcon('fa-play-circle-o')
->setName(pht('Show Column'))
->setIcon('fa-eye')
->setHref($this->getApplicationURI($base_uri.'delete/'.$id.'/'))
->setDisabled(!$can_edit)
->setWorkflow(true));

View file

@ -38,8 +38,7 @@ final class PhabricatorProjectPHIDTypeColumn extends PhabricatorPHIDType {
$handle->setName($column->getDisplayName());
$handle->setURI('/project/board/'.$column->getProject()->getID().'/');
$handle->setDisabled(
$column->getStatus() == PhabricatorProjectColumn::STATUS_DELETED);
$handle->setDisabled($column->isHidden());
}
}

View file

@ -6,7 +6,7 @@ final class PhabricatorProjectColumn
PhabricatorDestructableInterface {
const STATUS_ACTIVE = 0;
const STATUS_DELETED = 1;
const STATUS_HIDDEN = 1;
protected $name;
protected $status;
@ -45,8 +45,8 @@ final class PhabricatorProjectColumn
return ($this->getSequence() == 0);
}
public function isDeleted() {
return ($this->getStatus() == self::STATUS_DELETED);
public function isHidden() {
return ($this->getStatus() == self::STATUS_HIDDEN);
}
public function getDisplayName() {
@ -57,6 +57,10 @@ final class PhabricatorProjectColumn
}
public function getHeaderColor() {
if ($this->isHidden()) {
return PHUIActionHeaderView::HEADER_LIGHTRED;
}
if ($this->isDefaultColumn()) {
return PHUIActionHeaderView::HEADER_DARK_GREY;
}

View file

@ -36,11 +36,11 @@ final class PhabricatorProjectColumnTransaction
switch ($new) {
case PhabricatorProjectColumn::STATUS_ACTIVE:
return pht(
'%s activated this column.',
'%s marked this column visible.',
$author_handle);
case PhabricatorProjectColumn::STATUS_DELETED:
case PhabricatorProjectColumn::STATUS_HIDDEN:
return pht(
'%s deleted this column.',
'%s marked this column hidden.',
$author_handle);
}
break;