Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client upgraded permissions sub super #147

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
54 changes: 43 additions & 11 deletions app/user/user.sidebar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
(function () {
'use strict';

var MY_ACCOUNT = {
text: "My Account",
sref: "app.account.settings",
};

var SUB_CLIENTS = {
text: "Sub Clients",
sref: "app.user.client.sub.list",
};

var SUPER_CLIENTS = {
text: "Super Clients",
sref: "app.user.client.super.list",
};

angular
.module('app.user')
.config(NavConfig)
Expand All @@ -9,20 +24,37 @@
/**
* @ngInject
*/
function NavConfig(NavProvider) {
NavProvider.group('user', {
function NavConfig(Auth, NavProvider, Permission) {
//Need to import Auth and Permission here. Why doesn't this work? in install.nav.config.js and search.tab.js
//this is used in seemingly the exact same way.
var group = NavProvider.group('user', {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why doesnt this work? the other times auth is used it appears to be the exact same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because install.nav.config.js uses .run() instead of .config() where line 21 is in this file.

translate: "nav.USERS",
sref: "app.account.settings",
icon: "fa fa-user",
}).item({
text: "My Account",
sref: "app.account.settings",
}).item({
text: "Sub Clients",
sref: "app.user.client.sub.list",
}).item({
text: "Super Clients",
sref: "app.user.client.super.list"
});

Auth.whileLoggedIn(show, hide);

function show() {
Permission
.map()
.then(showPermitted)
;
}

function showPermitted(map) {
group.item(MY_ACCOUNT);

// if (showSubAndSuperClientPages) {
group.item(SUB_CLIENTS);
group.item(SUPER_CLIENTS);
// }
}

function hide() {
group.remove(MY_ACCOUNT);
group.remove(SUB_CLIENTS);
group.remove(SUPER_CLIENTS);
}
}
})();