diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -433,7 +433,7 @@ 'rsrc/js/application/transactions/behavior-show-older-transactions.js' => '600f440c', 'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => '2bdadf1a', 'rsrc/js/application/transactions/behavior-transaction-list.js' => '9cec214e', - 'rsrc/js/application/trigger/TriggerRule.js' => '1c60c3fc', + 'rsrc/js/application/trigger/TriggerRule.js' => '41b7b4f6', 'rsrc/js/application/trigger/TriggerRuleControl.js' => '5faf27b9', 'rsrc/js/application/trigger/TriggerRuleEditor.js' => 'b49fd60c', 'rsrc/js/application/trigger/TriggerRuleType.js' => '4feea7d3', @@ -894,7 +894,7 @@ 'syntax-default-css' => '055fc231', 'syntax-highlighting-css' => '4234f572', 'tokens-css' => 'ce5a50bd', - 'trigger-rule' => '1c60c3fc', + 'trigger-rule' => '41b7b4f6', 'trigger-rule-control' => '5faf27b9', 'trigger-rule-editor' => 'b49fd60c', 'trigger-rule-type' => '4feea7d3', diff --git a/src/applications/project/trigger/PhabricatorProjectTriggerManiphestPriorityRule.php b/src/applications/project/trigger/PhabricatorProjectTriggerManiphestPriorityRule.php --- a/src/applications/project/trigger/PhabricatorProjectTriggerManiphestPriorityRule.php +++ b/src/applications/project/trigger/PhabricatorProjectTriggerManiphestPriorityRule.php @@ -54,7 +54,7 @@ } protected function getDefaultValue() { - return head_key(ManiphestTaskPriority::getTaskPriorityMap()); + return ManiphestTaskPriority::getDefaultPriority(); } protected function getPHUIXControlType() { diff --git a/src/applications/project/trigger/PhabricatorProjectTriggerManiphestStatusRule.php b/src/applications/project/trigger/PhabricatorProjectTriggerManiphestStatusRule.php --- a/src/applications/project/trigger/PhabricatorProjectTriggerManiphestStatusRule.php +++ b/src/applications/project/trigger/PhabricatorProjectTriggerManiphestStatusRule.php @@ -53,7 +53,7 @@ } protected function getDefaultValue() { - return head_key(ManiphestTaskStatus::getTaskStatusMap()); + return ManiphestTaskStatus::getDefaultClosedStatus(); } protected function getPHUIXControlType() { diff --git a/webroot/rsrc/js/application/trigger/TriggerRule.js b/webroot/rsrc/js/application/trigger/TriggerRule.js --- a/webroot/rsrc/js/application/trigger/TriggerRule.js +++ b/webroot/rsrc/js/application/trigger/TriggerRule.js @@ -98,7 +98,24 @@ }, _onTypeChange: function(control) { - this.setType(control.value); + var new_type = control.value; + + this.setType(new_type); + + // Before we build a new control, change the rule value to be appropriate + // for the new rule type. + + // TODO: Currently, we set the rule value to the default value for the + // type. This works most of the time, but if the user selects type "A", + // makes a change to the value, selects type "B", then changes back to + // type "A", it would be better to retain their edit. This is currently + // difficult because of tokenizers: if you save their value, you get a + // list of PHIDs which do not restore cleanly into tokens later. + + var editor = this.getEditor(); + var type = editor.getType(new_type); + this.setValue(type.getDefaultValue()); + this._rebuildValueControl(); },