diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php index ada1eef8d1..9f78e0c4b8 100644 --- a/src/applications/maniphest/editor/ManiphestEditEngine.php +++ b/src/applications/maniphest/editor/ManiphestEditEngine.php @@ -1,122 +1,114 @@ getViewer()); } protected function newObjectQuery() { return id(new ManiphestTaskQuery()); } protected function getObjectCreateTitleText($object) { return pht('Create New Task'); } protected function getObjectEditTitleText($object) { return pht('Edit %s %s', $object->getMonogram(), $object->getTitle()); } protected function getObjectEditShortText($object) { return $object->getMonogram(); } protected function getObjectCreateShortText() { return pht('Create Task'); } protected function getCommentViewHeaderText($object) { $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); if (!$is_serious) { return pht('Weigh In'); } return parent::getCommentViewHeaderText($object); } protected function getObjectViewURI($object) { return '/'.$object->getMonogram(); } protected function buildCustomEditFields($object) { // See T4819. $status_map = ManiphestTaskStatus::getTaskStatusMap(); $dup_status = ManiphestTaskStatus::getDuplicateStatus(); if ($object->getStatus() != $dup_status) { 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. // - Don't let users change a task status to "Duplicate". // - When closing an unassigned task, assign the closing user. // - Make sure implicit CCs on actions are working reasonably. return array( id(new PhabricatorTextEditField()) ->setKey('title') ->setLabel(pht('Title')) ->setDescription(pht('Name of the task.')) ->setTransactionType(ManiphestTransaction::TYPE_TITLE) ->setIsRequired(true) ->setValue($object->getTitle()), id(new PhabricatorSelectEditField()) ->setKey('status') ->setLabel(pht('Status')) ->setDescription(pht('Status of the task.')) ->setTransactionType(ManiphestTransaction::TYPE_STATUS) ->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')) ->setDescription(pht('Priority of the task.')) ->setTransactionType(ManiphestTransaction::TYPE_PRIORITY) ->setValue($object->getPriority()) ->setOptions($priority_map), id(new PhabricatorRemarkupEditField()) ->setKey('description') ->setLabel(pht('Description')) ->setDescription(pht('Task description.')) ->setTransactionType(ManiphestTransaction::TYPE_DESCRIPTION) ->setValue($object->getDescription()), ); } protected function getEditorURI() { // TODO: Remove when cutting over. return $this->getApplication()->getApplicationURI('editpro/'); } } diff --git a/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php b/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php index b1ce19a1e0..85e0dc8fb1 100644 --- a/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php +++ b/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php @@ -1,114 +1,144 @@ useEdgeTransactions = $use_edge_transactions; return $this; } public function getUseEdgeTransactions() { return $this->useEdgeTransactions; } public function setEdgeTransactionDescriptions($add, $rem, $set) { $this->transactionDescriptions = array( '+' => $add, '-' => $rem, '=' => $set, ); 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(); } public function getValueForTransaction() { $new = parent::getValueForTransaction(); + if ($this->getIsSingleValue()) { + if ($new) { + return head($new); + } else { + return null; + } + } + if (!$this->getUseEdgeTransactions()) { return $new; } $old = $this->getInitialValue(); if ($old === null) { return array( '=' => array_fuse($new), ); } // If we're building an edge transaction and the request has data about the // original value the user saw when they loaded the form, interpret the // edit as a mixture of "+" and "-" operations instead of a single "=" // operation. This limits our exposure to race conditions by making most // concurrent edits merge correctly. $add = array_diff($new, $old); $rem = array_diff($old, $new); $value = array(); if ($add) { $value['+'] = array_fuse($add); } if ($rem) { $value['-'] = array_fuse($rem); } return $value; } protected function newEditType() { if ($this->getUseEdgeTransactions()) { return new PhabricatorEdgeEditType(); } - return parent::newEditType(); + $type = parent::newEditType(); + + if ($this->getIsSingleValue()) { + $type->setValueType('phid'); + } + + return $type; } public function getConduitEditTypes() { if (!$this->getUseEdgeTransactions()) { return parent::getConduitEditTypes(); } $transaction_type = $this->getTransactionType(); if ($transaction_type === null) { return array(); } $type_key = $this->getEditTypeKey(); $strings = $this->transactionDescriptions; $base = $this->getEditType(); $add = id(clone $base) ->setEditType($type_key.'.add') ->setEdgeOperation('+') ->setDescription(idx($strings, '+')) ->setValueDescription(pht('List of PHIDs to add.')); $rem = id(clone $base) ->setEditType($type_key.'.remove') ->setEdgeOperation('-') ->setDescription(idx($strings, '-')) ->setValueDescription(pht('List of PHIDs to remove.')); $set = id(clone $base) ->setEditType($type_key.'.set') ->setEdgeOperation('=') ->setDescription(idx($strings, '=')) ->setValueDescription(pht('List of PHIDs to set.')); return array( $add, $rem, $set, ); } } diff --git a/src/applications/transactions/editfield/PhabricatorTokenizerEditField.php b/src/applications/transactions/editfield/PhabricatorTokenizerEditField.php index 3fe45fc5b6..0ac5ba5083 100644 --- a/src/applications/transactions/editfield/PhabricatorTokenizerEditField.php +++ b/src/applications/transactions/editfield/PhabricatorTokenizerEditField.php @@ -1,73 +1,77 @@ commentActionLabel = $label; return $this; } public function getCommentActionLabel() { return $this->commentActionLabel; } protected function newControl() { $control = id(new AphrontFormTokenizerControl()) ->setDatasource($this->newDatasource()); $initial_value = $this->getInitialValue(); if ($initial_value !== null) { $control->setOriginalValue($initial_value); } + if ($this->getIsSingleValue()) { + $control->setLimit(1); + } + return $control; } protected function getInitialValueFromSubmit(AphrontRequest $request, $key) { return $request->getArr($key.'.original'); } protected function newEditType() { $type = parent::newEditType(); if ($this->getUseEdgeTransactions()) { $datasource = $this->newDatasource() ->setViewer($this->getViewer()); $type->setDatasource($datasource); } return $type; } public function getCommentEditTypes() { if (!$this->getUseEdgeTransactions()) { return parent::getCommentEditTypes(); } $transaction_type = $this->getTransactionType(); if ($transaction_type === null) { return array(); } $label = $this->getCommentActionLabel(); if ($label === null) { return array(); } $type_key = $this->getEditTypeKey(); $base = $this->getEditType(); $add = id(clone $base) ->setEditType($type_key.'.add') ->setEdgeOperation('+') ->setLabel($label); return array($add); } }