mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Make "Order By" field render correctly when showing a SavedQuery with an order alias
Summary: If you have a saved query with an order alias, we currently apply the order correctly but don't show the right value in the UI. Map any saved value to the canoncial value when rendering the control. Test Plan: Added some `var_dump()` and verified order key was getting mapped forward correctly. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D13227
This commit is contained in:
parent
0fab38e022
commit
bdef1255e3
2 changed files with 21 additions and 0 deletions
|
@ -269,6 +269,7 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
|||
$fields[] = id(new PhabricatorSearchOrderField())
|
||||
->setLabel(pht('Order By'))
|
||||
->setKey('order')
|
||||
->setOrderAliases($query->getBuiltinOrderAliasMap())
|
||||
->setOptions($orders);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,16 @@ final class PhabricatorSearchOrderField
|
|||
extends PhabricatorSearchField {
|
||||
|
||||
private $options;
|
||||
private $orderAliases;
|
||||
|
||||
public function setOrderAliases(array $order_aliases) {
|
||||
$this->orderAliases = $order_aliases;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrderAliases() {
|
||||
return $this->orderAliases;
|
||||
}
|
||||
|
||||
public function setOptions(array $options) {
|
||||
$this->options = $options;
|
||||
|
@ -22,6 +32,16 @@ final class PhabricatorSearchOrderField
|
|||
return $request->getStr($key);
|
||||
}
|
||||
|
||||
protected function getValueForControl() {
|
||||
// If the SavedQuery has an alias for an order, map it to the canonical
|
||||
// name for the order so the correct option is selected in the dropdown.
|
||||
$value = parent::getValueForControl();
|
||||
if (isset($this->orderAliases[$value])) {
|
||||
$value = $this->orderAliases[$value];
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function newControl() {
|
||||
return id(new AphrontFormSelectControl())
|
||||
->setOptions($this->getOptions());
|
||||
|
|
Loading…
Reference in a new issue