mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Fixed adding and removing tags on tasks
This commit is contained in:
@@ -30,6 +30,7 @@ habitrpg.controller("FiltersCtrl", ['$scope', '$rootScope', 'User', 'Shared',
|
|||||||
} else {
|
} else {
|
||||||
user.filters[tag.id] = !user.filters[tag.id];
|
user.filters[tag.id] = !user.filters[tag.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
// no longer persisting this, it was causing a lot of confusion - users thought they'd permanently lost tasks
|
// no longer persisting this, it was causing a lot of confusion - users thought they'd permanently lost tasks
|
||||||
// Note: if we want to persist for just this computer, easy method is:
|
// Note: if we want to persist for just this computer, easy method is:
|
||||||
// User.save();
|
// User.save();
|
||||||
|
|||||||
@@ -33,9 +33,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||||||
var newTask = {
|
var newTask = {
|
||||||
text: task,
|
text: task,
|
||||||
type: listDef.type,
|
type: listDef.type,
|
||||||
// tags: _.transform(User.user.filters, function(m, v, k) {
|
tags: _.keys(User.user.filters),
|
||||||
// if (v) m.push(v);
|
|
||||||
// }),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
User.addTask({body: newTask});
|
User.addTask({body: newTask});
|
||||||
@@ -272,4 +270,21 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||||||
$rootScope.playSound('Reward');
|
$rootScope.playSound('Reward');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
------------------------
|
||||||
|
Tags
|
||||||
|
------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
$scope.updateTaskTags = function (tagId, task) {
|
||||||
|
var tagIndex = task.tags.indexOf(tagId);
|
||||||
|
if (tagIndex === -1) {
|
||||||
|
Tasks.addTagToTask(task._id, tagId);
|
||||||
|
task.tags.push(tagId);
|
||||||
|
} else {
|
||||||
|
Tasks.removeTagFromTask(task._id, tagId);
|
||||||
|
task.tags.splice(tagIndex, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fieldset.option-group(ng-if='!$state.includes("options.social.challenges")')
|
fieldset.option-group(ng-if='!$state.includes("options.social.challenges")')
|
||||||
p.option-title.mega(ng-class='{active: task._tags}', ng-click='task._tags = !task._tags', tooltip=env.t('expandCollapse'))=env.t('tags')
|
p.option-title.mega(ng-class='{active: task._tags}', ng-click='task._tags = !task._tags', tooltip=env.t('expandCollapse'))=env.t('tags')
|
||||||
label.checkbox(ng-repeat='tag in user.tags', ng-if='task._tags')
|
label.checkbox(ng-repeat='tag in user.tags', ng-if='task._tags')
|
||||||
input(type='checkbox', ng-model='task.tags[tag.id]', ng-checked="task.tags.indexOf(tag.id) !== -1")
|
input(type='checkbox', ng-checked="task.tags.indexOf(tag.id) !== -1", ng-click="updateTaskTags(tag.id, task)")
|
||||||
markdown(text='tag.name')
|
markdown(text='tag.name')
|
||||||
|
|||||||
Reference in New Issue
Block a user