Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Fixing Conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
amoshaviv committed May 19, 2014
1 parent 59fc0de commit 9575fdc
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 186 deletions.
6 changes: 0 additions & 6 deletions app/tests/user.server.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,9 @@ describe('User Model Unit Tests:', function() {
});
});

<<<<<<< HEAD
it('should be able to save without problems', function(done) {
user.save(done);
});
=======
it('should be able to save whithout problems', function(done) {
user.save(done);
});
>>>>>>> pr/63

it('should fail to save an existing user again', function(done) {
user.save();
Expand Down
10 changes: 1 addition & 9 deletions public/modules/articles/config/articles.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@

// Configuring the Articles module
angular.module('articles').run(['Menus',
<<<<<<< HEAD
function(Menus) {
// Set top bar menu items
Menus.addMenuItem('topbar', 'Articles', 'articles', 'dropdown');
Menus.addSubMenuItem('topbar', 'articles', 'List Articles', 'articles');
Menus.addSubMenuItem('topbar', 'articles', 'New Article', 'articles/create');
}
=======
function(Menus) {
// Set top bar menu items
Menus.addMenuItem('topbar', 'Articles', 'articles');
Menus.addMenuItem('topbar', 'New Article', 'articles/create');
}
>>>>>>> pr/63
]);
]);
19 changes: 6 additions & 13 deletions public/modules/core/controllers/home.client.controller.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
'use strict';

<<<<<<< HEAD
angular.module('core')
.controller('HomeController', ['$scope', 'Authentication', function ($scope, Authentication) {
// This provides Authentication context.
// see /public/modules/users/services/authentication.client.service.js
$scope.authentication = Authentication;
}]);
=======

angular.module('core').controller('HomeController', ['$scope', 'Authentication',
function($scope, Authentication) {
$scope.authentication = Authentication;
}
]);
>>>>>>> pr/63
function($scope, Authentication) {
// This provides Authentication context.
$scope.authentication = Authentication;
}
]);
203 changes: 45 additions & 158 deletions public/modules/core/services/menus.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

//Menu service used for managing menus
angular.module('core').service('Menus', [
<<<<<<< HEAD
function() {
// Define a set of default roles
this.defaultRoles = ['user'];
Expand All @@ -12,14 +11,14 @@ angular.module('core').service('Menus', [

// A private function for rendering decision
var shouldRender = function(user) {
if(user) {
if (user) {
for (var userRoleIndex in user.roles) {
for (var roleIndex in this.roles) {
if(this.roles[roleIndex] === user.roles[userRoleIndex]) {
if (this.roles[roleIndex] === user.roles[userRoleIndex]) {
return true;
}
}
}
}
} else {
return this.isPublic;
}
Expand Down Expand Up @@ -87,37 +86,37 @@ angular.module('core').service('Menus', [
uiRoute: menuItemUIRoute || ('/' + menuItemURL),
isPublic: isPublic || this.menus[menuId].isPublic,
roles: roles || this.defaultRoles,
subitems: [],
subitems: [],
shouldRender: shouldRender
});

// Return the menu object
return this.menus[menuId];
};

// Add submenu item object
this.addSubMenuItem = function(menuId, rootMenuItemURL, menuItemTitle, menuItemURL, menuItemUIRoute, isPublic, roles) {
// Validate that the menu exists
this.validateMenuExistance(menuId);
// Search for menu item
for (var itemIndex in this.menus[menuId].items) {
if (this.menus[menuId].items[itemIndex].link === rootMenuItemURL) {
// Push new submenu item
this.menus[menuId].items[itemIndex].subitems.push({
title: menuItemTitle,
link: menuItemURL,
uiRoute: menuItemUIRoute || ('/' + menuItemURL),
isPublic: isPublic || this.menus[menuId].isPublic,
roles: roles || this.defaultRoles,
shouldRender: shouldRender
});
}
}
// Return the menu object
return this.menus[menuId];
};
this.addSubMenuItem = function(menuId, rootMenuItemURL, menuItemTitle, menuItemURL, menuItemUIRoute, isPublic, roles) {
// Validate that the menu exists
this.validateMenuExistance(menuId);

// Search for menu item
for (var itemIndex in this.menus[menuId].items) {
if (this.menus[menuId].items[itemIndex].link === rootMenuItemURL) {
// Push new submenu item
this.menus[menuId].items[itemIndex].subitems.push({
title: menuItemTitle,
link: menuItemURL,
uiRoute: menuItemUIRoute || ('/' + menuItemURL),
isPublic: isPublic || this.menus[menuId].isPublic,
roles: roles || this.defaultRoles,
shouldRender: shouldRender
});
}
}

// Return the menu object
return this.menus[menuId];
};

// Remove existing menu object by menu id
this.removeMenuItem = function(menuId, menuItemURL) {
Expand All @@ -134,138 +133,26 @@ angular.module('core').service('Menus', [
// Return the menu object
return this.menus[menuId];
};

// Remove existing menu object by menu id
this.removeSubMenuItem = function(menuId, submenuItemURL) {
// Validate that the menu exists
this.validateMenuExistance(menuId);
// Search for menu item to remove
for (var itemIndex in this.menus[menuId].items) {
for (var subitemIndex in this.menus[menuId].items[itemIndex].subitems) {
if (this.menus[menuId].items[itemIndex].subitems[subitemIndex].link === submenuItemURL) {
this.menus[menuId].items[itemIndex].subitems.splice(subitemIndex, 1);
}
}
}
// Return the menu object
return this.menus[menuId];
};
this.removeSubMenuItem = function(menuId, submenuItemURL) {
// Validate that the menu exists
this.validateMenuExistance(menuId);

// Search for menu item to remove
for (var itemIndex in this.menus[menuId].items) {
for (var subitemIndex in this.menus[menuId].items[itemIndex].subitems) {
if (this.menus[menuId].items[itemIndex].subitems[subitemIndex].link === submenuItemURL) {
this.menus[menuId].items[itemIndex].subitems.splice(subitemIndex, 1);
}
}
}

// Return the menu object
return this.menus[menuId];
};

//Adding the topbar menu
this.addMenu('topbar');
}
=======

function() {
// Define a set of default roles
this.defaultRoles = ['user'];

// Define the menus object
this.menus = {};

// A private function for rendering decision
var shouldRender = function(user) {
if (user) {
for (var userRoleIndex in user.roles) {
for (var roleIndex in this.roles) {
if (this.roles[roleIndex] === user.roles[userRoleIndex]) {
return true;
}
}
}
} else {
return this.isPublic;
}

return false;
};

// Validate menu existance
this.validateMenuExistance = function(menuId) {
if (menuId && menuId.length) {
if (this.menus[menuId]) {
return true;
} else {
throw new Error('Menu does not exists');
}
} else {
throw new Error('MenuId was not provided');
}

return false;
};

// Get the menu object by menu id
this.getMenu = function(menuId) {
// Validate that the menu exists
this.validateMenuExistance(menuId);

// Return the menu object
return this.menus[menuId];
};

// Add new menu object by menu id
this.addMenu = function(menuId, isPublic, roles) {
// Create the new menu
this.menus[menuId] = {
isPublic: isPublic || false,
roles: roles || this.defaultRoles,
items: [],
shouldRender: shouldRender
};

// Return the menu object
return this.menus[menuId];
};

// Remove existing menu object by menu id
this.removeMenu = function(menuId) {
// Validate that the menu exists
this.validateMenuExistance(menuId);

// Return the menu object
delete this.menus[menuId];
};

// Add menu item object
this.addMenuItem = function(menuId, menuItemTitle, menuItemURL, menuItemUIRoute, isPublic, roles) {
// Validate that the menu exists
this.validateMenuExistance(menuId);

// Push new menu item
this.menus[menuId].items.push({
title: menuItemTitle,
link: menuItemURL,
uiRoute: menuItemUIRoute || ('/' + menuItemURL),
isPublic: isPublic || this.menus[menuId].isPublic,
roles: roles || this.defaultRoles,
shouldRender: shouldRender
});

// Return the menu object
return this.menus[menuId];
};

// Remove existing menu object by menu id
this.removeMenuItem = function(menuId, menuItemURL) {
// Validate that the menu exists
this.validateMenuExistance(menuId);

// Search for menu item to remove
for (var itemIndex in this.menus[menuId].items) {
if (this.menus[menuId].items[itemIndex].link === menuItemURL) {
this.menus[menuId].items.splice(itemIndex, 1);
}
}

// Return the menu object
return this.menus[menuId];
};

//Adding the topbar menu
this.addMenu('topbar');
}
>>>>>>> pr/63
]);
]);

0 comments on commit 9575fdc

Please sign in to comment.