Skip to content

Commit

Permalink
Merge pull request #89 from Potentii/ui-permission-bug-fix
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
Potentii authored Nov 23, 2016
2 parents eb97020 + 492c029 commit 880938c
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 9 deletions.
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@
<section id="account-info-section" data-page="account-info">
<!-- Appbar -->
<header class="app-bar flex-horizontal-layout tinted">
<button type="button" onclick="spa.goBack()" class="inflate material-icons mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored raised fab">arrow_back</button>
<button type="button" onclick="spa.navigateTo('users')" class="inflate material-icons mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored raised fab">arrow_back</button>
<span data-intl="account-info-header"></span>
</header>

Expand Down
1 change: 1 addition & 0 deletions web/static/css/all.css
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ section > .list{
.clickable-app-bar.none-selected .none-selected-text{
visibility: visible;
background-color: var(--primary-color);
text-decoration: underline;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion web/static/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion web/static/js/pages/schedules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
9 changes: 9 additions & 0 deletions web/static/js/pages/user-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
40 changes: 38 additions & 2 deletions web/static/js/pages/user-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions web/static/res/dictionary/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
4 changes: 2 additions & 2 deletions web/static/res/dictionary/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit 880938c

Please sign in to comment.