diff --git a/admin_board_view/static/AdminBoardView/script.js b/admin_board_view/static/AdminBoardView/script.js index ce11b22..9aae789 100644 --- a/admin_board_view/static/AdminBoardView/script.js +++ b/admin_board_view/static/AdminBoardView/script.js @@ -33,13 +33,30 @@ function showConfirmation(title, body, id) { modal.show(); } +// Filter user page +document.getElementById("user").addEventListener("keypress", e => { + if (e.key === "Enter") { + const name = document.getElementById("user").value; + const escapedName = name.replace("'", "\\'"); + const user_options = document.getElementById("userOptions"); + const selected_user = user_options.querySelector(`[value='${escapedName}']`); + if (!selected_user) { + window.location = `/users?name=${name}`; + } else { + const userId = selected_user.id; + window.location = `/users/${userId}`; + } + } +}); + // Show user page const showUser = document.getElementById("show-user"); if (showUser) { document.getElementById("show-user").addEventListener("click", e => { const name = document.getElementById("user").value; + const escapedName = name.replace("'", "\\'"); const user_options = document.getElementById("userOptions"); - const selected_user = user_options.querySelector(`[value='${name}']`); + const selected_user = user_options.querySelector(`[value='${escapedName}']`); if (!selected_user) { showToast("Show user - Failed", "User not found"); } else { diff --git a/admin_board_view/templates/user.html b/admin_board_view/templates/user.html index d9aeeb6..6df9245 100644 --- a/admin_board_view/templates/user.html +++ b/admin_board_view/templates/user.html @@ -138,6 +138,29 @@
User | +Birthdate | +Balance | +|
---|---|---|---|
{{ user.name }} | +{{ user.email }} | +{{ user.birthday }} | +€{{ user.balance }} | +