mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Support tokenizer custom fields in bulk editor
Summary: Ref T13025. This allows custom tokenizer fields, like a "Owning Group" field, to be edited with the bulk editor. See PHI173 for some context. Test Plan: Edited a custom "Owner" field (a project tokenizer) with the bulk editor. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13025 Differential Revision: https://secure.phabricator.com/D18877
This commit is contained in:
parent
a26cf20dd1
commit
b6737554e1
3 changed files with 56 additions and 8 deletions
|
@ -6,6 +6,7 @@ final class PhabricatorCustomFieldEditField
|
|||
private $customField;
|
||||
private $httpParameterType;
|
||||
private $conduitParameterType;
|
||||
private $bulkParameterType;
|
||||
|
||||
public function setCustomField(PhabricatorCustomField $custom_field) {
|
||||
$this->customField = $custom_field;
|
||||
|
@ -36,6 +37,16 @@ final class PhabricatorCustomFieldEditField
|
|||
return $this->conduitParameterType;
|
||||
}
|
||||
|
||||
public function setCustomFieldBulkParameterType(
|
||||
BulkParameterType $type) {
|
||||
$this->bulkParameterType = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCustomFieldBulkParameterType() {
|
||||
return $this->bulkParameterType;
|
||||
}
|
||||
|
||||
protected function buildControl() {
|
||||
if ($this->getIsConduitOnly()) {
|
||||
return null;
|
||||
|
@ -51,15 +62,8 @@ final class PhabricatorCustomFieldEditField
|
|||
}
|
||||
|
||||
protected function newEditType() {
|
||||
$type = id(new PhabricatorCustomFieldEditType())
|
||||
return id(new PhabricatorCustomFieldEditType())
|
||||
->setCustomField($this->getCustomField());
|
||||
|
||||
$conduit_type = $this->newConduitParameterType();
|
||||
if ($conduit_type) {
|
||||
$type->setConduitParameterType($conduit_type);
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
public function getValueForTransaction() {
|
||||
|
@ -116,6 +120,16 @@ final class PhabricatorCustomFieldEditField
|
|||
return null;
|
||||
}
|
||||
|
||||
protected function newBulkParameterType() {
|
||||
$type = $this->getCustomFieldBulkParameterType();
|
||||
|
||||
if ($type) {
|
||||
return clone $type;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAllReadValueFromRequestKeys() {
|
||||
$keys = array();
|
||||
|
||||
|
|
|
@ -1119,6 +1119,11 @@ abstract class PhabricatorCustomField extends Phobject {
|
|||
$field->setCustomFieldConduitParameterType($conduit_type);
|
||||
}
|
||||
|
||||
$bulk_type = $this->getBulkParameterType();
|
||||
if ($bulk_type) {
|
||||
$field->setCustomFieldBulkParameterType($bulk_type);
|
||||
}
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
@ -1133,16 +1138,38 @@ abstract class PhabricatorCustomField extends Phobject {
|
|||
$conduit_only = false;
|
||||
}
|
||||
|
||||
$bulk_label = $this->getBulkEditLabel();
|
||||
|
||||
return $this->newEditField()
|
||||
->setKey($this->getFieldKey())
|
||||
->setEditTypeKey($this->getModernFieldKey())
|
||||
->setLabel($this->getFieldName())
|
||||
->setBulkEditLabel($bulk_label)
|
||||
->setDescription($this->getFieldDescription())
|
||||
->setTransactionType($this->getApplicationTransactionType())
|
||||
->setIsConduitOnly($conduit_only)
|
||||
->setValue($this->getNewValueForApplicationTransactions());
|
||||
}
|
||||
|
||||
protected function getBulkEditLabel() {
|
||||
if ($this->proxy) {
|
||||
return $this->proxy->getBulkEditLabel();
|
||||
}
|
||||
|
||||
return pht('Set "%s" to', $this->getFieldName());
|
||||
}
|
||||
|
||||
public function getBulkParameterType() {
|
||||
return $this->newBulkParameterType();
|
||||
}
|
||||
|
||||
protected function newBulkParameterType() {
|
||||
if ($this->proxy) {
|
||||
return $this->proxy->newBulkParameterType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getHTTPParameterType() {
|
||||
if ($this->proxy) {
|
||||
return $this->proxy->getHTTPParameterType();
|
||||
|
|
|
@ -65,6 +65,13 @@ abstract class PhabricatorStandardCustomFieldTokenizer
|
|||
return new ConduitPHIDListParameterType();
|
||||
}
|
||||
|
||||
protected function newBulkParameterType() {
|
||||
$datasource = $this->getDatasource();
|
||||
|
||||
return id(new BulkTokenizerParameterType())
|
||||
->setDatasource($datasource);
|
||||
}
|
||||
|
||||
public function shouldAppearInHeraldActions() {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue