UX: display small action for assignment/unassignment

This commit is contained in:
Sam 2017-03-07 17:13:10 -05:00
parent 84f4c30c34
commit bd5575d975
3 changed files with 18 additions and 9 deletions

View File

@ -55,6 +55,14 @@ function initialize(api, container) {
}); });
api.addPostSmallActionIcon('assigned','user-plus'); api.addPostSmallActionIcon('assigned','user-plus');
api.addPostSmallActionIcon('unassigned','user-times');
api.addPostTransformCallback((transformed) => {
if (transformed.actionCode === "assigned" || transformed.actionCode === "unassigned") {
transformed.isSmallAction = true;
transformed.canEdit = false;
}
});
api.addDiscoveryQueryParam('assigned', {replace: true, refreshModel: true}); api.addDiscoveryQueryParam('assigned', {replace: true, refreshModel: true});
@ -96,7 +104,7 @@ function initialize(api, container) {
export default { export default {
name: 'extend-for-assign', name: 'extend-for-assign',
initialize(container) { initialize(container) {
withPluginApi('0.8.3', api => { withPluginApi('0.8.5', api => {
initialize(api, container); initialize(api, container);
}); });
} }

View File

@ -1,7 +1,8 @@
en: en:
js: js:
action_codes: action_codes:
assigned: "assigned" assigned: "assigned %{who} %{when}"
unassigned: "unassigned %{who} %{when}"
discourse_assign: discourse_assign:
assigned: "Assigned" assigned: "Assigned"
assign_html: "<p class='assigned-to'><i class='fa-user-plus fa'></i> Assigned to {{userLink}}</p>" assign_html: "<p class='assigned-to'><i class='fa-user-plus fa'></i> Assigned to {{userLink}}</p>"

View File

@ -131,12 +131,12 @@ SQL
post_type = SiteSetting.assigns_public ? Post.types[:small_action] : Post.types[:whisper] post_type = SiteSetting.assigns_public ? Post.types[:small_action] : Post.types[:whisper]
unless silent unless silent
@topic.add_moderator_post(@assigned_by, @topic.add_moderator_post(@assigned_by, nil,
I18n.t('discourse_assign.assigned_to',
username: assign_to.username),
{ bump: false, { bump: false,
post_type: post_type, post_type: post_type,
action_code: "assigned"}) action_code: "assigned",
custom_fields: {"action_code_who" => assign_to.username}
})
unless @assigned_by.id == assign_to.id unless @assigned_by.id == assign_to.id
@ -183,11 +183,11 @@ SQL
if SiteSetting.unassign_creates_tracking_post && !silent if SiteSetting.unassign_creates_tracking_post && !silent
post_type = SiteSetting.assigns_public ? Post.types[:small_action] : Post.types[:whisper] post_type = SiteSetting.assigns_public ? Post.types[:small_action] : Post.types[:whisper]
@topic.add_moderator_post(@assigned_by, @topic.add_moderator_post(@assigned_by, nil,
I18n.t('discourse_assign.unassigned'),
{ bump: false, { bump: false,
post_type: post_type, post_type: post_type,
action_code: "assigned"}) custom_fields: {"action_code_who" => assigned_user&.username},
action_code: "unassigned"})
end end
end end
end end