From 492c029cca1d9db37dedbbe01a7b5d8f15bff03f Mon Sep 17 00:00:00 2001 From: Guilherme Reginaldo Ruella Date: Wed, 23 Nov 2016 15:43:35 -0200 Subject: [PATCH] Bug fixes - Fixed a bug were the interface didn't refresh the permissions after a user changed it's own permissions - Fixed a bug were the schedules page's FAB didn't show up on first load - Changed some labels --- web/index.html | 2 +- web/static/css/all.css | 1 + web/static/css/common.css | 2 +- web/static/js/pages/schedules.js | 6 ++++- web/static/js/pages/user-info.js | 9 +++++++ web/static/js/pages/user-update.js | 40 ++++++++++++++++++++++++++-- web/static/res/dictionary/en-us.json | 4 +-- web/static/res/dictionary/pt-br.json | 4 +-- 8 files changed, 59 insertions(+), 9 deletions(-) diff --git a/web/index.html b/web/index.html index 53a1502..30c3461 100644 --- a/web/index.html +++ b/web/index.html @@ -1052,7 +1052,7 @@
- +
diff --git a/web/static/css/all.css b/web/static/css/all.css index 3eeaba2..bcb4494 100644 --- a/web/static/css/all.css +++ b/web/static/css/all.css @@ -144,6 +144,7 @@ section > .list{ .clickable-app-bar.none-selected .none-selected-text{ visibility: visible; background-color: var(--primary-color); + text-decoration: underline; } /** diff --git a/web/static/css/common.css b/web/static/css/common.css index 7d02ef2..717d61e 100644 --- a/web/static/css/common.css +++ b/web/static/css/common.css @@ -219,7 +219,7 @@ body{ flex-shrink: 0; } .vertical-separator, .horizontal-separator{ - margin: 2em 0; + margin: 1.5em 0; } .vertical-separator, .vertical-line{ display: inline-block; diff --git a/web/static/js/pages/schedules.js b/web/static/js/pages/schedules.js index 26a461d..4fe4cbe 100644 --- a/web/static/js/pages/schedules.js +++ b/web/static/js/pages/schedules.js @@ -29,9 +29,13 @@ spa.onNavigate('schedules', (page, params) => { // *Checking if the vehicle is active: if(!data.active){ - // *If it is: + // *If it's not: // *Hiding the 'Add schedules' FAB: $('#schedules-create-done-fab').hide(); + } else{ + // *If it is: + // *Showing the 'Add schedules' FAB: + $('#schedules-create-done-fab').show(); } }) .fail(xhr => { diff --git a/web/static/js/pages/user-info.js b/web/static/js/pages/user-info.js index 4827522..275be7f 100644 --- a/web/static/js/pages/user-info.js +++ b/web/static/js/pages/user-info.js @@ -10,6 +10,15 @@ spa.onNavigate('user-info', (page, params) => { // *Checking if the user was authenticated: if(authenticated == true) { // *If true: + + // *Checking if the current user has permission to manage other user's account: + if(!request.retrieveUserPermissions().permissions.manage_users){ + // *If they're: + // *Navigating to account-info page: + spa.navigateTo('account-info', {id: user_id}); + return; + } + // *Listing the user: request.getUserSensitive(user_id) .done(data => { diff --git a/web/static/js/pages/user-update.js b/web/static/js/pages/user-update.js index b7efdc9..6c242f4 100644 --- a/web/static/js/pages/user-update.js +++ b/web/static/js/pages/user-update.js @@ -186,8 +186,44 @@ function updateUser(user_id, user_photo_base64){ .done(data => { // *Showing the snack with the message: snack.open(srm.get('user-update-successful-snack'), snack.TIME_SHORT); - // *Going back to user-info: - spa.goBack(); + + // *Checking if the updated user is the current one: + if(user_id === request.retrieveAccessInfo().id){ + // *If it was: + // *Requesting for the user authentication: + request.getAuth() + .done(data => { + // *Updating user permissions data: + request.saveUserPermissions( + {permissions: { + manage_schedules: data.user.permission_schedules, + manage_users: data.user.permission_users, + manage_vehicles: data.user.permission_vehicles + }}); + + // *Checking if the user can manage other users: + if(data.user.permission_users){ + // *If they are: + // *Going back to user-info: + spa.goBack(); + } else{ + // *If they aren't: + // *Navigating to account info page: + spa.navigateTo('account-info', {id: user_id}); + } + + // *Loading the user info on drawer: + updateDrawerUserInfo(); + }) + .fail(xhr => { + // *Redirecting the user to login page: + spa.navigateTo('login'); + }); + } else{ + // *If it wasn't: + // *Going back to user-info: + spa.goBack(); + } }) .fail(xhr => { // *Checking if the request's status is 401, sending the user to the login page if it is: diff --git a/web/static/res/dictionary/en-us.json b/web/static/res/dictionary/en-us.json index 875b0c7..91dde78 100644 --- a/web/static/res/dictionary/en-us.json +++ b/web/static/res/dictionary/en-us.json @@ -156,8 +156,8 @@ ["user-update-permission-vehicles-detail", "${user-create-permission-vehicles-detail}"], ["reservations-header", "Find reservations"], - ["none-selected-text-reservations-vehicle", "No vehicle selected"], - ["none-selected-text-reservations-user", "No user selected"], + ["none-selected-text-reservations-vehicle", "Select a vehicle"], + ["none-selected-text-reservations-user", "Select an user"], ["settings-header", "Settings"], ["settings-language", "Language"], diff --git a/web/static/res/dictionary/pt-br.json b/web/static/res/dictionary/pt-br.json index 2eb95e6..0373099 100644 --- a/web/static/res/dictionary/pt-br.json +++ b/web/static/res/dictionary/pt-br.json @@ -156,8 +156,8 @@ ["user-update-permission-vehicles-detail", "${user-create-permission-vehicles-detail}"], ["reservations-header", "Procurar reservas"], - ["none-selected-text-reservations-vehicle", "Nenhum veículo selecionado"], - ["none-selected-text-reservations-user", "Nenhum usuário selecionado"], + ["none-selected-text-reservations-vehicle", "Escolha um veículo"], + ["none-selected-text-reservations-user", "Escolha um usuário"], ["settings-header", "Configurações"], ["settings-language", "Idioma"],