1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-06 11:58:30 +01:00
phorge-phorge/src/applications/transactions/editfield/PhabricatorSelectEditField.php
epriestley bf1ac701c3 Support "select" types in bulk editor (status, priority)
Summary: Depends on D18864. Ref T13025. Adds bulk edit support back for "status" and "priority" using `<select />` controls.

Test Plan:
Used bulk editor to change status and priority for tasks.

{F5374436}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13025

Differential Revision: https://secure.phabricator.com/D18866
2018-01-19 12:44:48 -08:00

73 lines
1.7 KiB
PHP

<?php
final class PhabricatorSelectEditField
extends PhabricatorEditField {
private $options;
private $optionAliases = array();
public function setOptions(array $options) {
$this->options = $options;
return $this;
}
public function getOptions() {
if ($this->options === null) {
throw new PhutilInvalidStateException('setOptions');
}
return $this->options;
}
public function setOptionAliases(array $option_aliases) {
$this->optionAliases = $option_aliases;
return $this;
}
public function getOptionAliases() {
return $this->optionAliases;
}
protected function getDefaultValueFromConfiguration($value) {
return $this->getCanonicalValue($value);
}
protected function getValueForControl() {
$value = parent::getValueForControl();
return $this->getCanonicalValue($value);
}
protected function newControl() {
return id(new AphrontFormSelectControl())
->setOptions($this->getOptions());
}
protected function newHTTPParameterType() {
return new AphrontSelectHTTPParameterType();
}
protected function newCommentAction() {
return id(new PhabricatorEditEngineSelectCommentAction())
->setOptions($this->getOptions());
}
protected function newConduitParameterType() {
return new ConduitStringParameterType();
}
protected function newBulkParameterType() {
return new BulkSelectParameterType();
}
private function getCanonicalValue($value) {
$options = $this->getOptions();
if (!isset($options[$value])) {
$aliases = $this->getOptionAliases();
if (isset($aliases[$value])) {
$value = $aliases[$value];
}
}
return $value;
}
}