1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Improve rendering of Herald rules in "Another Herald rule..." field

Summary:
Fixes T9136.

  - Fix a bug where the name is rendered improperly.
  - Put disabled rules at the bottom.
  - Always show the rule monogram so you can distingiush between rules with the same name.

Test Plan: {F6849915}

Maniphest Tasks: T9136

Differential Revision: https://secure.phabricator.com/D20798
This commit is contained in:
epriestley 2019-09-09 13:24:27 -07:00
parent 7593a265d5
commit 1d1a60fdda
2 changed files with 18 additions and 11 deletions

View file

@ -404,8 +404,8 @@ final class HeraldRuleController extends HeraldController {
HeraldAdapter $adapter) {
$all_rules = $this->loadRulesThisRuleMayDependUpon($rule);
$all_rules = mpull($all_rules, 'getName', 'getPHID');
asort($all_rules);
$all_rules = msortv($all_rules, 'getEditorSortVector');
$all_rules = mpull($all_rules, 'getEditorDisplayName', 'getPHID');
$all_fields = $adapter->getFieldNameMap();
$all_conditions = $adapter->getConditionNameMap();
@ -674,15 +674,6 @@ final class HeraldRuleController extends HeraldController {
->execute();
}
// mark disabled rules as disabled since they are not useful as such;
// don't filter though to keep edit cases sane / expected
foreach ($all_rules as $current_rule) {
if ($current_rule->getIsDisabled()) {
$current_rule->makeEphemeral();
$current_rule->setName($rule->getName().' '.pht('(Disabled)'));
}
}
// A rule can not depend upon itself.
unset($all_rules[$rule->getID()]);

View file

@ -259,6 +259,22 @@ final class HeraldRule extends HeraldDAO
return '/'.$this->getMonogram();
}
public function getEditorSortVector() {
return id(new PhutilSortVector())
->addInt($this->getIsDisabled() ? 1 : 0)
->addString($this->getName());
}
public function getEditorDisplayName() {
$name = pht('%s %s', $this->getMonogram(), $this->getName());
if ($this->getIsDisabled()) {
$name = pht('%s (Disabled)', $name);
}
return $name;
}
/* -( Repetition Policies )------------------------------------------------ */