Skip to content

Commit

Permalink
Add cancel action to ConfirmController (#3160)
Browse files Browse the repository at this point in the history
* Clean input value
  • Loading branch information
Manuel Sanchez authored and di committed Mar 7, 2018
1 parent 3ebb445 commit bc48e99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export default class extends Controller {
this.buttonTarget.disabled = true;
}

cancel() {
this.inputTarget.value = "";
}

check() {
if (this.inputTarget.value == this.buttonTarget.dataset.expected) {
this.buttonTarget.disabled = false;
Expand Down
4 changes: 2 additions & 2 deletions warehouse/templates/manage/manage_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h3 class="sidebar-section__title">Your Account</h3>
<form method="POST" class="modal__form" action="{{ action or request.current_route_path() }}">
<input name="csrf_token" type="hidden" value="{{ request.session.get_csrf_token() }}">
{{ extra_fields if extra_fields else '' }}
<a href="#modal-close" title="Close" class="modal__close">
<a href="#modal-close" data-action="click->confirm#cancel" title="Close" class="modal__close">
<i class="fa fa-times" aria-hidden="true"></i>
<span class="sr-only">close</span>
</a>
Expand All @@ -79,7 +79,7 @@ <h3 class="modal__title">{{ title }} {{ confirm_string }}?</h3>
<input name="{{ name }}" data-action="input->confirm#check" data-target="confirm.input" type="text" placeholder="{{ confirm_string }}" autocomplete="off" autocorrect="off" autocapitalize="off">
</div>
<div class="modal__footer">
<a href="#modal-close" class="button modal__action">Cancel</a>
<a href="#modal-close" data-action="click->confirm#cancel" class="button modal__action">Cancel</a>
<button class="button button--primary modal__action" data-target="confirm.button" data-expected="{{ confirm_string }}" type="submit">
{{ title }}
</button>
Expand Down

0 comments on commit bc48e99

Please sign in to comment.