FEATURE: New site setting to ensure flags are claimed
This commit is contained in:
parent
d657fc0632
commit
569a87b136
|
@ -1,12 +1,20 @@
|
||||||
{{#unless canAct}}
|
{{#unless canAct}}
|
||||||
{{#if flaggedPost.topic.assigned_to_user}}
|
{{#if actableFilter}}
|
||||||
<div class='cant-act-flagged-post'>
|
{{#if flaggedPost.topic.assigned_to_user}}
|
||||||
<div class='cant-act-message'>
|
<div class='cant-act-flagged-post'>
|
||||||
{{i18n "discourse_assign.cant_act"}}
|
<div class='cant-act-message'>
|
||||||
|
{{i18n "discourse_assign.cant_act"}}
|
||||||
|
</div>
|
||||||
|
<div class='assigned-to'>
|
||||||
|
{{assigned-to user=flaggedPost.topic.assigned_to_user}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='assigned-to'>
|
{{else}}
|
||||||
{{assigned-to user=flaggedPost.topic.assigned_to_user}}
|
<div class='cant-act-flagged-post'>
|
||||||
|
<div class='cant-act-message'>
|
||||||
|
{{i18n "discourse_assign.cant_act_unclaimed"}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
|
@ -40,13 +40,26 @@ function modifySelectKit(api) {
|
||||||
function initialize(api) {
|
function initialize(api) {
|
||||||
// You can't act on flags claimed by another user
|
// You can't act on flags claimed by another user
|
||||||
api.modifyClass('component:flagged-post', {
|
api.modifyClass('component:flagged-post', {
|
||||||
@computed('flaggedPost.topic.assigned_to_user_id', 'filter')
|
@computed('flaggedPost.topic.assigned_to_user_id')
|
||||||
canAct(assignedToUserId, filter) {
|
canAct(assignedToUserId) {
|
||||||
if (this.siteSettings.assign_locks_flags && assignedToUserId && this.currentUser.id !== assignedToUserId) {
|
let { siteSettings } = this;
|
||||||
return false;
|
|
||||||
|
if (siteSettings.assign_locks_flags) {
|
||||||
|
|
||||||
|
let unassigned = (this.currentUser.id !== assignedToUserId);
|
||||||
|
|
||||||
|
// Can never act on another user's flags
|
||||||
|
if (assignedToUserId && unassigned) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If flags require assignment
|
||||||
|
if (this.siteSettings.flags_require_assign && unassigned) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._super(filter);
|
return this.get('actableFilter');
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ en:
|
||||||
unassigned: "unassigned %{who} %{when}"
|
unassigned: "unassigned %{who} %{when}"
|
||||||
discourse_assign:
|
discourse_assign:
|
||||||
cant_act: "You cannot act on flags that have been assigned to other users"
|
cant_act: "You cannot act on flags that have been assigned to other users"
|
||||||
|
cant_act_unclaimed: "You must claim this topic before acting on flags."
|
||||||
assigned: "Assigned"
|
assigned: "Assigned"
|
||||||
assigned_to: "Assigned to"
|
assigned_to: "Assigned to"
|
||||||
assign_notification: "<i title='assigned' class='fa fa-user-plus'></i><p><span>{{username}}</span> {{description}}</p>"
|
assign_notification: "<i title='assigned' class='fa fa-user-plus'></i><p><span>{{username}}</span> {{description}}</p>"
|
||||||
|
|
|
@ -11,11 +11,13 @@ en:
|
||||||
unassign_on_close: "When a topic is closed unassign topic"
|
unassign_on_close: "When a topic is closed unassign topic"
|
||||||
assign_locks_flags: "When a topic is assigned to a staff member, its flags can only be handled by that person"
|
assign_locks_flags: "When a topic is assigned to a staff member, its flags can only be handled by that person"
|
||||||
assign_mailer_enabled: "When enabled, the assigned user will receive a notification email on each assignment"
|
assign_mailer_enabled: "When enabled, the assigned user will receive a notification email on each assignment"
|
||||||
|
flags_require_assign: "When enabled, flags cannot be handled unless assigned to a user."
|
||||||
discourse_assign:
|
discourse_assign:
|
||||||
assigned_to: "Topic assigned to @%{username}"
|
assigned_to: "Topic assigned to @%{username}"
|
||||||
unassigned: "Topic was unassigned"
|
unassigned: "Topic was unassigned"
|
||||||
already_claimed: "That topic has already been claimed."
|
already_claimed: "That topic has already been claimed."
|
||||||
flag_assigned: "Sorry, flag's topic is assigned to another user"
|
flag_assigned: "Sorry, that flag's topic is assigned to another user"
|
||||||
|
flag_unclaimed: "You must claim that topic before acting on the flag"
|
||||||
assign_mailer:
|
assign_mailer:
|
||||||
title: "Assign Mailer"
|
title: "Assign Mailer"
|
||||||
subject_template: "[%{email_prefix}] %{assignee_name} assigned you to '%{topic_title}'!"
|
subject_template: "[%{email_prefix}] %{assignee_name} assigned you to '%{topic_title}'!"
|
||||||
|
|
|
@ -15,4 +15,7 @@ plugins:
|
||||||
assign_locks_flags:
|
assign_locks_flags:
|
||||||
default: true
|
default: true
|
||||||
client: true
|
client: true
|
||||||
|
flags_require_assign:
|
||||||
|
default: false
|
||||||
|
client: true
|
||||||
assign_mailer_enabled: false
|
assign_mailer_enabled: false
|
||||||
|
|
|
@ -21,6 +21,7 @@ after_initialize do
|
||||||
# not assigned to them
|
# not assigned to them
|
||||||
DiscourseEvent.on(:before_staff_flag_action) do |args|
|
DiscourseEvent.on(:before_staff_flag_action) do |args|
|
||||||
if SiteSetting.assign_locks_flags?
|
if SiteSetting.assign_locks_flags?
|
||||||
|
|
||||||
if custom_fields = args[:post].topic.custom_fields
|
if custom_fields = args[:post].topic.custom_fields
|
||||||
if assigned_to_id = custom_fields['assigned_to_id']
|
if assigned_to_id = custom_fields['assigned_to_id']
|
||||||
unless assigned_to_id.to_i == args[:user].id
|
unless assigned_to_id.to_i == args[:user].id
|
||||||
|
@ -30,8 +31,15 @@ after_initialize do
|
||||||
custom_message: 'discourse_assign.flag_assigned'
|
custom_message: 'discourse_assign.flag_assigned'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
elsif SiteSetting.flags_require_assign?
|
||||||
|
raise Discourse::InvalidAccess.new(
|
||||||
|
"Flags must be assigned before they can be acted on",
|
||||||
|
nil,
|
||||||
|
custom_message: 'discourse_assign.flag_unclaimed'
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue