UX: Put links back in flags summaries in advance of refactor.
This commit is contained in:
parent
7eb6dca3ec
commit
300faa6744
|
@ -7,7 +7,8 @@ export default Ember.Component.extend(StringBuffer, {
|
||||||
actionsSummary: Em.computed.alias('post.actionsWithoutLikes'),
|
actionsSummary: Em.computed.alias('post.actionsWithoutLikes'),
|
||||||
emptySummary: Em.computed.empty('actionsSummary'),
|
emptySummary: Em.computed.empty('actionsSummary'),
|
||||||
hidden: Em.computed.and('emptySummary', 'post.notDeleted'),
|
hidden: Em.computed.and('emptySummary', 'post.notDeleted'),
|
||||||
rerenderTriggers: ['actionsSummary.@each', 'post.deleted'],
|
|
||||||
|
rerenderTriggers: ['actionsSummary.@each', 'actionsSummary.users.length', 'post.deleted'],
|
||||||
|
|
||||||
// This was creating way too many bound ifs and subviews in the handlebars version.
|
// This was creating way too many bound ifs and subviews in the handlebars version.
|
||||||
renderString(buffer) {
|
renderString(buffer) {
|
||||||
|
@ -21,15 +22,38 @@ export default Ember.Component.extend(StringBuffer, {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO multi line expansion for flags
|
// TODO multi line expansion for flags
|
||||||
buffer.push(c.get('description') + '.');
|
let iconsHtml = "";
|
||||||
|
if (c.get('usersExpanded')) {
|
||||||
|
let postUrl;
|
||||||
|
c.get('users').forEach(function(u) {
|
||||||
|
iconsHtml += "<a href=\"" + Discourse.getURL("/users/") + u.get('username_lower') + "\" data-user-card=\"" + u.get('username_lower') + "\">";
|
||||||
|
if (u.post_url) {
|
||||||
|
postUrl = postUrl || u.post_url;
|
||||||
|
}
|
||||||
|
iconsHtml += Discourse.Utilities.avatarImg({
|
||||||
|
size: 'small',
|
||||||
|
avatarTemplate: u.get('avatarTemplate'),
|
||||||
|
title: u.get('username')
|
||||||
|
});
|
||||||
|
iconsHtml += "</a>";
|
||||||
|
});
|
||||||
|
|
||||||
|
let key = 'post.actions.people.' + c.get('actionType.name_key');
|
||||||
|
if (postUrl) { key = key + "_with_url"; }
|
||||||
|
|
||||||
|
// TODO postUrl might be uninitialized? pick a good default
|
||||||
|
buffer.push(" " + I18n.t(key, { icons: iconsHtml, postUrl: postUrl}) + ".");
|
||||||
|
}
|
||||||
|
renderActionIf('usersCollapsed', 'who-acted', c.get('description'));
|
||||||
renderActionIf('can_undo', 'undo', I18n.t("post.actions.undo." + c.get('actionType.name_key')));
|
renderActionIf('can_undo', 'undo', I18n.t("post.actions.undo." + c.get('actionType.name_key')));
|
||||||
renderActionIf('can_defer_flags', 'defer-flags', I18n.t("post.actions.defer_flags", { count: c.count }));
|
renderActionIf('can_defer_flags', 'defer-flags', I18n.t("post.actions.defer_flags", { count: c.count }));
|
||||||
|
|
||||||
buffer.push("</div>");
|
buffer.push("</div>");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const post = this.get('post');
|
const post = this.get('post');
|
||||||
if (!post.get('deleted')) {
|
if (post.get('deleted')) {
|
||||||
buffer.push("<div class='post-action'>" +
|
buffer.push("<div class='post-action'>" +
|
||||||
iconHTML('fa-trash-o') + ' ' +
|
iconHTML('fa-trash-o') + ' ' +
|
||||||
Discourse.Utilities.tinyAvatar(post.get('postDeletedBy.avatar_template'), {title: post.get('postDeletedBy.username')}) +
|
Discourse.Utilities.tinyAvatar(post.get('postDeletedBy.avatar_template'), {title: post.get('postDeletedBy.username')}) +
|
||||||
|
@ -53,6 +77,12 @@ export default Ember.Component.extend(StringBuffer, {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User wants to know who actioned it
|
||||||
|
if (actionTypeId = $target.data('who-acted')) {
|
||||||
|
this.actionTypeById(actionTypeId).loadUsers(post);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (actionTypeId = $target.data('undo')) {
|
if (actionTypeId = $target.data('undo')) {
|
||||||
this.get('actionsSummary').findProperty('id', actionTypeId).undo(post);
|
this.get('actionsSummary').findProperty('id', actionTypeId).undo(post);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue