Skip to content

Commit

Permalink
simplify logic in template
Browse files Browse the repository at this point in the history
- rename displayHeaderButtons back to displayShareButton

- displayShareButton is only for share button, not for settings button

- remove CSS app-settings-available and put logic directly in template ng-if
  • Loading branch information
megahirt committed Feb 14, 2022
1 parent ba54c77 commit 8bfaf45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<breadcrumbs id="top" class="breadcrumbs d-none d-md-block"></breadcrumbs>
</div>
<ul class="nav navbar-nav">
<li class="nav-item" ng-if="$ctrl.isLexiconProject" id="settings-dropdown-button" uib-dropdown data-ng-class="{'app-settings-available': $ctrl.header.settings.length > 0 && $ctrl.currentUserIsProjectManager}">
<li class="nav-item" ng-if="$ctrl.isLexiconProject && $ctrl.currentUserIsProjectManager" id="settings-dropdown-button" uib-dropdown>
<a id="settingsBtn" class="btn btn-primary my-auto" uib-dropdown-toggle title="Settings" href="#">
<i class="fa fa-cog iconPadding"></i><span>Settings</span>
</a>
Expand All @@ -95,7 +95,7 @@
{% endverbatim %}
</div>
</li>
<li class='nav-item' ng-if="$ctrl.isLexiconProject">
<li class='nav-item' ng-if="$ctrl.isLexiconProject && $ctrl.displayShareButton">
<a id="shareBtn" class="btn btn-primary my-auto" title="Share" href="#"
ng-click="$ctrl.openShareWithOthersModal()">
<i class="fa fa-share-alt iconPadding"></i><span>Share</span>
Expand Down
14 changes: 1 addition & 13 deletions src/Site/views/languageforge/theme/default/sass/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,6 @@
}
}

#settings-dropdown-button:not(.app-settings-available) {
.dropdown-toggle {
visibility: hidden;
}
}

#settings-dropdown-button.app-settings-available {
.dropdown-toggle {
visibility: visible;
}
}

#settingsBtn {
margin: 12px;
margin-right: 6px;
Expand All @@ -287,7 +275,7 @@
font-size: 1rem;
}
}

#settingsBtn::after {
display:none;
}
Expand Down
10 changes: 5 additions & 5 deletions src/angular-app/bellows/core/navbar.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export class NavbarController implements angular.IController {
project: Project;
interfaceConfig: InterfaceConfig;
currentUserIsProjectManager: boolean;
displayHeaderButtons: boolean;
displayShareButton: boolean;
projectTypeNames: ProjectTypeNames;
siteName: string;
isLexiconProject: boolean = false;

static $inject = [
'$scope',
'$uibModal',
'projectService',
'projectService',
'sessionService',
'offlineCacheUtils',
'applicationHeaderService'];
Expand Down Expand Up @@ -75,7 +75,7 @@ export class NavbarController implements angular.IController {
this.currentUserIsProjectManager =
(session.data.userProjectRole === ProjectRoles.MANAGER.key) ||
(session.data.userProjectRole === ProjectRoles.TECH_SUPPORT.key);
this.displayHeaderButtons =
this.displayShareButton =
(this.currentUserIsProjectManager || (this.project.allowSharing && this.session.data.userIsProjectMember));
}

Expand All @@ -84,9 +84,9 @@ export class NavbarController implements angular.IController {
this.siteName = session.baseSite();
});
this.$scope.$on('$locationChangeStart', (event, next, current) => {
if (current.includes('/lexicon') && !current.includes('/new-project') && this.displayHeaderButtons) {
if (current.includes('/lexicon') && !current.includes('/new-project')) {
this.isLexiconProject = true;
}else{
} else {
this.isLexiconProject = false;
}
});
Expand Down

0 comments on commit 8bfaf45

Please sign in to comment.