mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
[#1444] add filters back to use schema. Allow editing of top-level tags
object in PUT /user, WARNING! We want to get away from that ASAP and instead have a nested resource for managing tags. Set default task tags if not present, will revisit after tasks are a subdoc too
This commit is contained in:
@@ -57,7 +57,7 @@ var UserSchema = new Schema({
|
||||
dailyIds: Array,
|
||||
todoIds: Array,
|
||||
rewardIds: Array,
|
||||
/* Removed `filters`, no longer persisting to the database*/
|
||||
filters: {type: Schema.Types.Mixed, 'default': {}},
|
||||
|
||||
flags: {
|
||||
ads: String,
|
||||
@@ -218,6 +218,7 @@ function transformTaskLists(doc) {
|
||||
_.each(['habit', 'daily', 'todo', 'reward'], function(type) {
|
||||
// we use _.transform instead of a simple _.where in order to maintain sort-order
|
||||
doc[type + "s"] = _.reduce(doc[type + "Ids"], function(m, tid) {
|
||||
if (!doc.tasks[tid].tags) doc.tasks[tid].tags = {}; // FIXME remove this when we switch tasks to subdocs and can define tags default in schema
|
||||
m.push(doc.tasks[tid]);
|
||||
return m;
|
||||
}, []);
|
||||
@@ -238,7 +239,7 @@ UserSchema.methods.toJSON = function() {
|
||||
delete doc["#{type}Ids"]
|
||||
});
|
||||
delete doc.tasks
|
||||
doc.filters = {};
|
||||
//doc.filters = {};
|
||||
|
||||
return doc;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user