Skip to content

Commit

Permalink
Merge pull request #1363 from eciis/sideMenu-component
Browse files Browse the repository at this point in the history
Side menu component
  • Loading branch information
JuliePessoa authored Jan 14, 2019
2 parents 681f284 + 3c4859c commit dcc6a04
Show file tree
Hide file tree
Showing 23 changed files with 735 additions and 374 deletions.
2 changes: 1 addition & 1 deletion frontend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
abstract: true,
views: {
content: {
templateUrl: "app/user/left_nav.html",
templateUrl: "app/home/left_nav.html",
controller: "HomeController as homeCtrl"
}
}
Expand Down
60 changes: 7 additions & 53 deletions frontend/home/homeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,17 @@
var app = angular.module("app");

app.controller("HomeController", function HomeController(AuthService, $mdDialog,
$state, EventService, ProfileService, $rootScope, POST_EVENTS, STATES, UtilsService) {
$state, EventService, ProfileService, $rootScope, POST_EVENTS, STATES) {
var homeCtrl = this;

var ACTIVE = "active";
var LIMITE_EVENTS = 5;

homeCtrl.events = [];
homeCtrl.followingInstitutions = [];
homeCtrl.instMenuExpanded = false;
homeCtrl.isLoadingPosts = true;
homeCtrl.showMessageOfEmptyEvents = true;

homeCtrl.user = AuthService.getCurrentUser();

homeCtrl.getSelectedClass = function (stateName){
return $state.current.name === STATES[stateName] ? "selected" : "";
};

homeCtrl.goToInstitution = function goToInstitution(institutionKey) {
$state.go(STATES.INST_TIMELINE, {institutionKey: institutionKey});
};
homeCtrl.user = AuthService.getCurrentUser();

homeCtrl.eventInProgress = function eventInProgress(event) {
var end_time = event.end_time;
Expand All @@ -42,28 +32,16 @@
ProfileService.showProfile(userKey, ev);
};

homeCtrl.goHome = function goHome() {
UtilsService.selectNavOption(STATES.HOME);
};

homeCtrl.goToProfile = function goToProfile() {
UtilsService.selectNavOption(STATES.CONFIG_PROFILE);
homeCtrl.goToInstitution = function goToInstitution(institutionKey) {
$state.go(STATES.INST_TIMELINE, {institutionKey: institutionKey});
};

homeCtrl.goToEvents = function goToEvents() {
UtilsService.selectNavOption(STATES.EVENTS, {posts: homeCtrl.posts});
};

homeCtrl.goToInstitutions = function goToInstitutions() {
UtilsService.selectNavOption(STATES.USER_INSTITUTIONS);
};

homeCtrl.goInvite = function goInvite() {
UtilsService.selectNavOption(STATES.INVITE_INSTITUTION);
$state.go(STATES.EVENTS);
};

homeCtrl.goToEvent = function goToEvent(event) {
$state.go(STATES.EVENT_DETAILS, {eventKey: event.key, posts: homeCtrl.posts});
$state.go(STATES.EVENT_DETAILS, {eventKey: event.key});
};

homeCtrl.newPost = function newPost(event) {
Expand All @@ -83,14 +61,6 @@
});
};

homeCtrl.expandInstMenu = function expandInstMenu(){
homeCtrl.instMenuExpanded = !homeCtrl.instMenuExpanded;
};

homeCtrl.isActive = function isActive(institution) {
return institution.state === ACTIVE;
};

homeCtrl.isEventsEmpty = function isEventsEmpty() {
return homeCtrl.events.length === 0 || homeCtrl.showMessageOfEmptyEvents;
};
Expand All @@ -109,7 +79,7 @@
});
};

function getFollowingInstitutions(){
function getFollowingInstitutions() {
homeCtrl.followingInstitutions = homeCtrl.user.follows;
}

Expand All @@ -133,22 +103,6 @@
return actualEvents;
}

homeCtrl.takeTour = function takeTour(event) {
$mdDialog.show({
templateUrl: 'app/invites/welcome_dialog.html',
controller: function WelcomeController() {
var controller = this;
controller.next = false;
controller.cancel = function() {
$mdDialog.cancel();
};
},
controllerAs: "controller",
targetEvent: event,
clickOutsideToClose: false
});
};

/**
* Start the listeners to new post and delete post events.
* broadCasts the event to the hierachy by calling broadcastPostEvent()
Expand Down
6 changes: 6 additions & 0 deletions frontend/home/left_nav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div flex="100" layout="row" layout-align="center">
<div flex flex-lg="90" flex-gt-lg="70" layout="row" md-colors="{background: 'grey-50'}">
<side-menu type="HOME"></side-menu>
<div flex ui-view="user_content" layout="column"></div>
</div>
</div>
8 changes: 8 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<link rel="stylesheet" type="text/css" href="app/institution/registered_institutions_mobile.css">
<link rel="stylesheet" type="text/css" href="app/institution/registered_institution.css">
<link rel="stylesheet" type="text/css" href="app/invites/new_invite.css">
<link rel="stylesheet" type="text/css" href="app/sideMenu/side_menu.css">
</head>
<body ng-app="app" ng-cloak layout="column">

Expand Down Expand Up @@ -133,6 +134,13 @@
<script src="app/main/mainController.js"></script>
<script src="app/main/hideTopNavbar.js"></script>

<!-- SideMenu -->
<script src="app/sideMenu/sideMenu.component.js"></script>
<script src="app/sideMenu/sideMenuConstants.js"></script>
<script src="app/sideMenu/factories/homeItems.factory.js"></script>
<script src="app/sideMenu/factories/manageInstItems.factory.js"></script>
<script src="app/sideMenu/sideMenuItem/sideMenuItem.component.js"></script>

<!--Utils-->
<script src="app/utils/utils.js"></script>
<script src="app/utils/messageService.js"></script>
Expand Down
44 changes: 13 additions & 31 deletions frontend/institution/institutionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
institutionCtrl.addPost = institutionCtrl.user.current_institution.key === currentInstitutionKey;
const DEFAULT_INST_PHOTO = '/app/images/institution.png';

institutionCtrl.$onInit = () => {
institutionCtrl.canManageInst();
loadInstitution();
};

function loadInstitution() {
InstitutionService.getInstitution(currentInstitutionKey).then(function success(response) {
institutionCtrl.institution = new Institution(response);
Expand Down Expand Up @@ -65,8 +70,6 @@
institutionCtrl.portfolioUrl = url;
}

loadInstitution();

institutionCtrl.isAdmin = function isAdmin() {
var isAdmin = institutionCtrl.user.isAdmin(currentInstitutionKey);
var isloggedWithInstitution = (institutionCtrl.user.current_institution.key === currentInstitutionKey);
Expand Down Expand Up @@ -119,20 +122,9 @@
institutionCtrl.institution.name !== "Departamento do Complexo Industrial e Inovação em Saúde";
};

institutionCtrl.goToManageMembers = function goToManageMembers(){
UtilsService.selectNavOption(STATES.MANAGE_INST_MEMBERS, {institutionKey: currentInstitutionKey});
};

institutionCtrl.goToManageInstitutions = function goToManageInstitutions(){
UtilsService.selectNavOption(STATES.MANAGE_INST_INVITE_INST, {institutionKey: currentInstitutionKey});
};

institutionCtrl.goToEditInfo = function goToEditInfo(){
UtilsService.selectNavOption(STATES.MANAGE_INST_EDIT, {institutionKey: currentInstitutionKey});
};

institutionCtrl.goToInstitution = function goToInstitution(institutionKey) {
UtilsService.selectNavOption(STATES.INST_TIMELINE, {institutionKey: institutionKey});
const instKey = institutionKey || currentInstitutionKey;
$state.go(STATES.INST_TIMELINE, {institutionKey: instKey});
};

institutionCtrl.goToMembers = function goToMembers(institutionKey) {
Expand Down Expand Up @@ -177,7 +169,6 @@
institutionCtrl.isMember = institutionCtrl.user.isMember(institutionKey);
};


institutionCtrl.portfolioDialog = function(ev) {
$mdDialog.show({
templateUrl: 'app/institution/portfolioDialog.html',
Expand Down Expand Up @@ -290,20 +281,6 @@
ctrl.portfolioUrl = trustedUrl;
}

institutionCtrl.removeInstitution = function removeInstitution(ev) {
institutionCtrl.stateView = "remove_inst";
$mdDialog.show({
templateUrl: 'app/institution/removeInstDialog.html',
targetEvent: ev,
clickOutsideToClose:true,
locals: {
institution: institutionCtrl.institution
},
controller: "RemoveInstController",
controllerAs: 'removeInstCtrl'
});
};

institutionCtrl.getSelectedClass = function (stateName){
return $state.current.name === STATES[stateName] ? "selected" : "";
};
Expand Down Expand Up @@ -358,7 +335,12 @@
};

institutionCtrl.canManageInst = function canManageInst() {
return institutionCtrl.user.isAdmin(currentInstitutionKey) ? true : $state.go(STATES.HOME);
const isOnManageInstPage = [
STATES.MANAGE_INST_EDIT, STATES.MANAGE_INST_MEMBERS,
STATES.MANAGE_INST_INVITE_INST
].includes($state.current.name);
const isAdmin = institutionCtrl.user.isAdmin(currentInstitutionKey);
if(isOnManageInstPage && !isAdmin) $state.go(STATES.HOME);
};

institutionCtrl.limitString = function limitString(string, size) {
Expand Down
73 changes: 4 additions & 69 deletions frontend/institution/management_institution_page.html
Original file line number Diff line number Diff line change
@@ -1,74 +1,9 @@
<div ng-if="institutionCtrl.canManageInst()" layout="row" flex md-colors="{background: 'grey-200'}" layout-align="center">
<div layout="row" flex md-colors="{background: 'grey-200'}" layout-align="center">
<!-- CONTENT -->
<div flex-lg="90" flex-gt-lg="70" flex layout="row" layout-align="space-between"
md-colors="{background: 'grey-50'}">
<div flex-lg="90" flex-gt-lg="70" flex layout="row" layout-align="space-between" md-colors="{background: 'grey-50'}">

<!-- LEFT SIDE PANEL -->
<md-sidenav class="md-sidenav-left" md-component-id="leftNav" md-whiteframe="4" layout="row"
md-is-locked-open="$mdMedia('gt-sm')" flex-gt-md="25">
<md-content class="custom-scrollbar" layout="column"
md-colors="{background: 'grey-100'}" flex>
<div class="container">
<div class="row">
<div class="card hovercard"
md-colors="{background: institutionCtrl.user.getProfileColor()+'-800'}">
<div class="cardheader">
<div class="avatar">
<img ng-click="institutionCtrl.goToInstitution(institutionCtrl.institution.key)" alt="Foto da Instituição" ng-src="{{ institutionCtrl.institution.photo_url || '/app/images/institution.png' }}">
</div>
</div>
<div class="info"
md-colors="{background: institutionCtrl.user.getProfileColor()+'-600'}">
<div class="desc">
<div class="md-title">
<a style="color: #FFFFFF" href ng-click="institutionCtrl.goToInstitution(institutionCtrl.institution.key)">
{{ institutionCtrl.institution.name }}
</a>
</div>
</div>
</div>
</div>
</div>

<div class="row section-menu">
<md-menu-content width="4" md-colors="{background: 'grey-100'}">
<md-menu-item>
<md-button ng-click="institutionCtrl.goToEditInfo()"
ng-class="institutionCtrl.getSelectedClass('MANAGE_INST_EDIT')">
<md-icon>edit</md-icon>
<b>Editar Informações</b>
</md-button>
</md-menu-item>
<md-menu-item>
<md-button ng-click="institutionCtrl.goToManageMembers()"
ng-class="institutionCtrl.getSelectedClass('MANAGE_INST_MEMBERS')">
<md-icon>people</md-icon>
<b>Gerenciar membros</b>
</md-menu-item>
<md-menu-item>
<md-button ng-click="institutionCtrl.goToManageInstitutions()"
ng-class="institutionCtrl.getSelectedClass('MANAGE_INST_INVITE_INST')">
<md-icon>account_balance</md-icon>
<b>Vínculos Institucionais</b>
</md-button>
</md-menu-item>
<md-menu-item>
<md-button ng-click="institutionCtrl.removeInstitution()">
<md-icon>delete</md-icon>
<b>Remover Instituição</b>
</md-button>
</md-menu-item>
<md-menu-item>
<md-button ng-click="institutionCtrl.goToHome()">
<md-icon>arrow_back</md-icon>
<b>Voltar</b>
</md-button>
</md-menu-item>
</md-menu-content>
</div>
</div>
</md-content>
</md-sidenav>
<!-- LEFT SIDE PANEL -->
<side-menu type="MANAGE_INSTITUTION"></side-menu>

<!-- CONTENT -->
<div flex layout="row" layout-align="center">
Expand Down
2 changes: 1 addition & 1 deletion frontend/main/mainController.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
};

mainCtrl.toggle = function toggle() {
$mdSidenav('leftNav').toggle();
$mdSidenav('sideMenu').toggle();
};

mainCtrl.isSuperUser = function isSuperUser() {
Expand Down
24 changes: 16 additions & 8 deletions frontend/post/post_page.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<md-content layout="row" md-colors="{background: 'grey-200'}" layout-align="center">
<div flex-gt-lg="60" flex-lg="60" layout="row" layout-wrap layout-align="center" class="fill-screen">
<div layout="column" flex ng-if="postCtrl.post && !postCtrl.isHiden()">
<post-details post="postCtrl.post" is-post-page=true></post-details>
</div>
<div layout="row" layout-align="center center" ng-if="postCtrl.post && postCtrl.isHiden()">
<h2>Esta publicação foi removida.</h2>
<div layout="row" md-colors="{background: 'grey-200'}" layout-align="center">
<div flex flex-lg="90" flex-gt-lg="70" layout="row" layout-align="space-between" >

<side-menu type="HOME"></side-menu>

<div flex layout="row" layout-align="center">
<md-content class="custom-scrollbar" flex="95">
<div layout="row" ng-if="postCtrl.post && !postCtrl.isHiden()">
<post-details post="postCtrl.post" is-post-page=true></post-details>
</div>
</md-content>

<div layout="row" layout-align="center center" ng-if="postCtrl.post && postCtrl.isHiden()">
<h2>Esta publicação foi removida.</h2>
</div>
</div>
</div>
</md-content>
</div>
Loading

0 comments on commit dcc6a04

Please sign in to comment.