Skip to content

Commit

Permalink
#4 enhanced filter test
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Birkner committed Oct 20, 2014
1 parent 024d17e commit 2266eec
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 85 deletions.
19 changes: 11 additions & 8 deletions client/js/controller/skill_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,20 @@
if (employee.skills == null) {
employee.skills = [];
}
employee.skills.push(this.skill);
if( this.skill.length > 0 ) {
employee.skills.push(this.skill);

$http.post(url + '/api/mongo/employees/' + employee._id + '/skills', JSON.stringify(employee));
$http.post(url + '/api/mongo/employees/' + employee._id + '/skills', JSON.stringify(employee));

// TODO: get userid from session
var user = 'jon';
var msg = 'added skill';
var activity = {timestamp: new Date(), subject: user, action: msg, object: this.skill};
$http.post(url + '/api/mongo/activities', JSON.stringify(activity));
// TODO: get userid from session
var user = 'jon';
var msg = 'added skill';
var activity = {timestamp: new Date(), subject: user, action: msg, object: this.skill};
$http.post(url + '/api/mongo/activities', JSON.stringify(activity));

this.skill = '';
}

this.skill = '';
};

});
Expand Down
10 changes: 9 additions & 1 deletion client/js/filters/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@

angular.module('project-staffing').filter('firstLetterUppercase', function() {
return function(input) {
return input.charAt(0).toUpperCase() + input.slice(1);
if( input.length === 0 ) {
return '';
}
var array = input.split(/[ ]+/);
var result = '';
for(var i = 0; i < array.length; i++) {
result += array[i].charAt(0).toUpperCase() + array[i].slice(1) + ' ';
}
return result.trim();
};
});

Expand Down
156 changes: 83 additions & 73 deletions static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,19 +533,22 @@
if (employee.skills == null) {
employee.skills = [];
}
employee.skills.push(this.skill);
if( this.skill.length > 0 ) {
employee.skills.push(this.skill);

$http.post(url + '/api/mongo/employees/' + employee._id + '/skills', JSON.stringify(employee));
$http.post(url + '/api/mongo/employees/' + employee._id + '/skills', JSON.stringify(employee));

// TODO: get userid from session
var user = 'jon';
var msg = 'added skill';
var activity = {timestamp: new Date(), subject: user, action: msg, object: this.skill};
$http.post(url + '/api/mongo/activities', JSON.stringify(activity));
// TODO: get userid from session
var user = 'jon';
var msg = 'added skill';
var activity = {timestamp: new Date(), subject: user, action: msg, object: this.skill};
$http.post(url + '/api/mongo/activities', JSON.stringify(activity));

this.skill = '';
}

this.skill = '';
};

});

})();
Expand Down Expand Up @@ -727,6 +730,77 @@

})();

(function() {
'use strict';

angular.module('project-staffing').filter('firstLetterUppercase', function() {
return function(input) {
if( input.length === 0 ) {
return '';
}
var array = input.split(/[ ]+/);
var result = '';
for(var i = 0; i < array.length; i++) {
result += array[i].charAt(0).toUpperCase() + array[i].slice(1) + ' ';
}
return result.trim();
};
});

})();
(function() {
'use strict';

angular
.module('project-staffing')
.config(function($routeProvider) {
$routeProvider.when('/', {
templateUrl: 'views/index.html',
})
.when('/timeline', {
templateUrl: 'views/timeline.html',
controller: 'TimelineController',
controllerAs: 'timelineCtrl',
})
.when('/dashboard', {
templateUrl: 'views/dashboard.html',
controller: 'DashboardController',
controllerAs: 'dashboardCtrl',
})
.when('/list-employees', {
templateUrl: 'views/list_employees.html',
controller: 'EmployeeController',
controllerAs: 'employeeCtrl',
})
.when('/add-employee', {
templateUrl: 'views/add_employee.html',
controller: 'EmployeeController',
controllerAs: 'employeeCtrl',
})
.when('/list-customers', {
templateUrl: 'views/list_customers.html',
controller: 'CustomerController',
controllerAs: 'customerCtrl',
})
.when('/staffing', {
templateUrl: 'views/staff_project.html',
controller: 'StaffingController',
controllerAs: 'staffingCtrl',
})
.when('/add-customer', {
templateUrl: 'views/add_customer.html',
controller: 'CustomerController',
controllerAs: 'customerCtrl',
})
.when('/help', {
templateUrl: 'views/help.html',
})
.otherwise({
redirectTo: '/',
});
});
})();

(function(){
'use strict';

Expand Down Expand Up @@ -793,67 +867,3 @@
};
});
})();

(function() {
'use strict';

angular.module('project-staffing').filter('firstLetterUppercase', function() {
return function(input) {
return input.charAt(0).toUpperCase() + input.slice(1);
};
});

})();

(function() {
'use strict';

angular
.module('project-staffing')
.config(function($routeProvider) {
$routeProvider.when('/', {
templateUrl: 'views/index.html',
})
.when('/timeline', {
templateUrl: 'views/timeline.html',
controller: 'TimelineController',
controllerAs: 'timelineCtrl',
})
.when('/dashboard', {
templateUrl: 'views/dashboard.html',
controller: 'DashboardController',
controllerAs: 'dashboardCtrl',
})
.when('/list-employees', {
templateUrl: 'views/list_employees.html',
controller: 'EmployeeController',
controllerAs: 'employeeCtrl',
})
.when('/add-employee', {
templateUrl: 'views/add_employee.html',
controller: 'EmployeeController',
controllerAs: 'employeeCtrl',
})
.when('/list-customers', {
templateUrl: 'views/list_customers.html',
controller: 'CustomerController',
controllerAs: 'customerCtrl',
})
.when('/staffing', {
templateUrl: 'views/staff_project.html',
controller: 'StaffingController',
controllerAs: 'staffingCtrl',
})
.when('/add-customer', {
templateUrl: 'views/add_customer.html',
controller: 'CustomerController',
controllerAs: 'customerCtrl',
})
.when('/help', {
templateUrl: 'views/help.html',
})
.otherwise({
redirectTo: '/',
});
});
})();
Loading

0 comments on commit 2266eec

Please sign in to comment.