Skip to content

Add cancel action to ConfirmController #3160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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