prevent double click new issue/pull/comment button (#16157)

* prevent double click new issue/pull/comment button

when network is not good, these button maybe
double clicked, then more than one same issues
pulls or comments will be created. this pull
request will fix this bug.

Signed-off-by: a1012112796 <1012112796@qq.com>
tokarchuk/v1.17
a1012112796 3 years ago committed by GitHub
parent 0eac09e066
commit 672e5a752d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      templates/repo/issue/new_form.tmpl
  2. 4
      templates/repo/issue/view_content.tmpl
  3. 12
      web_src/js/features/common-global.js

@ -20,7 +20,7 @@
</div>
{{template "repo/issue/comment_tab" .}}
<div class="text right">
<button class="ui green button" tabindex="6">
<button class="ui green button loading-button" tabindex="6">
{{if .PageIsComparePull}}
{{.i18n.Tr "repo.pulls.create"}}
{{else}}

@ -121,7 +121,7 @@
</div>
{{end}}
{{end}}
<button class="ui green button" tabindex="5">
<button class="ui green button loading-button" tabindex="5">
{{.i18n.Tr "repo.issues.create_comment"}}
</button>
</div>
@ -172,7 +172,7 @@
</div>
{{end}}
{{end}}
<button class="ui green button" tabindex="5">
<button class="ui green button loading-button" tabindex="5">
{{.i18n.Tr "repo.issues.create_comment"}}
</button>
</div>

@ -142,6 +142,18 @@ export function initGlobalCommon() {
window.location = href;
}
});
// loading-button this logic used to prevent push one form more than one time
$(document).on('click', '.button.loading-button', function (e) {
const $btn = $(this);
if ($btn.hasClass('loading')) {
e.preventDefault();
return false;
}
$btn.addClass('loading disabled');
});
}
export function initGlobalDropzone() {

Loading…
Cancel
Save