more work on flags detail pages (#5232)

v1.18.x
Julian Lam 8 years ago
parent 0bf82c0e47
commit fceb5cc86b

@ -1,7 +1,13 @@
{ {
"quick-filters": "Quick Filters", "quick-filters": "Quick Filters",
"state": "State", "state": "State",
"reporter": "Reporter", "reporter": "Reporter",
"reported-at": "Reported At", "reported-at": "Reported At",
"no-flags": "Hooray! No flags found." "no-flags": "Hooray! No flags found.",
"state": "State",
"state-open": "New/Open",
"state-wip": "Work in Progress",
"state-resolved": "Resolved",
"state-rejected": "Rejected"
} }

@ -41,11 +41,6 @@
"flag_manage_history": "Action History", "flag_manage_history": "Action History",
"flag_manage_no_history": "No event history to report", "flag_manage_no_history": "No event history to report",
"flag_manage_assignee": "Assignee", "flag_manage_assignee": "Assignee",
"flag_manage_state": "State",
"flag_manage_state_open": "New/Open",
"flag_manage_state_wip": "Work in Progress",
"flag_manage_state_resolved": "Resolved",
"flag_manage_state_rejected": "Rejected",
"flag_manage_notes": "Shared Notes", "flag_manage_notes": "Shared Notes",
"flag_manage_update": "Update Flag Status", "flag_manage_update": "Update Flag Status",
"flag_manage_history_assignee": "Assigned to %1", "flag_manage_history_assignee": "Assigned to %1",

@ -20,21 +20,30 @@ var Flags = {
Flags.get = function (flagId, callback) { Flags.get = function (flagId, callback) {
async.waterfall([ async.waterfall([
// First stage
async.apply(async.parallel, { async.apply(async.parallel, {
base: async.apply(db.getObject.bind(db), 'flag:' + flagId), base: async.apply(db.getObject.bind(db), 'flag:' + flagId),
history: async.apply(db.getSortedSetRevRange.bind(db), 'flag:' + flagId + ':history', 0, -1), history: async.apply(db.getSortedSetRevRange.bind(db), 'flag:' + flagId + ':history', 0, -1),
notes: async.apply(db.getSortedSetRevRange.bind(db), 'flag:' + flagId + ':notes', 0, -1) notes: async.apply(db.getSortedSetRevRange.bind(db), 'flag:' + flagId + ':notes', 0, -1)
}), }),
function (data, next) { function (data, next) {
user.getUserFields(data.base.uid, ['username', 'picture'], function (err, userObj) { // Second stage
async.parallel({
userObj: async.apply(user.getUserFields, data.base.uid, ['username', 'picture']),
targetObj: async.apply(Flags.getTarget, data.base.type, data.base.targetId, data.base.uid)
}, function (err, payload) {
// Final object return construction
next(err, Object.assign(data.base, { next(err, Object.assign(data.base, {
datetimeISO: new Date(data.base.datetime).toISOString(),
target_readable: data.base.type.charAt(0).toUpperCase() + data.base.type.slice(1) + ' ' + data.base.targetId,
target: payload.targetObj,
history: data.history, history: data.history,
notes: data.notes, notes: data.notes,
reporter: { reporter: {
username: userObj.username, username: payload.userObj.username,
picture: userObj.picture, picture: payload.userObj.picture,
'icon:bgColor': userObj['icon:bgColor'], 'icon:bgColor': payload.userObj['icon:bgColor'],
'icon:text': userObj['icon:text'] 'icon:text': payload.userObj['icon:text']
} }
})); }));
}); });
@ -102,6 +111,25 @@ Flags.list = function (filters, callback) {
}); });
}; };
Flags.getTarget = function (type, id, uid, callback) {
switch (type) {
case 'post':
async.waterfall([
async.apply(posts.getPostsByPids, [id], uid),
function (posts, next) {
topics.addPostData(posts, uid, next);
}
], function (err, posts) {
callback(err, posts[0]);
});
break;
case 'user':
user.getUsersData(id, callback);
break;
}
};
Flags.create = function (type, id, uid, reason, callback) { Flags.create = function (type, id, uid, reason, callback) {
async.waterfall([ async.waterfall([
function (next) { function (next) {

Loading…
Cancel
Save