Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

fix(header): hide MyProjects btn when 0 projects #605

Merged
merged 1 commit into from
Aug 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/scripts/components/header/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<span class="hidden-md hidden-sm" data-translate>Login</span>
</a>
</li>
<li class="MyProjects" data-ng-if="hc.UserService.currentUser">
<li class="MyProjects" data-ng-if="hc.UserService.currentUser && hc.UserService.hasProjects()">
<label class="MyProjects__label navbar-text">
<input type="checkbox"
data-ng-change="hc.UserService.toggleFilter()"
Expand Down
9 changes: 9 additions & 0 deletions app/scripts/components/user/user.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module ngApp.components.user.services {
currentUser: IUser;
userCanDownloadFiles(files: IFile[]): boolean;
getToken(): void;
hasProjects(): boolean;
}

class UserService implements IUserService {
Expand Down Expand Up @@ -96,6 +97,14 @@ module ngApp.components.user.services {
this.$rootScope.$broadcast("gdc-user-reset");
}

hasProjects(): boolean {
if(!this.currentUser) {
return false;
}
var projects = _.get(this.currentUser.projects, 'gdc_ids', []);
return projects.length > 0;
}

isUserProject(file: IFile): boolean {
if (!this.currentUser) {
return false;
Expand Down