Class: RedmineExtensions::QueryOutput
- Inherits:
-
Object
- Object
- RedmineExtensions::QueryOutput
show all
- Defined in:
- lib/redmine_extensions/query_output.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(query_presenter, outputs = nil) ⇒ QueryOutput
Returns a new instance of QueryOutput.
41
42
43
44
|
# File 'lib/redmine_extensions/query_output.rb', line 41
def initialize(query_presenter, outputs=nil)
@query = query_presenter
@outputs = outputs || query_presenter.outputs
end
|
Instance Attribute Details
Returns the value of attribute query.
4
5
6
|
# File 'lib/redmine_extensions/query_output.rb', line 4
def query
@query
end
|
Class Method Details
.available_for?(query) ⇒ Boolean
Take query and decide if it is possible to render it by this output
37
38
39
|
# File 'lib/redmine_extensions/query_output.rb', line 37
def self.available_for?(query)
query.class > Query
end
|
.available_output_klasses_for(query) ⇒ Object
21
22
23
24
25
|
# File 'lib/redmine_extensions/query_output.rb', line 21
def self.available_output_klasses_for(query)
registered_outputs.select do |name, output|
output.available_for?(query)
end.values
end
|
.available_outputs_for(query) ⇒ Object
15
16
17
18
19
|
# File 'lib/redmine_extensions/query_output.rb', line 15
def self.available_outputs_for(query)
registered_outputs.select do |name, output|
output.available_for?(query)
end.keys
end
|
31
32
33
|
# File 'lib/redmine_extensions/query_output.rb', line 31
def self.key
self.name.split('::').last.sub(/Output$/, '').underscore
end
|
.output_klass_for(output) ⇒ Object
27
28
29
|
# File 'lib/redmine_extensions/query_output.rb', line 27
def self.output_klass_for(output)
registered_outputs[output.to_sym]
end
|
.register_output(klass, options = {}) ⇒ Object
7
8
9
|
# File 'lib/redmine_extensions/query_output.rb', line 7
def self.register_output(klass, options={})
registered_outputs[klass.key.to_sym] = klass
end
|
.registered_outputs ⇒ Object
11
12
13
|
# File 'lib/redmine_extensions/query_output.rb', line 11
def self.registered_outputs
@@registered_outputs ||= {}
end
|
Instance Method Details
#data_partial ⇒ Object
46
47
48
|
# File 'lib/redmine_extensions/query_output.rb', line 46
def data_partial
'easy_queries/easy_query_'+key
end
|
103
104
105
|
# File 'lib/redmine_extensions/query_output.rb', line 103
def edit_form
'easy_queries/form_'+key+'_settings'
end
|
#enabled? ⇒ Boolean
66
67
68
|
# File 'lib/redmine_extensions/query_output.rb', line 66
def enabled?
@outputs.output_enabled?(key)
end
|
107
108
109
|
# File 'lib/redmine_extensions/query_output.rb', line 107
def h
@outputs.view_context
end
|
74
75
76
77
|
# File 'lib/redmine_extensions/query_output.rb', line 74
def
content = options["#{key}_header".to_sym]
h.content_tag(:h3, content.html_safe) unless content.blank?
end
|
58
59
60
|
# File 'lib/redmine_extensions/query_output.rb', line 58
def key
self.class.key
end
|
62
63
64
|
# File 'lib/redmine_extensions/query_output.rb', line 62
def label
h.l('label_easy_query_output.'+key, default: key.humanize)
end
|
50
51
52
|
# File 'lib/redmine_extensions/query_output.rb', line 50
def order
10
end
|
#render_data ⇒ Object
54
55
56
|
# File 'lib/redmine_extensions/query_output.rb', line 54
def render_data
h.render partial: data_partial, locals: variables
end
|
#render_edit(action = 'edit') ⇒ Object
93
94
95
96
97
|
# File 'lib/redmine_extensions/query_output.rb', line 93
def render_edit(action='edit')
h.content_tag(:fieldset, class: "easy-query-filters-field #{key}_settings", style: ('display: none;' unless enabled? )) do
h.content_tag(:legend, label) + render_edit_form(action)
end
end
|
#render_edit_box(style = :check_box, options = {}) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/redmine_extensions/query_output.rb', line 79
def render_edit_box(style=:check_box, options={})
raise 'Style of edit box is not allowed' unless [:check_box, :radio_button].include?(style)
box_id = "#{query.modul_uniq_id}output_#{key}"
options[:class] = "#{options[:class]} #{query.modul_uniq_id}output_switch #{query.modul_uniq_id}content_switch"
options[:enabled] = enabled? unless options.key?(:enabled)
r = ''
r << h.send("#{style}_tag" , query.block_name.blank? ? 'outputs[]' : "#{query.block_name}[outputs][]", key, options[:enabled], id: box_id, class: options[:class])
r << h.label_tag(box_id, h.l('label_my_page_issue_output.' + key), :class => 'inline')
r.html_safe
end
|
99
100
101
|
# File 'lib/redmine_extensions/query_output.rb', line 99
def render_edit_form(action='edit')
h.render(self.edit_form, options.reverse_merge(query: query, modul_uniq_id: query.modul_uniq_id, block_name: query.block_name, action: action, page_module: query.page_module))
end
|
#variables ⇒ Object
70
71
72
|
# File 'lib/redmine_extensions/query_output.rb', line 70
def variables
options.reverse_merge(query: @query, output: self)
end
|