templates: switched most of confirm dialogs to sweetalert2
This commit is contained in:
parent
81cb00a1a9
commit
875bda9f88
14 changed files with 101 additions and 26 deletions
|
|
@ -246,7 +246,7 @@
|
|||
box-sizing: border-box;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
width: 32em;
|
||||
width: 38em;
|
||||
max-width: 100%;
|
||||
padding: 1.25em;
|
||||
border: none;
|
||||
|
|
|
|||
|
|
@ -594,7 +594,15 @@ var CommentsController = function() {
|
|||
showCancelButton: true,
|
||||
confirmButtonColor: '#84a5d2',
|
||||
cancelButtonColor: '#e85e4d',
|
||||
confirmButtonText: _gettext('Yes, delete comment #{0}!').format(comment_id)
|
||||
confirmButtonText: _gettext('Yes, delete comment #{0}!').format(comment_id),
|
||||
showClass: {
|
||||
popup: 'swal2-noanimation',
|
||||
backdrop: 'swal2-noanimation'
|
||||
},
|
||||
hideClass: {
|
||||
popup: '',
|
||||
backdrop: ''
|
||||
}
|
||||
}).then(function(result) {
|
||||
if (result.value) {
|
||||
self._deleteComment(node);
|
||||
|
|
|
|||
|
|
@ -120,4 +120,40 @@ function ajaxErrorSwal(message) {
|
|||
backdrop: ''
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
* use in onclick attributes e.g
|
||||
* onclick="submitConfirm(event, this, _gettext('Confirm to delete '), _gettext('Confirm Delete'), 'what we delete')">
|
||||
* */
|
||||
function submitConfirm(event, self, question, confirmText, htmlText) {
|
||||
if (htmlText === "undefined") {
|
||||
htmlText = null;
|
||||
}
|
||||
if (confirmText === "undefined") {
|
||||
confirmText = _gettext('Delete')
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
Swal.fire({
|
||||
title: question,
|
||||
icon: 'warning',
|
||||
html: htmlText,
|
||||
showClass: {
|
||||
popup: 'swal2-noanimation',
|
||||
backdrop: 'swal2-noanimation'
|
||||
},
|
||||
hideClass: {
|
||||
popup: '',
|
||||
backdrop: ''
|
||||
},
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#84a5d2',
|
||||
cancelButtonColor: '#e85e4d',
|
||||
confirmButtonText: confirmText
|
||||
}).then(function(result) {
|
||||
if (result.value) {
|
||||
$(self).closest("form").submit();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -54,7 +54,10 @@
|
|||
%if c.is_super_admin or c.gist.gist_owner == c.rhodecode_user.user_id:
|
||||
<div class="pull-right remove_gist">
|
||||
${h.secure_form(h.route_path('gist_delete', gist_id=c.gist.gist_access_id), request=request)}
|
||||
${h.submit('remove_gist', _('Delete'),class_="btn btn-mini btn-danger",onclick="return confirm('"+_('Confirm to delete this Gist')+"');")}
|
||||
<input class="btn btn-mini btn-danger" id="remove_gist" name="remove_gist"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this gist'), _gettext('Delete'), '${c.gist.gist_access_id}')"
|
||||
type="submit" value="${_('Delete')}"
|
||||
>
|
||||
${h.end_form()}
|
||||
</div>
|
||||
%endif
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@
|
|||
${h.secure_form(h.route_path('my_account_auth_tokens_delete'), request=request)}
|
||||
${h.hidden('del_auth_token', auth_token.user_api_key_id)}
|
||||
<button class="btn btn-link btn-danger" type="submit"
|
||||
onclick="return confirm('${_('Confirm to remove this auth token: %s') % auth_token.token_obfuscated}');">
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this auth token'), _gettext('Delete'), '${auth_token.token_obfuscated}')"
|
||||
>
|
||||
${_('Delete')}
|
||||
</button>
|
||||
${h.end_form()}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@
|
|||
${h.secure_form(h.route_path('my_account_emails_delete'), request=request)}
|
||||
${h.hidden('del_email_id',em.email_id)}
|
||||
<button class="btn btn-link btn-danger" type="submit" id="${'remove_email_%s'.format(em.email_id)}"
|
||||
onclick="return confirm('${_('Confirm to delete this email: {}').format(em.email)}');">
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this email'), _gettext('Delete'), '${em.email}')"
|
||||
>
|
||||
${_('Delete')}
|
||||
</button>
|
||||
${h.end_form()}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@
|
|||
${h.secure_form(h.route_path('my_account_ssh_keys_delete'), request=request)}
|
||||
${h.hidden('del_ssh_key', ssh_key.ssh_key_id)}
|
||||
<button class="btn btn-link btn-danger" type="submit"
|
||||
onclick="return confirm('${_('Confirm to remove ssh key %s') % ssh_key.ssh_key_fingerprint}');">
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this ssh key'), _gettext('Delete'), '${ssh_key.ssh_key_fingerprint}')"
|
||||
>
|
||||
${_('Delete')}
|
||||
</button>
|
||||
${h.end_form()}
|
||||
|
|
|
|||
|
|
@ -93,14 +93,16 @@
|
|||
%if c.rhodecode_db_repo.locked[0]:
|
||||
${h.hidden('set_unlock', '1')}
|
||||
<button class="btn btn-small" type="submit"
|
||||
onclick="return confirm('${_('Confirm to unlock repository.')}');">
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to unlock this repository'), _gettext('Unlock'), '${c.rhodecode_db_repo.repo_name}')"
|
||||
>
|
||||
<i class="icon-unlock"></i>
|
||||
${_('Unlock repository')}
|
||||
</button>
|
||||
%else:
|
||||
${h.hidden('set_lock', '1')}
|
||||
<button class="btn btn-small" type="submit"
|
||||
onclick="return confirm('${_('Confirm to lock repository.')}');">
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to lock this repository'), _gettext('lock'), '${c.rhodecode_db_repo.repo_name}')"
|
||||
>
|
||||
<i class="icon-lock"></i>
|
||||
${_('Lock repository')}
|
||||
</button>
|
||||
|
|
@ -166,7 +168,8 @@
|
|||
|
||||
<div class="field">
|
||||
<button class="btn btn-small btn-warning" type="submit"
|
||||
onclick="return confirm('${_('Confirm to archive this repository: %s') % c.repo_name}');">
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to archive this repository'), _gettext('Archive'), '${c.rhodecode_db_repo.repo_name}')"
|
||||
>
|
||||
${_('Archive this repository')}
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -221,7 +224,8 @@
|
|||
|
||||
<div class="field">
|
||||
<button class="btn btn-small btn-danger" type="submit"
|
||||
onclick="return confirm('${_('Confirm to delete this repository: %s') % c.repo_name}');">
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this repository'), _gettext('Delete'), '${c.rhodecode_db_repo.repo_name}')"
|
||||
>
|
||||
${_('Delete this repository')}
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,11 @@
|
|||
${h.secure_form(h.route_path('edit_repo_caches', repo_name=c.repo_name), request=request)}
|
||||
<div class="form">
|
||||
<div class="fields">
|
||||
${h.submit('reset_cache_%s' % c.rhodecode_db_repo.repo_name,_('Invalidate repository cache'),class_="btn btn-small",onclick="return confirm('"+_('Confirm to invalidate repository cache')+"');")}
|
||||
<input class="btn btn-small" id="reset_cache_${c.rhodecode_db_repo.repo_id}"
|
||||
name="reset_cache_${c.rhodecode_db_repo.repo_id}"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to invalidate repository cache'), _gettext('Invalidate Cache'), '${c.rhodecode_db_repo.repo_name}')"
|
||||
type="submit" value="${_('Invalidate repository cache')}"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
${h.end_form()}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,12 @@
|
|||
${h.secure_form(h.route_path('edit_repo_remote_pull', repo_name=c.repo_name), request=request)}
|
||||
<div class="form">
|
||||
<div class="fields">
|
||||
${h.submit('remote_pull_%s' % c.rhodecode_db_repo.repo_name,_('Pull changes from remote location'),class_="btn btn-small",onclick="return confirm('"+_('Confirm to pull changes from remote side')+"');")}
|
||||
<input class="btn btn-small"
|
||||
id="remote_pull_${c.rhodecode_db_repo.repo_id}"
|
||||
name="remote_pull_${c.rhodecode_db_repo.repo_id}"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm pull changes from remote side'), _gettext('Pull changes'), '${c.rhodecode_db_repo.clone_uri_hidden}')"
|
||||
type="submit" value="${_('Pull changes from remote location')}"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
${h.end_form()}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
<div class="field">
|
||||
<button class="btn btn-small btn-danger" type="submit"
|
||||
onclick="return confirm('${_('Confirm to delete this exception')}');">
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this exception'), _gettext('Delete'), ${c.exception_id})">
|
||||
<i class="icon-remove"></i>
|
||||
${_('Delete This Exception')}
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@
|
|||
<input type="hidden" name="type_filter", value="${c.type_filter}">
|
||||
<div class="field">
|
||||
<button class="btn btn-small btn-danger" type="submit"
|
||||
onclick="return confirm('${_('Confirm to delete all exceptions')}');">
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete all exceptions'), _gettext('Delete'), '${'total:{}'.format(c.exception_list_count)}')"
|
||||
>
|
||||
<i class="icon-remove"></i>
|
||||
% if c.type_filter:
|
||||
${_('Delete All `{}`').format(c.type_filter)}
|
||||
|
|
|
|||
|
|
@ -176,8 +176,10 @@ ${h.style_metatag(tag_type, tag)|n,trim}
|
|||
</div>
|
||||
<div class="grid_delete">
|
||||
${h.secure_form(h.route_path('edit_repo_advanced_delete', repo_name=repo_name), request=request)}
|
||||
${h.submit('remove_%s' % repo_name,_('Delete'),class_="btn btn-link btn-danger",
|
||||
onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo_name+"');")}
|
||||
<input class="btn btn-link btn-danger" id="remove_${repo_name}" name="remove_${repo_name}"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this repository'), _gettext('Delete'), '${repo_name}')"
|
||||
type="submit" value="Delete"
|
||||
>
|
||||
${h.end_form()}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -250,8 +252,10 @@ ${h.style_metatag(tag_type, tag)|n,trim}
|
|||
</div>
|
||||
<div class="grid_delete">
|
||||
${h.secure_form(h.route_path('edit_repo_group_advanced_delete', repo_group_name=repo_group_name), request=request)}
|
||||
${h.submit('remove_%s' % repo_group_name,_('Delete'),class_="btn btn-link btn-danger",
|
||||
onclick="return confirm('"+_ungettext('Confirm to delete this group: %s with %s repository','Confirm to delete this group: %s with %s repositories',gr_count) % (repo_group_name, gr_count)+"');")}
|
||||
<input class="btn btn-link btn-danger" id="remove_${repo_group_name}" name="remove_${repo_group_name}"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this repository group'), _gettext('Delete'), '${_ungettext('`{}` with {} repository','`{}` with {} repositories',gr_count).format(repo_group_name, gr_count)}')"
|
||||
type="submit" value="Delete"
|
||||
>
|
||||
${h.end_form()}
|
||||
</div>
|
||||
</%def>
|
||||
|
|
@ -265,8 +269,10 @@ ${h.style_metatag(tag_type, tag)|n,trim}
|
|||
</div>
|
||||
<div class="grid_delete">
|
||||
${h.secure_form(h.route_path('user_delete', user_id=user_id), request=request)}
|
||||
${h.submit('remove_',_('Delete'),id="remove_user_%s" % user_id, class_="btn btn-link btn-danger",
|
||||
onclick="return confirm('"+_('Confirm to delete this user: %s') % username+"');")}
|
||||
<input class="btn btn-link btn-danger" id="remove_user_${user_id}" name="remove_user_${user_id}"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this user'), _gettext('Delete'), '${username}')"
|
||||
type="submit" value="Delete"
|
||||
>
|
||||
${h.end_form()}
|
||||
</div>
|
||||
</%def>
|
||||
|
|
@ -277,8 +283,10 @@ ${h.style_metatag(tag_type, tag)|n,trim}
|
|||
</div>
|
||||
<div class="grid_delete">
|
||||
${h.secure_form(h.route_path('user_groups_delete', user_group_id=user_group_id), request=request)}
|
||||
${h.submit('remove_',_('Delete'),id="remove_group_%s" % user_group_id, class_="btn btn-link btn-danger",
|
||||
onclick="return confirm('"+_('Confirm to delete this user group: %s') % user_group_name+"');")}
|
||||
<input class="btn btn-link btn-danger" id="remove_group_${user_group_id}" name="remove_group_${user_group_id}"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this user group'), _gettext('Delete'), '${user_group_name}')"
|
||||
type="submit" value="Delete"
|
||||
>
|
||||
${h.end_form()}
|
||||
</div>
|
||||
</%def>
|
||||
|
|
@ -423,8 +431,10 @@ ${h.style_metatag(tag_type, tag)|n,trim}
|
|||
% if h.HasRepoPermissionAny('repository.admin')(c.repo_name):
|
||||
<div class="grid_delete">
|
||||
${h.secure_form(h.route_path('repo_artifacts_delete', repo_name=repo_name, uid=file_store_id), request=request)}
|
||||
${h.submit('remove_',_('Delete'),id="remove_artifact_%s" % file_store_id, class_="btn btn-link btn-danger",
|
||||
onclick="return confirm('"+_('Confirm to delete this artifact: %s') % file_uid+"');")}
|
||||
<input class="btn btn-link btn-danger" id="remove_artifact_${file_store_id}" name="remove_artifact_${file_store_id}"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this artifact'), _gettext('Delete'), '${file_uid}')"
|
||||
type="submit" value="${_('Delete')}"
|
||||
>
|
||||
${h.end_form()}
|
||||
</div>
|
||||
% endif
|
||||
|
|
|
|||
|
|
@ -63,8 +63,9 @@
|
|||
<div id="delete_pullrequest" class="action_button pr-save ${('' if c.allowed_to_delete else 'disabled' )}" style="display: none;">
|
||||
% if c.allowed_to_delete:
|
||||
${h.secure_form(h.route_path('pullrequest_delete', repo_name=c.pull_request.target_repo.repo_name, pull_request_id=c.pull_request.pull_request_id), request=request)}
|
||||
${h.submit('remove_%s' % c.pull_request.pull_request_id, _('Delete pull request'),
|
||||
class_="btn btn-link btn-danger no-margin",onclick="return confirm('"+_('Confirm to delete this pull request')+"');")}
|
||||
<input class="btn btn-link btn-danger no-margin" id="remove_${c.pull_request.pull_request_id}" name="remove_${c.pull_request.pull_request_id}"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete this pull request'), _gettext('Delete'), '${'!{}'.format(c.pull_request.pull_request_id)}')"
|
||||
type="submit" value="${_('Delete pull request')}">
|
||||
${h.end_form()}
|
||||
% else:
|
||||
<span class="tooltip" title="${_('Not allowed to delete this pull request')}">${_('Delete pull request')}</span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue