1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

Limit number of EditEngine tokenizer tokens in "Owner" field UI to 1

Summary:
Ref T9132. Only allow a task to have a single owner in the UI.

In Conduit, make this field appear and behave as "phid" instead of "list<phid>".

Test Plan: Edited a task with new fancy form, got limited to one owner. Assigned/unassigned. Used Conduit to assign/unassign.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9132

Differential Revision: https://secure.phabricator.com/D14666
This commit is contained in:
epriestley 2015-12-04 07:21:50 -08:00
parent dd0b09a610
commit b3cf00333c
3 changed files with 38 additions and 12 deletions

View file

@ -58,17 +58,9 @@ final class ManiphestEditEngine
unset($status_map[$dup_status]);
}
$owner_phid = $object->getOwnerPHID();
if ($owner_phid) {
$owner_value = array($owner_phid);
} else {
$owner_value = array();
}
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
// TODO: Restore these or toss them:
// - Require a single owner.
// - Default owner to viewer.
// - Don't show "change status" for closed tasks.
// - Don't show "change owner" for closed tasks.
@ -92,12 +84,12 @@ final class ManiphestEditEngine
->setValue($object->getStatus())
->setOptions($status_map),
id(new PhabricatorUsersEditField())
->setKey('assigned')
->setAliases(array('assign', 'assignee'))
->setKey('owner')
->setAliases(array('ownerPHID', 'assign', 'assigned'))
->setLabel(pht('Assigned To'))
->setDescription(pht('User who is responsible for the task.'))
->setTransactionType(ManiphestTransaction::TYPE_OWNER)
->setValue($owner_value),
->setSingleValue($object->getOwnerPHID()),
id(new PhabricatorSelectEditField())
->setKey('priority')
->setLabel(pht('Priority'))

View file

@ -5,6 +5,7 @@ abstract class PhabricatorPHIDListEditField
private $useEdgeTransactions;
private $transactionDescriptions = array();
private $isSingleValue;
public function setUseEdgeTransactions($use_edge_transactions) {
$this->useEdgeTransactions = $use_edge_transactions;
@ -24,6 +25,21 @@ abstract class PhabricatorPHIDListEditField
return $this;
}
public function setSingleValue($value) {
if ($value === null) {
$value = array();
} else {
$value = array($value);
}
$this->isSingleValue = true;
return $this->setValue($value);
}
public function getIsSingleValue() {
return $this->isSingleValue;
}
protected function newHTTPParameterType() {
return new AphrontPHIDListHTTPParameterType();
}
@ -31,6 +47,14 @@ abstract class PhabricatorPHIDListEditField
public function getValueForTransaction() {
$new = parent::getValueForTransaction();
if ($this->getIsSingleValue()) {
if ($new) {
return head($new);
} else {
return null;
}
}
if (!$this->getUseEdgeTransactions()) {
return $new;
}
@ -68,7 +92,13 @@ abstract class PhabricatorPHIDListEditField
return new PhabricatorEdgeEditType();
}
return parent::newEditType();
$type = parent::newEditType();
if ($this->getIsSingleValue()) {
$type->setValueType('phid');
}
return $type;
}
public function getConduitEditTypes() {

View file

@ -25,6 +25,10 @@ abstract class PhabricatorTokenizerEditField
$control->setOriginalValue($initial_value);
}
if ($this->getIsSingleValue()) {
$control->setLimit(1);
}
return $control;
}