Add event handlers to RB.DialogView

Review Request #10967 — Created March 27, 2020 and submitted — Latest diff uploaded

Information

Review Board
release-3.0.x
2e812d3...

Reviewers

This patch adds event handlers to RB.DialogView for submit and
keydown. The form submit event handler fixes the bug where pressing
Enter on the upload file dialog (RB.UploadAttachmentView) would
cancel the file upload instead of actually uploading it. Pressing the
return key on RB.DialogView dialogs that have a completed form will
now submit the form instead of reloading the page and discarding
changes unless the form specifies an action explicitly. The keydown
event handler allows the dialog to be closed when the Escape key
is pressed.

Since RB.DialogView is a child of the modalBox, it needs to listen
to keydown events from the main box area and not from its own content
area so that it can handle events from within it. This means we can't
use the events map for the keydown event and have to bind an explicit
keydown event handler on .modalbox-inner.

New unit tests:
- triggering submit with primary button enabled triggers the button
- triggering submit with primary button disabled on a dialog does
nothing
- triggering submit with primary button enabled on a dialog with a
form does nothing
- triggering keydown using the Escape key hides the dialog

Manual testing:

File upload dialog:
- pressing Enter after opening the dialog and not filling out any
fields does nothing
- pressing Enter after uploading a file & editing the caption uploads
the file with the caption
- pressing Escape after opening the dialog hides the dialog

New review request dialog:
- pressing Escape after opening the dialog hides the dialog