mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +01:00
Support "Assign To" in Maniphest bulk editor
Summary: Ref T13025. See PHI173. This supports the "Assign to" field in the new editor. This is very slightly funky: to unassign tasks, you need to leave the field blank. I have half a diff to fix this, but the way the `none()` token works in the default datasource is odd so it needs a separate datasource. I'm punting on this for now since it works, at least, and isn't //completely// unreasonable. This also simplifies some EditEngine stuff a little. Notably: - I reorganized EditType construction slightly so subclasses can copy/paste a little bit less. - EditType had `field` and `editField` properties which had the same values. I canonicalized on `editField` and made this value set a little more automatically. Test Plan: Used bulk editor to reassign some tasks. By leaving the field blank, unassigned tasks. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13025 Differential Revision: https://secure.phabricator.com/D18874
This commit is contained in:
parent
0cad6021b6
commit
91a78db99b
8 changed files with 50 additions and 46 deletions
|
@ -189,6 +189,7 @@ EODOCS
|
|||
->setKey('owner')
|
||||
->setAliases(array('ownerPHID', 'assign', 'assigned'))
|
||||
->setLabel(pht('Assigned To'))
|
||||
->setBulkEditLabel(pht('Assign to'))
|
||||
->setDescription(pht('User who is responsible for the task.'))
|
||||
->setConduitDescription(pht('Reassign the task.'))
|
||||
->setConduitTypeDescription(
|
||||
|
|
|
@ -2219,7 +2219,6 @@ abstract class PhabricatorEditEngine
|
|||
}
|
||||
|
||||
foreach ($field_types as $field_type) {
|
||||
$field_type->setField($field);
|
||||
$types[$field_type->getEditType()] = $field_type;
|
||||
}
|
||||
}
|
||||
|
@ -2523,7 +2522,6 @@ abstract class PhabricatorEditEngine
|
|||
}
|
||||
|
||||
foreach ($field_types as $field_type) {
|
||||
$field_type->setField($field);
|
||||
$types[$field_type->getEditType()] = $field_type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -681,50 +681,49 @@ abstract class PhabricatorEditField extends Phobject {
|
|||
}
|
||||
|
||||
protected function newEditType() {
|
||||
$parameter_type = $this->getConduitParameterType();
|
||||
if (!$parameter_type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$edit_type = id(new PhabricatorSimpleEditType())
|
||||
->setConduitParameterType($parameter_type);
|
||||
|
||||
$bulk_type = $this->getBulkParameterType();
|
||||
if ($bulk_type) {
|
||||
$edit_type->setBulkParameterType($bulk_type);
|
||||
}
|
||||
|
||||
return $edit_type;
|
||||
return new PhabricatorSimpleEditType();
|
||||
}
|
||||
|
||||
protected function getEditType() {
|
||||
$transaction_type = $this->getTransactionType();
|
||||
|
||||
if ($transaction_type === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$type_key = $this->getEditTypeKey();
|
||||
$edit_type = $this->newEditType();
|
||||
if (!$edit_type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $edit_type
|
||||
->setEditType($type_key)
|
||||
$type_key = $this->getEditTypeKey();
|
||||
|
||||
$edit_type
|
||||
->setEditField($this)
|
||||
->setTransactionType($transaction_type)
|
||||
->setEditType($type_key)
|
||||
->setMetadata($this->getMetadata());
|
||||
|
||||
if (!$edit_type->getConduitParameterType()) {
|
||||
$conduit_parameter = $this->getConduitParameterType();
|
||||
if ($conduit_parameter) {
|
||||
$edit_type->setConduitParameterType($conduit_parameter);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$edit_type->getBulkParameterType()) {
|
||||
$bulk_parameter = $this->getBulkParameterType();
|
||||
if ($bulk_parameter) {
|
||||
$edit_type->setBulkParameterType($bulk_parameter);
|
||||
}
|
||||
}
|
||||
|
||||
return $edit_type;
|
||||
}
|
||||
|
||||
final public function getConduitEditTypes() {
|
||||
if ($this->conduitEditTypes === null) {
|
||||
$edit_types = $this->newConduitEditTypes();
|
||||
$edit_types = mpull($edit_types, null, 'getEditType');
|
||||
|
||||
foreach ($edit_types as $edit_type) {
|
||||
$edit_type->setEditField($this);
|
||||
}
|
||||
|
||||
$this->conduitEditTypes = $edit_types;
|
||||
}
|
||||
|
||||
|
@ -758,11 +757,6 @@ abstract class PhabricatorEditField extends Phobject {
|
|||
if ($this->bulkEditTypes === null) {
|
||||
$edit_types = $this->newBulkEditTypes();
|
||||
$edit_types = mpull($edit_types, null, 'getEditType');
|
||||
|
||||
foreach ($edit_types as $edit_type) {
|
||||
$edit_type->setEditField($this);
|
||||
}
|
||||
|
||||
$this->bulkEditTypes = $edit_types;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,10 +98,8 @@ abstract class PhabricatorPHIDListEditField
|
|||
return new PhabricatorEdgeEditType();
|
||||
}
|
||||
|
||||
$type = new PhabricatorDatasourceEditType();
|
||||
$type->setIsSingleValue($this->getIsSingleValue());
|
||||
$type->setConduitParameterType($this->newConduitParameterType());
|
||||
return $type;
|
||||
return id(new PhabricatorDatasourceEditType())
|
||||
->setIsSingleValue($this->getIsSingleValue());
|
||||
}
|
||||
|
||||
protected function newBulkEditTypes() {
|
||||
|
|
|
@ -56,4 +56,12 @@ abstract class PhabricatorTokenizerEditField
|
|||
return $action;
|
||||
}
|
||||
|
||||
protected function newBulkParameterType() {
|
||||
$datasource = $this->newDatasource()
|
||||
->setViewer($this->getViewer());
|
||||
|
||||
return id(new BulkTokenizerParameterType())
|
||||
->setDatasource($datasource);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,4 +19,20 @@ final class PhabricatorDatasourceEditType
|
|||
return '?';
|
||||
}
|
||||
|
||||
public function newRawBulkTransaction(array $xaction) {
|
||||
$value = idx($xaction, 'value');
|
||||
|
||||
if ($this->getIsSingleValue()) {
|
||||
if ($value) {
|
||||
$value = head($value);
|
||||
} else {
|
||||
$value = null;
|
||||
}
|
||||
|
||||
$xaction['value'] = $value;
|
||||
}
|
||||
|
||||
return $xaction;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ final class PhabricatorEdgeEditType
|
|||
->setDatasource($this->getDatasource());
|
||||
}
|
||||
|
||||
|
||||
public function newRawBulkTransaction(array $xaction) {
|
||||
$value = idx($xaction, 'value');
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ abstract class PhabricatorEditType extends Phobject {
|
|||
private $editField;
|
||||
private $transactionType;
|
||||
private $label;
|
||||
private $field;
|
||||
private $metadata = array();
|
||||
|
||||
private $conduitDescription;
|
||||
|
@ -36,16 +35,7 @@ abstract class PhabricatorEditType extends Phobject {
|
|||
return $this->bulkEditLabel;
|
||||
}
|
||||
|
||||
return $this->getField()->getBulkEditLabel();
|
||||
}
|
||||
|
||||
public function setField(PhabricatorEditField $field) {
|
||||
$this->field = $field;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getField() {
|
||||
return $this->field;
|
||||
return $this->getEditField()->getBulkEditLabel();
|
||||
}
|
||||
|
||||
public function setEditType($edit_type) {
|
||||
|
|
Loading…
Reference in a new issue