Skip to content

Commit

Permalink
fix(login): disable buttons w/o session
Browse files Browse the repository at this point in the history
This commit addresses two issues reported in #222:
 1. The duplicate text on the login panel has been removed.
 2. The tree cannot be expanded when the user does not have a session.
  • Loading branch information
jniles committed May 5, 2016
1 parent b0e797a commit 3ef5632
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions client/src/partials/bhima/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ function ApplicationController(AppCache, Session, Languages, $state, $rootScope,
// the 'true' parameter forces refresh
Languages.read(true);

vm.isLoggedIn = function isLoggedIn() {
vm.isLoggedIn = isLoggedIn;

// check if the user has a valid session.
function isLoggedIn() {
return !!Session.user;
};
}

// Default sidebar state
/** @todo Load sidebar state before angular is bootstrapped to remove 'flicker' */
Expand All @@ -38,6 +41,7 @@ function ApplicationController(AppCache, Session, Languages, $state, $rootScope,
* Application Structure methods
*/
vm.toggleSidebar = function toggleSidebar() {
if (!isLoggedIn()) { return; }
vm.sidebarExpanded = !vm.sidebarExpanded;
cache.sidebar = { expanded : vm.sidebarExpanded };
};
Expand All @@ -52,7 +56,9 @@ function ApplicationController(AppCache, Session, Languages, $state, $rootScope,
delete vm.project;
});

// go to the settings page
vm.settings = function settings() {
if (!isLoggedIn()) { return; }
$state.go('settings', { previous : $state.$current.name });
};

Expand Down
5 changes: 3 additions & 2 deletions client/src/partials/login/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
</button>
<ul role="menu" uib-dropdown-menu>
<li role="menuitem" ng-repeat="(key, lang) in LoginCtrl.languages">
<a ng-click="LoginCtrl.languageService.set(key)">{{ lang.name }}</a>
<a ng-click="LoginCtrl.languageService.set(key)" href>
{{ lang.name }}
</a>
</li>
</ul>
</div>
<h4>{{ "LOGIN.TITLE" | translate }}</h4>
</div>

<div class="panel-body">
Expand Down
3 changes: 1 addition & 2 deletions client/src/partials/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ angular.module('bhima.controllers')
.controller('LoginController', LoginController);

LoginController.$inject = [
'appcache', 'SessionService',
'LanguageService', 'ProjectService'
'appcache', 'SessionService', 'LanguageService', 'ProjectService'
];

/**
Expand Down

0 comments on commit 3ef5632

Please sign in to comment.