1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 16:00:59 +01:00

Allow stacked comment actions to be explicitly ordered

Summary:
Ref T6027. Normally, actions use the same order as the form, but in some cases (like moving stuff on workboards) it makes sense to reorder them explicitly.

Pin "Move on board" near the bottom, and "projects/subscribers" at the bottom. I think these are generally reasonable rules in all cases.

Test Plan: Opened menu, saw slightly better action order.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T6027

Differential Revision: https://secure.phabricator.com/D15639
This commit is contained in:
epriestley 2016-04-06 06:22:44 -07:00
parent 67629aab14
commit 4d32c990ab
6 changed files with 32 additions and 1 deletions

View file

@ -163,6 +163,7 @@ EODOCS
->setIsDefaultable(false)
->setIsLockable(false)
->setCommentActionLabel(pht('Move on Workboard'))
->setCommentActionOrder(2000)
->setColumnMap($column_map),
id(new PhabricatorTextEditField())
->setKey('title')

View file

@ -50,6 +50,7 @@ final class PhabricatorProjectsEditEngineExtension
->setIsCopyable(true)
->setUseEdgeTransactions(true)
->setCommentActionLabel(pht('Change Project Tags'))
->setCommentActionOrder(8000)
->setDescription(pht('Select project tags for the object.'))
->setTransactionType($edge_type)
->setMetadataValue('edge:type', $project_edge_type)

View file

@ -45,6 +45,7 @@ final class PhabricatorSubscriptionsEditEngineExtension
->setIsCopyable(true)
->setUseEdgeTransactions(true)
->setCommentActionLabel(pht('Change Subscribers'))
->setCommentActionOrder(9000)
->setDescription(pht('Choose subscribers.'))
->setTransactionType($subscribers_type)
->setValue($sub_phids);

View file

@ -6,6 +6,7 @@ abstract class PhabricatorEditEngineCommentAction extends Phobject {
private $label;
private $value;
private $initialValue;
private $order;
abstract public function getPHUIXControlType();
abstract public function getPHUIXControlSpecification();
@ -37,6 +38,20 @@ abstract class PhabricatorEditEngineCommentAction extends Phobject {
return $this->value;
}
public function setOrder($order) {
$this->order = $order;
return $this;
}
public function getOrder() {
return $this->order;
}
public function getSortVector() {
return id(new PhutilSortVector())
->addInt($this->getOrder());
}
public function setInitialValue($initial_value) {
$this->initialValue = $initial_value;
return $this;

View file

@ -1382,6 +1382,8 @@ abstract class PhabricatorEditEngine
$comment_actions[$key] = $comment_action;
}
$comment_actions = msortv($comment_actions, 'getSortVector');
$view->setCommentActions($comment_actions);
return $view;

View file

@ -24,6 +24,7 @@ abstract class PhabricatorEditField extends Phobject {
private $commentActionLabel;
private $commentActionValue;
private $commentActionOrder = 1000;
private $hasCommentActionValue;
private $isLocked;
@ -243,6 +244,15 @@ abstract class PhabricatorEditField extends Phobject {
return $this->commentActionLabel;
}
public function setCommentActionOrder($order) {
$this->commentActionOrder = $order;
return $this;
}
public function getCommentActionOrder() {
return $this->commentActionOrder;
}
public function setCommentActionValue($comment_action_value) {
$this->hasCommentActionValue = true;
$this->commentActionValue = $comment_action_value;
@ -686,7 +696,8 @@ abstract class PhabricatorEditField extends Phobject {
$action
->setKey($this->getKey())
->setLabel($label)
->setValue($this->getValueForCommentAction($value));
->setValue($this->getValueForCommentAction($value))
->setOrder($this->getCommentActionOrder());
return $action;
}