# HG changeset patch # User Marcin Lulek # Date 2020-04-17 20:01:12 # Node ID 4bf03e9f08c33abb54b985587a03a2d456823189 # Parent 4d4359b7904b127217fcbb021e7b3522c5c784a6 templates: switched most of confirm dialogs to sweetalert2 diff --git a/rhodecode/public/css/sweetalert2.less b/rhodecode/public/css/sweetalert2.less --- a/rhodecode/public/css/sweetalert2.less +++ b/rhodecode/public/css/sweetalert2.less @@ -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; diff --git a/rhodecode/public/js/src/rhodecode/comments.js b/rhodecode/public/js/src/rhodecode/comments.js --- a/rhodecode/public/js/src/rhodecode/comments.js +++ b/rhodecode/public/js/src/rhodecode/comments.js @@ -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); diff --git a/rhodecode/public/js/src/rhodecode/utils/ajax.js b/rhodecode/public/js/src/rhodecode/utils/ajax.js --- a/rhodecode/public/js/src/rhodecode/utils/ajax.js +++ b/rhodecode/public/js/src/rhodecode/utils/ajax.js @@ -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(); + } + }) } \ No newline at end of file diff --git a/rhodecode/templates/admin/gists/gist_show.mako b/rhodecode/templates/admin/gists/gist_show.mako --- a/rhodecode/templates/admin/gists/gist_show.mako +++ b/rhodecode/templates/admin/gists/gist_show.mako @@ -54,7 +54,10 @@ %if c.is_super_admin or c.gist.gist_owner == c.rhodecode_user.user_id:
${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')+"');")} + ${h.end_form()}
%endif diff --git a/rhodecode/templates/admin/my_account/my_account_auth_tokens.mako b/rhodecode/templates/admin/my_account/my_account_auth_tokens.mako --- a/rhodecode/templates/admin/my_account/my_account_auth_tokens.mako +++ b/rhodecode/templates/admin/my_account/my_account_auth_tokens.mako @@ -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)} ${h.end_form()} diff --git a/rhodecode/templates/admin/my_account/my_account_emails.mako b/rhodecode/templates/admin/my_account/my_account_emails.mako --- a/rhodecode/templates/admin/my_account/my_account_emails.mako +++ b/rhodecode/templates/admin/my_account/my_account_emails.mako @@ -28,7 +28,8 @@ ${h.secure_form(h.route_path('my_account_emails_delete'), request=request)} ${h.hidden('del_email_id',em.email_id)} ${h.end_form()} diff --git a/rhodecode/templates/admin/my_account/my_account_ssh_keys.mako b/rhodecode/templates/admin/my_account/my_account_ssh_keys.mako --- a/rhodecode/templates/admin/my_account/my_account_ssh_keys.mako +++ b/rhodecode/templates/admin/my_account/my_account_ssh_keys.mako @@ -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)} ${h.end_form()} diff --git a/rhodecode/templates/admin/repos/repo_edit_advanced.mako b/rhodecode/templates/admin/repos/repo_edit_advanced.mako --- a/rhodecode/templates/admin/repos/repo_edit_advanced.mako +++ b/rhodecode/templates/admin/repos/repo_edit_advanced.mako @@ -93,14 +93,16 @@ %if c.rhodecode_db_repo.locked[0]: ${h.hidden('set_unlock', '1')} %else: ${h.hidden('set_lock', '1')} @@ -166,7 +168,8 @@
@@ -221,7 +224,8 @@
diff --git a/rhodecode/templates/admin/repos/repo_edit_caches.mako b/rhodecode/templates/admin/repos/repo_edit_caches.mako --- a/rhodecode/templates/admin/repos/repo_edit_caches.mako +++ b/rhodecode/templates/admin/repos/repo_edit_caches.mako @@ -17,7 +17,11 @@ ${h.secure_form(h.route_path('edit_repo_caches', repo_name=c.repo_name), request=request)}
- ${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')+"');")} +
${h.end_form()} diff --git a/rhodecode/templates/admin/repos/repo_edit_remote.mako b/rhodecode/templates/admin/repos/repo_edit_remote.mako --- a/rhodecode/templates/admin/repos/repo_edit_remote.mako +++ b/rhodecode/templates/admin/repos/repo_edit_remote.mako @@ -37,7 +37,12 @@ ${h.secure_form(h.route_path('edit_repo_remote_pull', repo_name=c.repo_name), request=request)}
- ${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')+"');")} +
${h.end_form()} diff --git a/rhodecode/templates/admin/settings/settings_exceptions.mako b/rhodecode/templates/admin/settings/settings_exceptions.mako --- a/rhodecode/templates/admin/settings/settings_exceptions.mako +++ b/rhodecode/templates/admin/settings/settings_exceptions.mako @@ -35,7 +35,7 @@
diff --git a/rhodecode/templates/admin/settings/settings_exceptions_browse.mako b/rhodecode/templates/admin/settings/settings_exceptions_browse.mako --- a/rhodecode/templates/admin/settings/settings_exceptions_browse.mako +++ b/rhodecode/templates/admin/settings/settings_exceptions_browse.mako @@ -16,7 +16,8 @@
${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+"');")} + ${h.end_form()}
@@ -250,8 +252,10 @@
${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)+"');")} + ${h.end_form()}
@@ -265,8 +269,10 @@
${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+"');")} + ${h.end_form()}
@@ -277,8 +283,10 @@
${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+"');")} + ${h.end_form()}
@@ -423,8 +431,10 @@ % if h.HasRepoPermissionAny('repository.admin')(c.repo_name):
${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+"');")} + ${h.end_form()}
% endif diff --git a/rhodecode/templates/pullrequests/pullrequest_show.mako b/rhodecode/templates/pullrequests/pullrequest_show.mako --- a/rhodecode/templates/pullrequests/pullrequest_show.mako +++ b/rhodecode/templates/pullrequests/pullrequest_show.mako @@ -63,8 +63,9 @@