Skip to content

Commit

Permalink
#3 add project in the left menu
Browse files Browse the repository at this point in the history
  • Loading branch information
quoctran18 committed Aug 30, 2017
1 parent 107be09 commit f61a84e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 38 deletions.
1 change: 1 addition & 0 deletions viDoc/modules/core/client/services/menu.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
state: options.state || '',
type: options.type || 'item',
class: options.class,
params: options.params || {},
roles: ((options.roles === null || typeof options.roles === 'undefined') ? service.defaultRoles : options.roles),
position: options.position || 0,
items: [],
Expand Down
34 changes: 3 additions & 31 deletions viDoc/modules/core/client/views/sidebar.client.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,13 @@
<ul class="sidebar-menu">

<li class="header">MANAGEMENT</li>
<li class="treeview">
<a ui-sref="projects.list">
<li ng-repeat="subitem in vm.menu.items | orderBy: 'position'" ng ng-if="subitem.shouldRender(vm.authentication.user);" ui-sref-active="active" class="treeview">
<a ui-sref="{{subitem.state}}({[subitem.params.name]: subitem.params.id })">
<span class="glyphicon glyphicon-book"
style="font-size: 12px;padding-right: 8px"></span>
<span>Projects</span>
<span ng-bind="subitem.title"></span>
</a>
</li>
<li class="treeview">
<a ui-sref="admin.users">
<span class="glyphicon glyphicon-user"
style="font-size: 12px;padding-right: 8px"></span>
<span>Manage Users</span>
</a>
</li>
<li class="treeview">
<a ui-sref="chat">
<span class="glyphicon glyphicon-envelope"
style="font-size: 12px;padding-right: 8px"></span>
<span>Chat</span>
</a>
</li>
<li ng-repeat="item in vm.menu.items | orderBy: 'position'" ng-if="item.shouldRender(vm.authentication.user);" ui-sref-active="active" class="{{item.class}} treeview">
<a href="#">
<i ng-class="item.icon || 'fa-circle-o' " class="fa"></i>
<span ng-bind="item.title"></span>
<span class="pull-right-container" ng-if="item.items.length>0">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu" ng-if="item.items.length>0">
<li ng-repeat="subitem in item.items | orderBy: 'position'" ng-if="subitem.shouldRender(vm.authentication.user);">
<a ui-sref="{{subitem.state}}({{subitem.params}})" ><i class="fa fa-circle-o"></i> <span ng-bind="subitem.title"></span></a>
</li>
</ul>
</li>

</ul>
</section>
Expand Down
14 changes: 12 additions & 2 deletions viDoc/modules/projects/client/config/projects.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@
.module('projects')
.run(menuConfig);

menuConfig.$inject = ['menuService'];
menuConfig.$inject = ['menuService', 'ProjectsService'];

function menuConfig(menuService) {
function menuConfig(menuService, ProjectsService) {
// Set top bar menu items
ProjectsService.query(projects => {
for (let project of projects) {
menuService.addMenuItem('sidebar', {
title: project.name,
state: 'projects.view',
params: { name: 'projectId', id: project._id },
roles: ['*']
});
}
});
}
}());
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
.module('projects')
.controller('ProjectsListController', ProjectsListController);

ProjectsListController.$inject = ['ProjectsService'];
ProjectsListController.$inject = ['$scope', 'ProjectsService', 'menuService', '$state'];

function ProjectsListController(ProjectsService) {
function ProjectsListController($scope, ProjectsService, menuService, $state) {
var vm = this;

vm.projects = ProjectsService.query();
vm.projectName = function (name) {
return name.replace(/ /gi, '-').toLowerCase();
};
}
}());
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
vm.remove = remove;
vm.save = save;
vm.close = close;
if (!vm.project.userID) {
vm.project.userID = [];
}
vm.addUser = function(userId) {
var index = vm.project.userID.indexOf(userId);
if (index === -1) {
Expand Down

0 comments on commit f61a84e

Please sign in to comment.