3 final class PhabricatorProjectTriggerManiphestPriorityRule
4 extends PhabricatorProjectTriggerRule
{
6 const TRIGGERTYPE
= 'task.priority';
8 public function getSelectControlName() {
9 return pht('Change priority to');
12 protected function assertValidRuleRecordFormat($value) {
13 if (!is_string($value)) {
16 'Priority rule value should be a string, but is not (value is "%s").',
17 phutil_describe_type($value)));
21 protected function assertValidRuleRecordValue($value) {
22 $map = ManiphestTaskPriority
::getTaskPriorityMap();
23 if (!isset($map[$value])) {
26 'Task priority value ("%s") is not a valid task priority. '.
27 'Valid priorities are: %s.',
29 implode(', ', array_keys($map))));
33 protected function newDropTransactions($object, $value) {
34 $value = ManiphestTaskPriority
::getKeywordForTaskPriority($value);
36 $this->newTransaction()
37 ->setTransactionType(ManiphestTaskPriorityTransaction
::TRANSACTIONTYPE
)
38 ->setNewValue($value),
42 protected function newDropEffects($value) {
43 $priority_name = ManiphestTaskPriority
::getTaskPriorityName($value);
44 $priority_icon = ManiphestTaskPriority
::getTaskPriorityIcon($value);
45 $priority_color = ManiphestTaskPriority
::getTaskPriorityColor($value);
48 'Change priority to %s.',
49 phutil_tag('strong', array(), $priority_name));
53 ->setIcon($priority_icon)
54 ->setColor($priority_color)
55 ->addCondition('priority', '!=', $value)
56 ->setContent($content),
60 protected function getDefaultValue() {
61 return ManiphestTaskPriority
::getDefaultPriority();
64 protected function getPHUIXControlType() {
68 protected function getPHUIXControlSpecification() {
69 $map = ManiphestTaskPriority
::getTaskPriorityMap();
73 'order' => array_keys($map),
77 public function getRuleViewLabel() {
78 return pht('Change Priority');
81 public function getRuleViewDescription($value) {
82 $priority_name = ManiphestTaskPriority
::getTaskPriorityName($value);
85 'Change task priority to %s.',
86 phutil_tag('strong', array(), $priority_name));
89 public function getRuleViewIcon($value) {
90 $priority_icon = ManiphestTaskPriority
::getTaskPriorityIcon($value);
91 $priority_color = ManiphestTaskPriority
::getTaskPriorityColor($value);
93 return id(new PHUIIconView())
94 ->setIcon($priority_icon, $priority_color);