Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/transactions/behavior-comment-actions.js
| Show All 37 Lines | for (var ii = 0; ii < options.length; ii++) { | ||||
| if (option.value == key) { | if (option.value == key) { | ||||
| return option; | return option; | ||||
| } | } | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| function redraw() { | |||||
| // If any of the stacked actions specify that they change the label for | |||||
| // the "Submit" button, update the button text. Otherwise, return it to | |||||
| // the default text. | |||||
| var button_text = config.defaultButtonText; | |||||
| for (var k in rows) { | |||||
| var action = action_map[k]; | |||||
| if (action.buttonText) { | |||||
| button_text = action.buttonText; | |||||
| } | |||||
| } | |||||
| var button_node = JX.DOM.find(form_node, 'button', 'submit-transactions'); | |||||
| JX.DOM.setContent(button_node, button_text); | |||||
| } | |||||
| function remove_action(key) { | function remove_action(key) { | ||||
| var row = rows[key]; | var row = rows[key]; | ||||
| if (row) { | if (row) { | ||||
| JX.DOM.remove(row.node); | JX.DOM.remove(row.node); | ||||
| row.option.disabled = false; | row.option.disabled = false; | ||||
| delete rows[key]; | delete rows[key]; | ||||
| } | } | ||||
| redraw(); | |||||
| } | } | ||||
| function serialize_actions() { | function serialize_actions() { | ||||
| var data = []; | var data = []; | ||||
| for (var k in rows) { | for (var k in rows) { | ||||
| data.push({ | data.push({ | ||||
| type: k, | type: k, | ||||
| Show All 24 Lines | for (var ii = 0; ii < drafts.length; ii++) { | ||||
| option = find_option(draft); | option = find_option(draft); | ||||
| if (!option) { | if (!option) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| control = add_row(option); | control = add_row(option); | ||||
| } | } | ||||
| redraw(); | |||||
| } | } | ||||
| function onresponse(response) { | function onresponse(response) { | ||||
| if (JX.Device.getDevice() != 'desktop') { | if (JX.Device.getDevice() != 'desktop') { | ||||
| return; | return; | ||||
| } | } | ||||
| var panel = JX.$(config.panelID); | var panel = JX.$(config.panelID); | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | function add_row(option) { | ||||
| JX.DOM.listen(remove, 'click', null, function(e) { | JX.DOM.listen(remove, 'click', null, function(e) { | ||||
| e.kill(); | e.kill(); | ||||
| remove_action(action.key); | remove_action(action.key); | ||||
| }); | }); | ||||
| place_node.parentNode.insertBefore(node, place_node); | place_node.parentNode.insertBefore(node, place_node); | ||||
| redraw(); | |||||
| force_preview(); | force_preview(); | ||||
| return control; | return control; | ||||
| } | } | ||||
| JX.DOM.listen(form_node, ['submit', 'didSyntheticSubmit'], null, function() { | JX.DOM.listen(form_node, ['submit', 'didSyntheticSubmit'], null, function() { | ||||
| input_node.value = serialize_actions(); | input_node.value = serialize_actions(); | ||||
| }); | }); | ||||
| ▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines | |||||