From c0a4addf30f265eef78235f17899a1254f5e4f6a Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 17 Apr 2021 18:30:55 +0200 Subject: [PATCH] Cancel button in User edit now leads to the right page back #1938 --- cps/static/js/main.js | 14 ++++++++++++++ cps/static/js/table.js | 6 +++--- cps/templates/admin.html | 2 +- cps/templates/email_edit.html | 2 +- cps/templates/user_edit.html | 2 +- cps/templates/user_table.html | 3 +++ 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 81308c64..7231c51c 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -114,6 +114,20 @@ $(document).ready(function() { } }); +$(".session").click(function() { + window.sessionStorage.setItem("back", window.location.pathname); +}); + +$("#back").click(function() { + var loc = sessionStorage.getItem("back"); + if (!loc) { + loc = $(this).data("back"); + } + sessionStorage.removeItem("back"); + window.location.href = loc; + +}); + function confirmDialog(id, dialogid, dataValue, yesFn, noFn) { var $confirm = $("#" + dialogid); $confirm.modal('show'); diff --git a/cps/static/js/table.js b/cps/static/js/table.js index 7c4b04a7..d5a070c9 100644 --- a/cps/static/js/table.js +++ b/cps/static/js/table.js @@ -600,7 +600,7 @@ function responseHandler(res) { } function singleUserFormatter(value, row) { - return '' + this.buttontext + '' + return '' + this.buttontext + '' } function checkboxFormatter(value, row, index){ @@ -741,6 +741,6 @@ function queryParams(params) return params; } -function test(){ - console.log("hello"); +function storeLocation() { + window.sessionStorage.setItem("back", window.location.pathname); } diff --git a/cps/templates/admin.html b/cps/templates/admin.html index 5226151e..c06b7e72 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -26,7 +26,7 @@ {% for user in allUser %} {% if not user.role_anonymous() or config.config_anonbrowse %} - {{user.name}} + {{user.name}} {{user.email}} {{user.kindle_mail}} {{user.downloads.count()}} diff --git a/cps/templates/email_edit.html b/cps/templates/email_edit.html index ac1c36d2..59978ea9 100644 --- a/cps/templates/email_edit.html +++ b/cps/templates/email_edit.html @@ -66,7 +66,7 @@ {% if feature_support['gmail'] %} {% endif %} - {{_('Back')}} + {{_('Back')}} {% if g.allow_registration %}
diff --git a/cps/templates/user_edit.html b/cps/templates/user_edit.html index e2b184fc..846ad978 100644 --- a/cps/templates/user_edit.html +++ b/cps/templates/user_edit.html @@ -129,7 +129,7 @@
{{_('Save')}}
{% if not profile %} - {{_('Cancel')}} +
{{_('Cancel')}}
{% endif %} {% if g.user and g.user.role_admin() and not profile and not new_user and not content.role_anonymous() %}
{{_('Delete User')}}
diff --git a/cps/templates/user_table.html b/cps/templates/user_table.html index b8a9d2c2..c538dfa4 100644 --- a/cps/templates/user_table.html +++ b/cps/templates/user_table.html @@ -137,6 +137,9 @@ + {% endblock %} {% block modal %} {{ delete_confirm_modal() }}