Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cbueschi committed Feb 3, 2015
2 parents dcb97aa + d07db9b commit cfc1523
Show file tree
Hide file tree
Showing 25 changed files with 350 additions and 161 deletions.
13 changes: 13 additions & 0 deletions app/controllers/members.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,17 @@ exports.memberByID = function(req, res, next, id) {
});

};

/**
* Team middleware
*/
exports.listByTeamId = function(req, res, next, id) {
console.log('members list', id);
Team.findById(id).populate('user', 'displayName').exec(function(err, team) {
if (err) return next(err);
if (! team) return next(new Error('Failed to load Team ' + id));
req.team = team;
next();
});
};

8 changes: 5 additions & 3 deletions app/routes/members.server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module.exports = function(app) {
var teams = require('../../app/controllers/teams.server.controller');

// Members Routes
//app.route('/members');
//.get(members.list);
//.post(users.requiresLogin, members.create);
app.route('/team/:teamId/members')
.get(members.listByTeamId);
// .post(users.requiresLogin, members.create);


app.route('/members/:memberId')
Expand All @@ -18,4 +18,6 @@ module.exports = function(app) {

// Finish by binding the Team middleware
app.param('memberId', members.memberByID);
// if param teamId, apply function members.listByTeamId
app.param('teamId', members.listByTeamId);
};
1 change: 1 addition & 0 deletions config/env/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
sessionSecret: 'TEAMBUDDY',
// The name of the MongoDB collection to store sessions in
sessionCollection: 'sessions',

// The session cookie settings
sessionCookie: {
path: '/',
Expand Down
2 changes: 1 addition & 1 deletion config/env/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = {
db: {
uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean',
uri: process.env.MONGO_URL,
options: {
user: '',
pass: ''
Expand Down
8 changes: 8 additions & 0 deletions public/dist/application.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/dist/application.css.map

Large diffs are not rendered by default.

106 changes: 92 additions & 14 deletions public/dist/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,20 @@ angular.module('buddyevents').config(['$stateProvider',
'use strict';

// Buddyevents controller
angular.module('buddyevents').controller('BuddyeventsController', ['$scope', '$stateParams', '$location', '$rootScope', 'Authentication', 'Buddyevents', 'Teams',
function($scope, $stateParams, $location, $rootScope, Authentication, Buddyevents, Teams) {
angular.module('buddyevents').controller('BuddyeventsController', ['$scope', '$stateParams', '$location', '$rootScope', 'Authentication', 'Buddyevents', 'Teams', 'AcitveTeamFactory',
function($scope, $stateParams, $location, $rootScope, Authentication, Buddyevents, Teams, AcitveTeamFactory) {
$scope.authentication = Authentication;

// Find a list of Teams
$scope.init = function() {
$scope.teams = Teams.query();

var teamId = AcitveTeamFactory.getActiveTeam();
if(teamId) {
$scope.team = Teams.get({
teamId: teamId
});
}
};

// Find existing Member
Expand Down Expand Up @@ -238,6 +244,29 @@ angular.module('core').controller('HomeController', ['$scope', 'Authentication',
]);
'use strict';

angular.module('core').directive('chooseTeam', ['Teams', 'AcitveTeamFactory', function(Teams, AcitveTeamFactory) {

return {
restrict: 'E',
templateUrl: 'modules/core/directives/core.client.chooseTeam.directive.html',

controller: ["$scope", "$element", function($scope, $element){
// Change Team by choosing one in the dropdown
$scope.changeTeam = function($event, _id) {
$event.preventDefault();

AcitveTeamFactory.setActiveTeam(_id);

$scope.team = Teams.get({
teamId: _id
});
};
}]
};

}]);
'use strict';

//Menu service used for managing menus
angular.module('core').service('Menus', [

Expand Down Expand Up @@ -404,6 +433,18 @@ angular.module('core').service('Menus', [
]);
'use strict';

angular.module('core').service('AcitveTeamFactory', ['Teams', function(Teams) {

this.setActiveTeam = function(id) {
this.activeTeam = id;
};
this.getActiveTeam = function() {
return this.activeTeam;
};

}]);
'use strict';

// Configuring the Members module
angular.module('members').run(['Menus',
function(Menus) {
Expand Down Expand Up @@ -433,22 +474,28 @@ angular.module('members').config(['$stateProvider',
templateUrl: 'modules/members/views/view-members.client.view.html'
}).
state('editMember', {
url: '/members/:memberId/edit',
url: '/team/:teamId/members/:memberId/edit',
templateUrl: 'modules/members/views/edit-members.client.view.html'
});
}
]);
'use strict';

// Teams controller
angular.module('members').controller('MembersController', ['$scope', '$stateParams', '$location', '$rootScope', 'Authentication', 'Teams', 'Members',
function($scope, $stateParams, $location, $rootScope, Authentication, Teams, Members) {
angular.module('members').controller('MembersController', ['$scope', '$stateParams', '$location', '$rootScope', 'Authentication', 'Teams', 'Members', 'AcitveTeamFactory',
function($scope, $stateParams, $location, $rootScope, Authentication, Teams, Members, AcitveTeamFactory) {
$scope.authentication = Authentication;

// Find a list of Teams
$scope.find = function() {
$scope.teams = Teams.query();

var teamId = AcitveTeamFactory.getActiveTeam();
if(teamId) {
$scope.team = Teams.get({
teamId: teamId
});
}
};

// Find existing Member
Expand All @@ -459,7 +506,6 @@ angular.module('members').controller('MembersController', ['$scope', '$statePara
});
};

// Update existing Team
$scope.add = function() {

//console.log(this.team);
Expand All @@ -483,6 +529,9 @@ angular.module('members').controller('MembersController', ['$scope', '$statePara
});
};

// Update existing Team


// Update existing Team
$scope.update = function() {
var member = $scope.member;
Expand Down Expand Up @@ -514,7 +563,10 @@ angular.module('members').controller('MembersController', ['$scope', '$statePara
// Change Team by choosing one in the dropdown
$scope.changeTeam = function($event, _id) {
$event.preventDefault();
$rootScope.team = Teams.get({

AcitveTeamFactory.setActiveTeam(_id);

$scope.team = Teams.get({
teamId: _id
});
};
Expand All @@ -523,11 +575,13 @@ angular.module('members').controller('MembersController', ['$scope', '$statePara
'use strict';

//Teams service used to communicate Teams REST endpoints
angular.module('members').factory('Members', ['$resource',
function($resource) {
return $resource('members/:memberId', { memberId: '@_id'
}, {
update: {
angular.module('members').factory('Members', ['$resource', function($resource) {

return $resource('members/:memberId',
{
memberId: '@_id'
}, {
update: {
method: 'PUT'
}
});
Expand Down Expand Up @@ -558,11 +612,11 @@ angular.module('teams').config(['$stateProvider',
templateUrl: 'modules/teams/views/create-team.client.view.html'
}).
state('viewTeam', {
url: '/teams/:teamId',
url: '/team/:teamId',
templateUrl: 'modules/teams/views/view-team.client.view.html'
}).
state('editTeam', {
url: '/teams/:teamId/edit',
url: '/team/:teamId/edit',
templateUrl: 'modules/teams/views/edit-team.client.view.html'
});
}
Expand Down Expand Up @@ -596,6 +650,30 @@ angular.module('teams').controller('TeamsController', ['$scope', '$stateParams',
});
};

// Update existing Team
$scope.add = function() {

//console.log(this.team);
var team = this.team;

var member = {
firstname: this.firstname,
lastname: this.lastname
};

team.members.push(member);

var _this = this;

team.$update(function() {
_this.firstname = '';
_this.lastname = '';

}, function(errorResponse) {
$scope.error = errorResponse.data.message;
});
};

// Remove existing Team
$scope.remove = function(team) {
if ( team ) {
Expand Down
8 changes: 8 additions & 0 deletions public/dist/application.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -6336,3 +6336,11 @@ body.ng-cloak {
.navbar li li a {
color: black;
}
.input-append {
position: relative;
}
.input-append .add-on {
position: absolute;
top: 8px;
right: 10px;
}
Loading

0 comments on commit cfc1523

Please sign in to comment.