FEATURE: Filter reviewables by assigned user (#58)
This commit is contained in:
parent
434605f03f
commit
3593f9ef67
|
@ -0,0 +1,16 @@
|
||||||
|
<div class='reviewable-filter discourse-assign-assign-to-filter'>
|
||||||
|
<label class='filter-label'>{{i18n "discourse_assign.assigned_to"}}</label>
|
||||||
|
{{user-selector
|
||||||
|
single=true
|
||||||
|
fullWidthWrap=true
|
||||||
|
allowAny=false
|
||||||
|
group="staff"
|
||||||
|
groupMembersOf=allowedGroups
|
||||||
|
excludeCurrentUser=false
|
||||||
|
includeMentionableGroups=false
|
||||||
|
hasGroups=false
|
||||||
|
usernames=additionalFilters.assigned_to
|
||||||
|
placeholderKey=placeholderKey
|
||||||
|
autocomplete="off"
|
||||||
|
}}
|
||||||
|
</div>
|
|
@ -0,0 +1,13 @@
|
||||||
|
export default {
|
||||||
|
shouldRender(args) {
|
||||||
|
return args.additionalFilters;
|
||||||
|
},
|
||||||
|
|
||||||
|
setupComponent(args, component) {
|
||||||
|
const groupIDs = component.siteSettings.assign_allowed_on_groups.split("|");
|
||||||
|
const groupNames = this.site.groups
|
||||||
|
.filter(group => groupIDs.includes(group.id.toString()))
|
||||||
|
.map(group => group.name);
|
||||||
|
component.set("allowedGroups", groupNames);
|
||||||
|
}
|
||||||
|
};
|
21
plugin.rb
21
plugin.rb
|
@ -268,6 +268,27 @@ after_initialize do
|
||||||
id && id.to_i rescue nil
|
id && id.to_i rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: Remove this when 2.4 becomes the new stable
|
||||||
|
if self.respond_to?(:add_custom_reviewable_filter)
|
||||||
|
add_custom_reviewable_filter(
|
||||||
|
[
|
||||||
|
:assigned_to,
|
||||||
|
Proc.new do |results, value|
|
||||||
|
results.joins(<<~SQL
|
||||||
|
INNER JOIN posts p ON p.id = target_id
|
||||||
|
INNER JOIN topics t ON t.id = p.topic_id
|
||||||
|
INNER JOIN topic_custom_fields tcf ON tcf.topic_id = t.id
|
||||||
|
INNER JOIN users u ON u.id = tcf.value::integer
|
||||||
|
SQL
|
||||||
|
)
|
||||||
|
.where(target_type: Post.name)
|
||||||
|
.where('tcf.name = ?', TopicAssigner::ASSIGNED_TO_ID)
|
||||||
|
.where('u.username = ?', value)
|
||||||
|
end
|
||||||
|
]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
on(:post_created) do |post|
|
on(:post_created) do |post|
|
||||||
::TopicAssigner.auto_assign(post, force: true)
|
::TopicAssigner.auto_assign(post, force: true)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue