mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
Wrap task service in anon function
This commit is contained in:
@@ -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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user