Wrap task service in anon function

This commit is contained in:
Blade Barringer
2015-06-21 20:35:45 -05:00
parent 10c709a9f2
commit f5647ecd76

View File

@@ -1,16 +1,19 @@
'use strict'; 'use strict';
angular (function(){
var TASK_KEYS_TO_REMOVE = ['_id', 'completed', 'date', 'dateCompleted', 'dateCreated', 'history', 'id', 'streak'];
angular
.module('habitrpg') .module('habitrpg')
.factory('Tasks', tasksFactory); .factory('Tasks', tasksFactory);
tasksFactory.$inject = [ tasksFactory.$inject = [
'$rootScope', '$rootScope',
'Shared', 'Shared',
'User' 'User'
]; ];
function tasksFactory($rootScope, Shared, User) { function tasksFactory($rootScope, Shared, User) {
function editTask(task) { function editTask(task) {
task._editing = !task._editing; task._editing = !task._editing;
@@ -27,8 +30,7 @@ function tasksFactory($rootScope, Shared, User) {
} }
function _cleanUpTask(task) { function _cleanUpTask(task) {
var keysToRemove = ['_id', 'completed', 'date', 'dateCompleted', 'dateCreated', 'history', 'id', 'streak']; var cleansedTask = _.omit(task, TASK_KEYS_TO_REMOVE);
var cleansedTask = _.omit(task, keysToRemove);
// Copy checklists but reset to uncomplete and assign new id // Copy checklists but reset to uncomplete and assign new id
_(cleansedTask.checklist).forEach(function(item) { _(cleansedTask.checklist).forEach(function(item) {
@@ -47,4 +49,5 @@ function tasksFactory($rootScope, Shared, User) {
editTask: editTask, editTask: editTask,
cloneTask: cloneTask cloneTask: cloneTask
}; };
} }
})();