1
0
Fork 0
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:
epriestley 2018-01-19 05:42:54 -08:00
parent a26cf20dd1
commit b6737554e1
3 changed files with 56 additions and 8 deletions

View file

@ -6,6 +6,7 @@ final class PhabricatorCustomFieldEditField
private $customField; private $customField;
private $httpParameterType; private $httpParameterType;
private $conduitParameterType; private $conduitParameterType;
private $bulkParameterType;
public function setCustomField(PhabricatorCustomField $custom_field) { public function setCustomField(PhabricatorCustomField $custom_field) {
$this->customField = $custom_field; $this->customField = $custom_field;
@ -36,6 +37,16 @@ final class PhabricatorCustomFieldEditField
return $this->conduitParameterType; return $this->conduitParameterType;
} }
public function setCustomFieldBulkParameterType(
BulkParameterType $type) {
$this->bulkParameterType = $type;
return $this;
}
public function getCustomFieldBulkParameterType() {
return $this->bulkParameterType;
}
protected function buildControl() { protected function buildControl() {
if ($this->getIsConduitOnly()) { if ($this->getIsConduitOnly()) {
return null; return null;
@ -51,15 +62,8 @@ final class PhabricatorCustomFieldEditField
} }
protected function newEditType() { protected function newEditType() {
$type = id(new PhabricatorCustomFieldEditType()) return id(new PhabricatorCustomFieldEditType())
->setCustomField($this->getCustomField()); ->setCustomField($this->getCustomField());
$conduit_type = $this->newConduitParameterType();
if ($conduit_type) {
$type->setConduitParameterType($conduit_type);
}
return $type;
} }
public function getValueForTransaction() { public function getValueForTransaction() {
@ -116,6 +120,16 @@ final class PhabricatorCustomFieldEditField
return null; return null;
} }
protected function newBulkParameterType() {
$type = $this->getCustomFieldBulkParameterType();
if ($type) {
return clone $type;
}
return null;
}
public function getAllReadValueFromRequestKeys() { public function getAllReadValueFromRequestKeys() {
$keys = array(); $keys = array();

View file

@ -1119,6 +1119,11 @@ abstract class PhabricatorCustomField extends Phobject {
$field->setCustomFieldConduitParameterType($conduit_type); $field->setCustomFieldConduitParameterType($conduit_type);
} }
$bulk_type = $this->getBulkParameterType();
if ($bulk_type) {
$field->setCustomFieldBulkParameterType($bulk_type);
}
return $field; return $field;
} }
@ -1133,16 +1138,38 @@ abstract class PhabricatorCustomField extends Phobject {
$conduit_only = false; $conduit_only = false;
} }
$bulk_label = $this->getBulkEditLabel();
return $this->newEditField() return $this->newEditField()
->setKey($this->getFieldKey()) ->setKey($this->getFieldKey())
->setEditTypeKey($this->getModernFieldKey()) ->setEditTypeKey($this->getModernFieldKey())
->setLabel($this->getFieldName()) ->setLabel($this->getFieldName())
->setBulkEditLabel($bulk_label)
->setDescription($this->getFieldDescription()) ->setDescription($this->getFieldDescription())
->setTransactionType($this->getApplicationTransactionType()) ->setTransactionType($this->getApplicationTransactionType())
->setIsConduitOnly($conduit_only) ->setIsConduitOnly($conduit_only)
->setValue($this->getNewValueForApplicationTransactions()); ->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() { protected function getHTTPParameterType() {
if ($this->proxy) { if ($this->proxy) {
return $this->proxy->getHTTPParameterType(); return $this->proxy->getHTTPParameterType();

View file

@ -65,6 +65,13 @@ abstract class PhabricatorStandardCustomFieldTokenizer
return new ConduitPHIDListParameterType(); return new ConduitPHIDListParameterType();
} }
protected function newBulkParameterType() {
$datasource = $this->getDatasource();
return id(new BulkTokenizerParameterType())
->setDatasource($datasource);
}
public function shouldAppearInHeraldActions() { public function shouldAppearInHeraldActions() {
return true; return true;
} }