blob: 62cca06bf5e797ee4dd2323ac363fc032d631e64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# frozen_string_literal: true
# WorkItem model inherits from Issue model. It's planned to be its extension
# with widgets support. Because WorkItems are internally Issues, WorkItemsFinder
# can be almost identical to IssuesFinder, except it should return instances of
# WorkItems instead of Issues
module WorkItems
class WorkItemsFinder < IssuesFinder
def params_class
::IssuesFinder::Params
end
private
def filter_items(items)
items = super(items)
by_widgets(items)
end
def by_widgets(items)
WorkItems::Type.available_widgets.each do |widget_class|
widget_filter = widget_filter_for(widget_class)
next unless widget_filter
items = widget_filter.filter(items, params)
end
items
end
def widget_filter_for(widget_class)
"WorkItems::Widgets::Filters::#{widget_class.name.demodulize.camelize}".constantize
rescue NameError
nil
end
def model_class
WorkItem
end
end
end
|