@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Mostly make the editor UI for triggers work

Summary:
Ref T5474. This provides a Herald-like UI for editing workboard trigger rules.

This probably has some missing pieces and doesn't actually save anything to the database yet, but the basics at least roughly work.

Test Plan: {F6299886}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T5474

Differential Revision: https://secure.phabricator.com/D20301

+682 -1
+28
resources/celerity/map.php
··· 100 100 'rsrc/css/application/policy/policy.css' => 'ceb56a08', 101 101 'rsrc/css/application/ponder/ponder-view.css' => '05a09d0a', 102 102 'rsrc/css/application/project/project-card-view.css' => '3b1f7b20', 103 + 'rsrc/css/application/project/project-triggers.css' => 'cb866c2d', 103 104 'rsrc/css/application/project/project-view.css' => '567858b3', 104 105 'rsrc/css/application/releeph/releeph-core.css' => 'f81ff2db', 105 106 'rsrc/css/application/releeph/releeph-preview-branch.css' => '22db5c07', ··· 432 433 'rsrc/js/application/transactions/behavior-show-older-transactions.js' => '600f440c', 433 434 'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => '2bdadf1a', 434 435 'rsrc/js/application/transactions/behavior-transaction-list.js' => '9cec214e', 436 + 'rsrc/js/application/trigger/TriggerRule.js' => 'e4a816a4', 437 + 'rsrc/js/application/trigger/TriggerRuleControl.js' => '5faf27b9', 438 + 'rsrc/js/application/trigger/TriggerRuleEditor.js' => 'b49fd60c', 439 + 'rsrc/js/application/trigger/TriggerRuleType.js' => '4feea7d3', 440 + 'rsrc/js/application/trigger/trigger-rule-editor.js' => '398fdf13', 435 441 'rsrc/js/application/typeahead/behavior-typeahead-browse.js' => '70245195', 436 442 'rsrc/js/application/typeahead/behavior-typeahead-search.js' => '7b139193', 437 443 'rsrc/js/application/uiexample/gesture-example.js' => '242dedd0', ··· 683 689 'javelin-behavior-time-typeahead' => '5803b9e7', 684 690 'javelin-behavior-toggle-class' => 'f5c78ae3', 685 691 'javelin-behavior-toggle-widget' => '8f959ad0', 692 + 'javelin-behavior-trigger-rule-editor' => '398fdf13', 686 693 'javelin-behavior-typeahead-browse' => '70245195', 687 694 'javelin-behavior-typeahead-search' => '7b139193', 688 695 'javelin-behavior-user-menu' => '60cd9241', ··· 875 882 'policy-transaction-detail-css' => 'c02b8384', 876 883 'ponder-view-css' => '05a09d0a', 877 884 'project-card-view-css' => '3b1f7b20', 885 + 'project-triggers-css' => 'cb866c2d', 878 886 'project-view-css' => '567858b3', 879 887 'releeph-core' => 'f81ff2db', 880 888 'releeph-preview-branch' => '22db5c07', ··· 886 894 'syntax-default-css' => '055fc231', 887 895 'syntax-highlighting-css' => '4234f572', 888 896 'tokens-css' => 'ce5a50bd', 897 + 'trigger-rule' => 'e4a816a4', 898 + 'trigger-rule-control' => '5faf27b9', 899 + 'trigger-rule-editor' => 'b49fd60c', 900 + 'trigger-rule-type' => '4feea7d3', 889 901 'typeahead-browse-css' => 'b7ed02d2', 890 902 'unhandled-exception-css' => '9ecfc00d', 891 903 ), ··· 1217 1229 'javelin-install', 1218 1230 'javelin-dom', 1219 1231 ), 1232 + '398fdf13' => array( 1233 + 'javelin-behavior', 1234 + 'trigger-rule-editor', 1235 + 'trigger-rule', 1236 + 'trigger-rule-type', 1237 + ), 1220 1238 '3b4899b0' => array( 1221 1239 'javelin-behavior', 1222 1240 'phabricator-prefab', ··· 1347 1365 'javelin-sound', 1348 1366 'phabricator-notification', 1349 1367 ), 1368 + '4feea7d3' => array( 1369 + 'trigger-rule-control', 1370 + ), 1350 1371 '506aa3f4' => array( 1351 1372 'javelin-behavior', 1352 1373 'javelin-stratcom', ··· 1431 1452 'javelin-stratcom', 1432 1453 'javelin-dom', 1433 1454 'phuix-dropdown-menu', 1455 + ), 1456 + '5faf27b9' => array( 1457 + 'phuix-form-control-view', 1434 1458 ), 1435 1459 '600f440c' => array( 1436 1460 'javelin-behavior', ··· 1849 1873 ), 1850 1874 'b347a301' => array( 1851 1875 'javelin-behavior', 1876 + ), 1877 + 'b49fd60c' => array( 1878 + 'multirow-row-manager', 1879 + 'trigger-rule', 1852 1880 ), 1853 1881 'b517bfa0' => array( 1854 1882 'phui-oi-list-view-css',
+82 -1
src/applications/project/controller/trigger/PhabricatorProjectTriggerEditController.php
··· 65 65 $v_name = $request->getStr('name'); 66 66 $v_edit = $request->getStr('editPolicy'); 67 67 68 + $v_rules = $request->getStr('rules'); 69 + $v_rules = phutil_json_decode($v_rules); 70 + 68 71 $xactions = array(); 69 72 if (!$trigger->getID()) { 70 73 $xactions[] = $trigger->getApplicationTransactionTemplate() ··· 80 83 $xactions[] = $trigger->getApplicationTransactionTemplate() 81 84 ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) 82 85 ->setNewValue($v_edit); 86 + 87 + // TODO: Actually write the new rules to the database. 83 88 84 89 $editor = $trigger->getApplicationTransactionEditor() 85 90 ->setActor($viewer) ··· 133 138 $header = pht('New Trigger'); 134 139 } 135 140 141 + $form_id = celerity_generate_unique_node_id(); 142 + $table_id = celerity_generate_unique_node_id(); 143 + $create_id = celerity_generate_unique_node_id(); 144 + $input_id = celerity_generate_unique_node_id(); 145 + 136 146 $form = id(new AphrontFormView()) 137 - ->setViewer($viewer); 147 + ->setViewer($viewer) 148 + ->setID($form_id); 138 149 139 150 if ($column) { 140 151 $form->addHiddenInput('columnPHID', $column->getPHID()); ··· 161 172 ->setPolicies($policies) 162 173 ->setError($e_edit)); 163 174 175 + $form->appendChild( 176 + phutil_tag( 177 + 'input', 178 + array( 179 + 'type' => 'hidden', 180 + 'name' => 'rules', 181 + 'id' => $input_id, 182 + ))); 183 + 184 + $form->appendChild( 185 + id(new PHUIFormInsetView()) 186 + ->setTitle(pht('Rules')) 187 + ->setDescription( 188 + pht( 189 + 'When a card is dropped into a column which uses this trigger:')) 190 + ->setRightButton( 191 + javelin_tag( 192 + 'a', 193 + array( 194 + 'href' => '#', 195 + 'class' => 'button button-green', 196 + 'id' => $create_id, 197 + 'mustcapture' => true, 198 + ), 199 + pht('New Rule'))) 200 + ->setContent( 201 + javelin_tag( 202 + 'table', 203 + array( 204 + 'id' => $table_id, 205 + 'class' => 'trigger-rules-table', 206 + )))); 207 + 208 + $this->setupEditorBehavior( 209 + $trigger, 210 + $form_id, 211 + $table_id, 212 + $create_id, 213 + $input_id); 214 + 164 215 $form->appendControl( 165 216 id(new AphrontFormSubmitControl()) 166 217 ->setValue($submit) ··· 195 246 ->setTitle($title) 196 247 ->setCrumbs($crumbs) 197 248 ->appendChild($column_view); 249 + } 250 + 251 + private function setupEditorBehavior( 252 + PhabricatorProjectTrigger $trigger, 253 + $form_id, 254 + $table_id, 255 + $create_id, 256 + $input_id) { 257 + 258 + $rule_list = $trigger->getTriggerRules(); 259 + $rule_list = mpull($rule_list, 'toDictionary'); 260 + $rule_list = array_values($rule_list); 261 + 262 + $type_list = PhabricatorProjectTriggerRule::getAllTriggerRules(); 263 + $type_list = mpull($type_list, 'newTemplate'); 264 + $type_list = array_values($type_list); 265 + 266 + require_celerity_resource('project-triggers-css'); 267 + 268 + Javelin::initBehavior( 269 + 'trigger-rule-editor', 270 + array( 271 + 'formNodeID' => $form_id, 272 + 'tableNodeID' => $table_id, 273 + 'createNodeID' => $create_id, 274 + 'inputNodeID' => $input_id, 275 + 276 + 'rules' => $rule_list, 277 + 'types' => $type_list, 278 + )); 198 279 } 199 280 200 281 }
+36
src/applications/project/trigger/PhabricatorProjectTriggerInvalidRule.php
··· 11 11 $this->getRecord()->getType()); 12 12 } 13 13 14 + public function getSelectControlName() { 15 + return pht('(Invalid Rule)'); 16 + } 17 + 18 + protected function isSelectableRule() { 19 + return false; 20 + } 21 + 14 22 protected function assertValidRuleValue($value) { 15 23 return; 16 24 } ··· 21 29 22 30 protected function newDropEffects($value) { 23 31 return array(); 32 + } 33 + 34 + protected function isValidRule() { 35 + return false; 36 + } 37 + 38 + protected function newInvalidView() { 39 + return array( 40 + id(new PHUIIconView()) 41 + ->setIcon('fa-exclamation-triangle red'), 42 + ' ', 43 + pht( 44 + 'This is a trigger rule with a valid type ("%s") but an invalid '. 45 + 'value.', 46 + $this->getRecord()->getType()), 47 + ); 48 + } 49 + 50 + protected function getDefaultValue() { 51 + return null; 52 + } 53 + 54 + protected function getPHUIXControlType() { 55 + return null; 56 + } 57 + 58 + protected function getPHUIXControlSpecification() { 59 + return null; 24 60 } 25 61 26 62 }
+21
src/applications/project/trigger/PhabricatorProjectTriggerManiphestStatusRule.php
··· 13 13 ManiphestTaskStatus::getTaskStatusName($value)); 14 14 } 15 15 16 + public function getSelectControlName() { 17 + return pht('Change status to'); 18 + } 19 + 16 20 protected function assertValidRuleValue($value) { 17 21 if (!is_string($value)) { 18 22 throw new Exception( ··· 53 57 ->setColor($status_color) 54 58 ->addCondition('status', '!=', $value) 55 59 ->setContent($content), 60 + ); 61 + } 62 + 63 + protected function getDefaultValue() { 64 + return head_key(ManiphestTaskStatus::getTaskStatusMap()); 65 + } 66 + 67 + protected function getPHUIXControlType() { 68 + return 'select'; 69 + } 70 + 71 + protected function getPHUIXControlSpecification() { 72 + $map = ManiphestTaskStatus::getTaskStatusMap(); 73 + 74 + return array( 75 + 'options' => $map, 76 + 'order' => array_keys($map), 56 77 ); 57 78 } 58 79
+48
src/applications/project/trigger/PhabricatorProjectTriggerRule.php
··· 38 38 } 39 39 40 40 abstract public function getDescription(); 41 + abstract public function getSelectControlName(); 41 42 abstract protected function assertValidRuleValue($value); 42 43 abstract protected function newDropTransactions($object, $value); 43 44 abstract protected function newDropEffects($value); 45 + abstract protected function getDefaultValue(); 46 + abstract protected function getPHUIXControlType(); 47 + abstract protected function getPHUIXControlSpecification(); 48 + 49 + protected function isSelectableRule() { 50 + return true; 51 + } 52 + 53 + protected function isValidRule() { 54 + return true; 55 + } 56 + 57 + protected function newInvalidView() { 58 + return null; 59 + } 44 60 45 61 final public function getDropTransactions($object, $value) { 46 62 return $this->newDropTransactions($object, $value); ··· 94 110 final protected function newEffect() { 95 111 return new PhabricatorProjectDropEffect(); 96 112 } 113 + 114 + final public function toDictionary() { 115 + $record = $this->getRecord(); 116 + 117 + $is_valid = $this->isValidRule(); 118 + if (!$is_valid) { 119 + $invalid_view = hsprintf('%s', $this->newInvalidView()); 120 + } else { 121 + $invalid_view = null; 122 + } 123 + 124 + return array( 125 + 'type' => $record->getType(), 126 + 'value' => $record->getValue(), 127 + 'isValidRule' => $is_valid, 128 + 'invalidView' => $invalid_view, 129 + ); 130 + } 131 + 132 + final public function newTemplate() { 133 + return array( 134 + 'type' => $this->getTriggerType(), 135 + 'name' => $this->getSelectControlName(), 136 + 'selectable' => $this->isSelectableRule(), 137 + 'defaultValue' => $this->getDefaultValue(), 138 + 'control' => array( 139 + 'type' => $this->getPHUIXControlType(), 140 + 'specification' => $this->getPHUIXControlSpecification(), 141 + ), 142 + ); 143 + } 144 + 97 145 98 146 }
+35
src/applications/project/trigger/PhabricatorProjectTriggerUnknownRule.php
··· 11 11 $this->getRecord()->getType()); 12 12 } 13 13 14 + public function getSelectControlName() { 15 + return pht('(Unknown Rule)'); 16 + } 17 + 18 + protected function isSelectableRule() { 19 + return false; 20 + } 21 + 14 22 protected function assertValidRuleValue($value) { 15 23 return; 16 24 } ··· 21 29 22 30 protected function newDropEffects($value) { 23 31 return array(); 32 + } 33 + 34 + protected function isValidRule() { 35 + return false; 36 + } 37 + 38 + protected function newInvalidView() { 39 + return array( 40 + id(new PHUIIconView()) 41 + ->setIcon('fa-exclamation-triangle yellow'), 42 + ' ', 43 + pht( 44 + 'This is a trigger rule with a unknown type ("%s").', 45 + $this->getRecord()->getType()), 46 + ); 47 + } 48 + 49 + protected function getDefaultValue() { 50 + return null; 51 + } 52 + 53 + protected function getPHUIXControlType() { 54 + return null; 55 + } 56 + 57 + protected function getPHUIXControlSpecification() { 58 + return null; 24 59 } 25 60 26 61 }
+38
webroot/rsrc/css/application/project/project-triggers.css
··· 1 + /** 2 + * @provides project-triggers-css 3 + */ 4 + 5 + .trigger-rules-table { 6 + margin: 16px 0; 7 + border-collapse: separate; 8 + border-spacing: 0 4px; 9 + } 10 + 11 + .trigger-rules-table tr { 12 + background: {$bluebackground}; 13 + } 14 + 15 + .trigger-rules-table td { 16 + padding: 6px 4px; 17 + vertical-align: middle; 18 + } 19 + 20 + .trigger-rules-table td.type-cell { 21 + padding-left: 6px; 22 + } 23 + 24 + .trigger-rules-table td.remove-column { 25 + padding-right: 6px; 26 + } 27 + 28 + .trigger-rules-table td.invalid-cell { 29 + padding-left: 12px; 30 + } 31 + 32 + .trigger-rules-table td.invalid-cell .phui-icon-view { 33 + margin-right: 4px; 34 + } 35 + 36 + .trigger-rules-table td.value-cell { 37 + width: 100%; 38 + }
+140
webroot/rsrc/js/application/trigger/TriggerRule.js
··· 1 + /** 2 + * @provides trigger-rule 3 + * @javelin 4 + */ 5 + 6 + JX.install('TriggerRule', { 7 + 8 + construct: function() { 9 + }, 10 + 11 + properties: { 12 + rowID: null, 13 + type: null, 14 + value: null, 15 + editor: null, 16 + isValidRule: true, 17 + invalidView: null 18 + }, 19 + 20 + statics: { 21 + newFromDictionary: function(map) { 22 + return new JX.TriggerRule() 23 + .setType(map.type) 24 + .setValue(map.value) 25 + .setIsValidRule(map.isValidRule) 26 + .setInvalidView(map.invalidView); 27 + }, 28 + }, 29 + 30 + members: { 31 + _typeCell: null, 32 + _valueCell: null, 33 + _readValueCallback: null, 34 + 35 + newRowContent: function() { 36 + if (!this.getIsValidRule()) { 37 + var invalid_cell = JX.$N( 38 + 'td', 39 + { 40 + colSpan: 2, 41 + className: 'invalid-cell' 42 + }, 43 + JX.$H(this.getInvalidView())); 44 + 45 + return [invalid_cell]; 46 + } 47 + 48 + var type_cell = this._getTypeCell(); 49 + var value_cell = this._getValueCell(); 50 + 51 + 52 + this._rebuildValueControl(); 53 + 54 + return [type_cell, value_cell]; 55 + }, 56 + 57 + getValueForSubmit: function() { 58 + this._readValueFromControl(); 59 + 60 + return { 61 + type: this.getType(), 62 + value: this.getValue() 63 + }; 64 + }, 65 + 66 + _getTypeCell: function() { 67 + if (!this._typeCell) { 68 + var editor = this.getEditor(); 69 + var types = editor.getTypes(); 70 + 71 + var options = []; 72 + for (var ii = 0; ii < types.length; ii++) { 73 + var type = types[ii]; 74 + 75 + if (!type.getIsSelectable()) { 76 + continue; 77 + } 78 + 79 + options.push( 80 + JX.$N('option', {value: type.getType()}, type.getName())); 81 + } 82 + 83 + var control = JX.$N('select', {}, options); 84 + 85 + control.value = this.getType(); 86 + 87 + var on_change = JX.bind(this, this._onTypeChange); 88 + JX.DOM.listen(control, 'onchange', null, on_change); 89 + 90 + var attributes = { 91 + className: 'type-cell' 92 + }; 93 + 94 + this._typeCell = JX.$N('td', attributes, control); 95 + } 96 + 97 + return this._typeCell; 98 + }, 99 + 100 + _onTypeChange: function() { 101 + var control = this._getTypeCell(); 102 + this.setType(control.value); 103 + 104 + this._rebuildValueControl(); 105 + }, 106 + 107 + _getValueCell: function() { 108 + if (!this._valueCell) { 109 + var attributes = { 110 + className: 'value-cell' 111 + }; 112 + 113 + this._valueCell = JX.$N('td', attributes); 114 + } 115 + 116 + return this._valueCell; 117 + }, 118 + 119 + _rebuildValueControl: function() { 120 + var value_cell = this._getValueCell(); 121 + 122 + var editor = this.getEditor(); 123 + var type = editor.getType(this.getType()); 124 + var control = type.getControl(); 125 + 126 + var input = control.newInput(this); 127 + this._readValueCallback = input.get; 128 + 129 + JX.DOM.setContent(value_cell, input.node); 130 + }, 131 + 132 + _readValueFromControl: function() { 133 + if (this._readValueCallback) { 134 + this.setValue(this._readValueCallback()); 135 + } 136 + } 137 + 138 + } 139 + 140 + });
+40
webroot/rsrc/js/application/trigger/TriggerRuleControl.js
··· 1 + /** 2 + * @requires phuix-form-control-view 3 + * @provides trigger-rule-control 4 + * @javelin 5 + */ 6 + 7 + JX.install('TriggerRuleControl', { 8 + 9 + construct: function() { 10 + }, 11 + 12 + properties: { 13 + type: null, 14 + specification: null 15 + }, 16 + 17 + statics: { 18 + newFromDictionary: function(map) { 19 + return new JX.TriggerRuleControl() 20 + .setType(map.type) 21 + .setSpecification(map.specification); 22 + }, 23 + }, 24 + 25 + members: { 26 + newInput: function(rule) { 27 + var phuix = new JX.PHUIXFormControl() 28 + .setControl(this.getType(), this.getSpecification()); 29 + 30 + phuix.setValue(rule.getValue()); 31 + 32 + return { 33 + node: phuix.getRawInputNode(), 34 + get: JX.bind(phuix, phuix.getValue) 35 + }; 36 + } 37 + 38 + } 39 + 40 + });
+137
webroot/rsrc/js/application/trigger/TriggerRuleEditor.js
··· 1 + /** 2 + * @requires multirow-row-manager 3 + * trigger-rule 4 + * @provides trigger-rule-editor 5 + * @javelin 6 + */ 7 + 8 + JX.install('TriggerRuleEditor', { 9 + 10 + construct: function(form_node) { 11 + this._formNode = form_node; 12 + this._rules = []; 13 + this._types = []; 14 + }, 15 + 16 + members: { 17 + _formNode: null, 18 + _tableNode: null, 19 + _createButtonNode: null, 20 + _inputNode: null, 21 + _rowManager: null, 22 + _rules: null, 23 + _types: null, 24 + 25 + setTableNode: function(table) { 26 + this._tableNode = table; 27 + return this; 28 + }, 29 + 30 + setCreateButtonNode: function(button) { 31 + this._createButtonNode = button; 32 + return this; 33 + }, 34 + 35 + setInputNode: function(input) { 36 + this._inputNode = input; 37 + return this; 38 + }, 39 + 40 + start: function() { 41 + var on_submit = JX.bind(this, this._submitForm); 42 + JX.DOM.listen(this._formNode, 'submit', null, on_submit); 43 + 44 + var manager = new JX.MultirowRowManager(this._tableNode); 45 + this._rowManager = manager; 46 + 47 + var on_remove = JX.bind(this, this._rowRemoved); 48 + manager.listen('row-removed', on_remove); 49 + 50 + var create_button = this._createButtonNode; 51 + var on_create = JX.bind(this, this._createRow); 52 + JX.DOM.listen(create_button, 'click', null, on_create); 53 + }, 54 + 55 + _submitForm: function() { 56 + var values = []; 57 + for (var ii = 0; ii < this._rules.length; ii++) { 58 + var rule = this._rules[ii]; 59 + values.push(rule.getValueForSubmit()); 60 + } 61 + 62 + this._inputNode.value = JX.JSON.stringify(values); 63 + }, 64 + 65 + _createRow: function(e) { 66 + var rule = this.newRule(); 67 + this.addRule(rule); 68 + e.kill(); 69 + }, 70 + 71 + newRule: function() { 72 + // Create new rules with the first valid rule type. 73 + var types = this.getTypes(); 74 + var type; 75 + for (var ii = 0; ii < types.length; ii++) { 76 + type = types[ii]; 77 + if (!type.getIsSelectable()) { 78 + continue; 79 + } 80 + 81 + // If we make it here: this type is valid, so use it. 82 + break; 83 + } 84 + 85 + var default_value = type.getDefaultValue(); 86 + 87 + return new JX.TriggerRule() 88 + .setType(type.getType()) 89 + .setValue(default_value); 90 + }, 91 + 92 + addRule: function(rule) { 93 + rule.setEditor(this); 94 + this._rules.push(rule); 95 + 96 + var manager = this._rowManager; 97 + 98 + var row = manager.addRow([]); 99 + var row_id = manager.getRowID(row); 100 + rule.setRowID(row_id); 101 + 102 + manager.updateRow(row_id, rule.newRowContent()); 103 + }, 104 + 105 + addType: function(type) { 106 + this._types.push(type); 107 + return this; 108 + }, 109 + 110 + getTypes: function() { 111 + return this._types; 112 + }, 113 + 114 + getType: function(type) { 115 + for (var ii = 0; ii < this._types.length; ii++) { 116 + if (this._types[ii].getType() === type) { 117 + return this._types[ii]; 118 + } 119 + } 120 + 121 + return null; 122 + }, 123 + 124 + _rowRemoved: function(row_id) { 125 + for (var ii = 0; ii < this._rules.length; ii++) { 126 + var rule = this._rules[ii]; 127 + 128 + if (rule.getRowID() === row_id) { 129 + this._rules.splice(ii, 1); 130 + break; 131 + } 132 + } 133 + } 134 + 135 + } 136 + 137 + });
+36
webroot/rsrc/js/application/trigger/TriggerRuleType.js
··· 1 + /** 2 + * @requires trigger-rule-control 3 + * @provides trigger-rule-type 4 + * @javelin 5 + */ 6 + 7 + JX.install('TriggerRuleType', { 8 + 9 + construct: function() { 10 + }, 11 + 12 + properties: { 13 + type: null, 14 + name: null, 15 + isSelectable: true, 16 + defaultValue: null, 17 + control: null 18 + }, 19 + 20 + statics: { 21 + newFromDictionary: function(map) { 22 + var control = JX.TriggerRuleControl.newFromDictionary(map.control); 23 + 24 + return new JX.TriggerRuleType() 25 + .setType(map.type) 26 + .setName(map.name) 27 + .setIsSelectable(map.selectable) 28 + .setDefaultValue(map.defaultValue) 29 + .setControl(control); 30 + }, 31 + }, 32 + 33 + members: { 34 + } 35 + 36 + });
+41
webroot/rsrc/js/application/trigger/trigger-rule-editor.js
··· 1 + /** 2 + * @requires javelin-behavior 3 + * trigger-rule-editor 4 + * trigger-rule 5 + * trigger-rule-type 6 + * @provides javelin-behavior-trigger-rule-editor 7 + * @javelin 8 + */ 9 + 10 + JX.behavior('trigger-rule-editor', function(config) { 11 + var form_node = JX.$(config.formNodeID); 12 + var table_node = JX.$(config.tableNodeID); 13 + var create_node = JX.$(config.createNodeID); 14 + var input_node = JX.$(config.inputNodeID); 15 + 16 + var editor = new JX.TriggerRuleEditor(form_node) 17 + .setTableNode(table_node) 18 + .setCreateButtonNode(create_node) 19 + .setInputNode(input_node); 20 + 21 + editor.start(); 22 + 23 + var ii; 24 + 25 + for (ii = 0; ii < config.types.length; ii++) { 26 + var type = JX.TriggerRuleType.newFromDictionary(config.types[ii]); 27 + editor.addType(type); 28 + } 29 + 30 + if (config.rules.length) { 31 + for (ii = 0; ii < config.rules.length; ii++) { 32 + var rule = JX.TriggerRule.newFromDictionary(config.rules[ii]); 33 + editor.addRule(rule); 34 + } 35 + } else { 36 + // If the trigger doesn't have any rules yet, add an empty rule to start 37 + // with, so the user doesn't have to click "New Rule". 38 + editor.addRule(editor.newRule()); 39 + } 40 + 41 + });