mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-04 14:50:47 +01:00
more work on flags detail pages (#5232)
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
{
|
||||
"quick-filters": "Quick Filters",
|
||||
"state": "State",
|
||||
"reporter": "Reporter",
|
||||
"reported-at": "Reported At",
|
||||
"no-flags": "Hooray! No flags found."
|
||||
"quick-filters": "Quick Filters",
|
||||
"state": "State",
|
||||
"reporter": "Reporter",
|
||||
"reported-at": "Reported At",
|
||||
"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_no_history": "No event history to report",
|
||||
"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_update": "Update Flag Status",
|
||||
"flag_manage_history_assignee": "Assigned to %1",
|
||||
|
||||
38
src/flags.js
38
src/flags.js
@@ -20,21 +20,30 @@ var Flags = {
|
||||
|
||||
Flags.get = function (flagId, callback) {
|
||||
async.waterfall([
|
||||
// First stage
|
||||
async.apply(async.parallel, {
|
||||
base: async.apply(db.getObject.bind(db), 'flag:' + flagId),
|
||||
history: async.apply(db.getSortedSetRevRange.bind(db), 'flag:' + flagId + ':history', 0, -1),
|
||||
notes: async.apply(db.getSortedSetRevRange.bind(db), 'flag:' + flagId + ':notes', 0, -1)
|
||||
}),
|
||||
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, {
|
||||
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,
|
||||
notes: data.notes,
|
||||
reporter: {
|
||||
username: userObj.username,
|
||||
picture: userObj.picture,
|
||||
'icon:bgColor': userObj['icon:bgColor'],
|
||||
'icon:text': userObj['icon:text']
|
||||
username: payload.userObj.username,
|
||||
picture: payload.userObj.picture,
|
||||
'icon:bgColor': payload.userObj['icon:bgColor'],
|
||||
'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) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
|
||||
Reference in New Issue
Block a user