1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

Fix transaction comment bug

Summary: form.reset() resets a form to whatever values were present when the form was loaded into the DOM. Instead, grab all the pertinent form bits and set there values to "clear". I don't think there's too much utility in putting this somewhere more general, but it could be something like DOM.clearForm(form) or something. Fixes T3629.

Test Plan:
repro'd original issue

 - open legalpad doc (or your favorite application transaction powered app)
 - type in a comment but do not submit (you are creating a draft) e.g. "foo"
 - reload page and note comment appears e.g. "foo"
 - change comment e.g. "foobar"
 - submit comment
 - BUG - after submission, the comment reverts to the comment at initial page load e.g. "foo"

then after this patch, I can't repro it anymore with these steps - the comment is correctly blank

 NOTE: this will need to be tested with more complicated forms.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T3629

Differential Revision: https://secure.phabricator.com/D8220
This commit is contained in:
Bob Trahan 2014-02-13 15:10:20 -08:00
parent a4529b4e60
commit 5729bbc085
2 changed files with 41 additions and 12 deletions

View file

@ -406,7 +406,7 @@ return array(
'rsrc/js/application/search/behavior-reorder-queries.js' => '34397f68', 'rsrc/js/application/search/behavior-reorder-queries.js' => '34397f68',
'rsrc/js/application/slowvote/behavior-slowvote-embed.js' => 'a51fdb2e', 'rsrc/js/application/slowvote/behavior-slowvote-embed.js' => 'a51fdb2e',
'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => '9084a36f', 'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => '9084a36f',
'rsrc/js/application/transactions/behavior-transaction-list.js' => '0dcf1716', 'rsrc/js/application/transactions/behavior-transaction-list.js' => '5e3da3ad',
'rsrc/js/application/uiexample/JavelinViewExample.js' => 'd4a14807', 'rsrc/js/application/uiexample/JavelinViewExample.js' => 'd4a14807',
'rsrc/js/application/uiexample/ReactorButtonExample.js' => '44524435', 'rsrc/js/application/uiexample/ReactorButtonExample.js' => '44524435',
'rsrc/js/application/uiexample/ReactorCheckboxExample.js' => '7ba325ee', 'rsrc/js/application/uiexample/ReactorCheckboxExample.js' => '7ba325ee',
@ -599,7 +599,7 @@ return array(
'javelin-behavior-phabricator-search-typeahead' => 'f6b56f7a', 'javelin-behavior-phabricator-search-typeahead' => 'f6b56f7a',
'javelin-behavior-phabricator-tooltips' => 'e5dd1c6d', 'javelin-behavior-phabricator-tooltips' => 'e5dd1c6d',
'javelin-behavior-phabricator-transaction-comment-form' => '9084a36f', 'javelin-behavior-phabricator-transaction-comment-form' => '9084a36f',
'javelin-behavior-phabricator-transaction-list' => '0dcf1716', 'javelin-behavior-phabricator-transaction-list' => '5e3da3ad',
'javelin-behavior-phabricator-watch-anchor' => '06e05112', 'javelin-behavior-phabricator-watch-anchor' => '06e05112',
'javelin-behavior-phame-post-preview' => '61d927ec', 'javelin-behavior-phame-post-preview' => '61d927ec',
'javelin-behavior-pholio-mock-edit' => '1e1e8bb0', 'javelin-behavior-pholio-mock-edit' => '1e1e8bb0',
@ -850,14 +850,6 @@ return array(
1 => 'javelin-install', 1 => 'javelin-install',
2 => 'javelin-dom', 2 => 'javelin-dom',
), ),
'0dcf1716' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-stratcom',
2 => 'javelin-workflow',
3 => 'javelin-dom',
4 => 'javelin-fx',
),
'0e34ca02' => '0e34ca02' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
@ -1167,6 +1159,14 @@ return array(
3 => 'javelin-stratcom', 3 => 'javelin-stratcom',
4 => 'javelin-vector', 4 => 'javelin-vector',
), ),
'5e3da3ad' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-stratcom',
2 => 'javelin-workflow',
3 => 'javelin-dom',
4 => 'javelin-fx',
),
'5f004630' => '5f004630' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',

View file

@ -109,11 +109,40 @@ JX.behavior('phabricator-transaction-list', function(config) {
var e = JX.DOM.invoke(form, 'willClear'); var e = JX.DOM.invoke(form, 'willClear');
if (!e.getPrevented()) { if (!e.getPrevented()) {
form.reset(); var ii;
var textareas = JX.DOM.scry(form, 'textarea');
for (ii = 0; ii < textareas.length; ii++) {
textareas[ii].value = '';
}
var inputs = JX.DOM.scry(form, 'input');
for (ii = 0; ii < inputs.length; ii++) {
switch (inputs[ii].type) {
case 'password':
case 'text':
inputs[ii].value = '';
break;
case 'checkbox':
case 'radio':
inputs[ii].checked = false;
break;
}
}
var selects = JX.DOM.scry(form, 'select');
var jj;
for (ii = 0; ii < selects.length; ii++) {
if (selects[ii].type == 'select-one') {
selects[ii].selectedIndex = 0;
} else {
for (jj = 0; jj < selects[ii].options.length; jj++) {
selects[ii].options[jj].selected = false;
}
}
}
} }
}) })
.start(); .start();
}); });
}); });