redmine_extensions 0.0.39 → 0.1.01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/redmine_extensions/redmine_extensions.js +30 -59
- data/app/controllers/easy_settings_controller.rb +1 -1
- data/app/helpers/redmine_extensions/application_helper.rb +108 -65
- data/app/helpers/redmine_extensions/rendering_helper.rb +5 -0
- data/app/presenters/easy_query_adapter_presenter.rb +50 -0
- data/app/views/common/_collapsible_module_layout.html.erb +13 -0
- data/app/views/easy_entity_assignments/_assignments_container.html.erb +10 -15
- data/app/views/easy_entity_assignments/_query_index.html.erb +2 -10
- data/app/views/easy_queries/_easy_query_tile.html.erb +7 -0
- data/app/views/easy_settings/edit.html.erb +1 -1
- data/config/routes.rb +3 -7
- data/lib/generators/redmine_extensions/entity/templates/_form.html.erb.erb +1 -1
- data/lib/generators/redmine_extensions/entity/templates/_sidebar.html.erb.erb +8 -8
- data/lib/generators/redmine_extensions/entity/templates/context_menu.html.erb.erb +7 -7
- data/lib/generators/redmine_extensions/entity/templates/custom_field.rb.erb +7 -7
- data/lib/generators/redmine_extensions/entity/templates/edit.html.erb.erb +16 -16
- data/lib/generators/redmine_extensions/entity/templates/index.api.rsb.erb +5 -5
- data/lib/generators/redmine_extensions/entity/templates/index.html.erb.erb +4 -4
- data/lib/generators/redmine_extensions/entity/templates/mail_added.html.erb.erb +1 -1
- data/lib/generators/redmine_extensions/entity/templates/mail_added.text.erb.erb +2 -2
- data/lib/generators/redmine_extensions/entity/templates/mail_updated.text.erb.erb +2 -2
- data/lib/generators/redmine_extensions/entity/templates/migration.rb.erb +9 -9
- data/lib/generators/redmine_extensions/entity/templates/new.html.erb.erb +16 -16
- data/lib/generators/redmine_extensions/entity/templates/query.rb.erb +1 -1
- data/lib/generators/redmine_extensions/entity/templates/routes.rb.erb +12 -12
- data/lib/generators/redmine_extensions/entity/templates/show.html.erb.erb +37 -37
- data/lib/redmine_extensions/easy_query_adapter.rb +107 -88
- data/lib/redmine_extensions/easy_query_helpers/outputs.rb +69 -0
- data/lib/redmine_extensions/engine.rb +11 -1
- data/lib/redmine_extensions/query_output.rb +41 -25
- data/lib/redmine_extensions/query_outputs/list_output.rb +14 -0
- data/lib/redmine_extensions/query_outputs/tile_output.rb +19 -0
- data/lib/redmine_extensions/redmine_patches/patches.rb +2 -3
- data/lib/redmine_extensions/version.rb +1 -1
- data/spec/redmine/bin/about +0 -0
- data/spec/redmine/bin/bundle +0 -0
- data/spec/redmine/bin/rails +0 -0
- data/spec/redmine/bin/rake +0 -0
- data/spec/redmine/extra/svn/reposman.rb +0 -0
- data/spec/redmine/public/dispatch.fcgi.example +0 -0
- data/spec/redmine/script/about +0 -0
- data/spec/redmine/script/rails +0 -0
- metadata +1978 -1972
- data/lib/redmine_extensions/query_outputs/table_output.rb +0 -18
@@ -1,17 +1,17 @@
|
|
1
|
-
<%%= title l(:heading_<%= model_name_underscored %>_edit) %>
|
2
|
-
|
3
|
-
<%%= form_for([@project, @<%= model_name_underscored %>], html: {multipart: <%= acts_as_attachable? %>, id: '<%= model_name_underscored %>_form', class: 'tabular'}) do |f| %>
|
4
|
-
<%%= error_messages_for @<%= model_name_underscored %> %>
|
5
|
-
|
6
|
-
<div class="box">
|
7
|
-
<%%= render partial: 'form', locals: {<%= model_name_underscored %>: @<%= model_name_underscored %>} %>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<p>
|
11
|
-
<%%= submit_tag l(:button_update), title: l(:button_update) %>
|
12
|
-
</p>
|
13
|
-
<%% end %>
|
14
|
-
<%% ### PAGE CUSTOMS ########################################################## %>
|
15
|
-
<%% content_for :sidebar do %>
|
16
|
-
<%%= render :partial => '<%= model_name_pluralize_underscored %>/sidebar' %>
|
1
|
+
<%%= title l(:heading_<%= model_name_underscored %>_edit) %>
|
2
|
+
|
3
|
+
<%%= form_for([@project, @<%= model_name_underscored %>], html: {multipart: <%= acts_as_attachable? %>, id: '<%= model_name_underscored %>_form', class: 'tabular'}) do |f| %>
|
4
|
+
<%%= error_messages_for @<%= model_name_underscored %> %>
|
5
|
+
|
6
|
+
<div class="box">
|
7
|
+
<%%= render partial: 'form', locals: {<%= model_name_underscored %>: @<%= model_name_underscored %>} %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<p>
|
11
|
+
<%%= submit_tag l(:button_update), title: l(:button_update) %>
|
12
|
+
</p>
|
13
|
+
<%% end %>
|
14
|
+
<%% ### PAGE CUSTOMS ########################################################## %>
|
15
|
+
<%% content_for :sidebar do %>
|
16
|
+
<%%= render :partial => '<%= model_name_pluralize_underscored %>/sidebar' %>
|
17
17
|
<%% end %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
api.array :<%= model_name_pluralize_underscored %>, api_meta(total_count: @entity_count, offset: @offset, limit: @limit) do
|
2
|
-
@entities.each do |<%= model_name_underscored %>|
|
3
|
-
render_api_<%= model_name_underscored %>(api, <%= model_name_underscored %>)
|
4
|
-
end
|
5
|
-
end
|
1
|
+
api.array :<%= model_name_pluralize_underscored %>, api_meta(total_count: @entity_count, offset: @offset, limit: @limit) do
|
2
|
+
@entities.each do |<%= model_name_underscored %>|
|
3
|
+
render_api_<%= model_name_underscored %>(api, <%= model_name_underscored %>)
|
4
|
+
end
|
5
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%%= render @query %>
|
2
|
-
<%% ### PAGE CUSTOMS ########################################################## %>
|
3
|
-
<%% content_for :sidebar do %>
|
4
|
-
<%%= render :partial => '<%= model_name_pluralize_underscored %>/sidebar' %>
|
1
|
+
<%%= render @query %>
|
2
|
+
<%% ### PAGE CUSTOMS ########################################################## %>
|
3
|
+
<%% content_for :sidebar do %>
|
4
|
+
<%%= render :partial => '<%= model_name_pluralize_underscored %>/sidebar' %>
|
5
5
|
<%% end %>
|
@@ -1 +1 @@
|
|
1
|
-
<h1><%%= link_to(@<%= model_name_underscored %>.to_s, @<%= model_name_underscored %>_url) %></h1>
|
1
|
+
<h1><%%= link_to(@<%= model_name_underscored %>.to_s, @<%= model_name_underscored %>_url) %></h1>
|
@@ -1,2 +1,2 @@
|
|
1
|
-
<%%= @<%= model_name_underscored %>.to_s %>
|
2
|
-
<%%= @<%= model_name_underscored %>_url %>
|
1
|
+
<%%= @<%= model_name_underscored %>.to_s %>
|
2
|
+
<%%= @<%= model_name_underscored %>_url %>
|
@@ -1,2 +1,2 @@
|
|
1
|
-
<%%= @<%= model_name_underscored %>.to_s %>
|
2
|
-
<%%= @<%= model_name_underscored %>_url %>
|
1
|
+
<%%= @<%= model_name_underscored %>.to_s %>
|
2
|
+
<%%= @<%= model_name_underscored %>_url %>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
class Create<%= model_name_pluralize_underscored.camelize %> < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :<%= model_name_pluralize_underscored %>, force: true do |t|
|
4
|
-
<%- db_columns.each do |column_name, column_attrs| -%>
|
5
|
-
t.<%= column_attrs[:type] %> :<%= column_name %>, null: <%= column_attrs[:null] %>
|
6
|
-
<%- end -%>
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
1
|
+
class Create<%= model_name_pluralize_underscored.camelize %> < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :<%= model_name_pluralize_underscored %>, force: true do |t|
|
4
|
+
<%- db_columns.each do |column_name, column_attrs| -%>
|
5
|
+
t.<%= column_attrs[:type] %> :<%= column_name %>, null: <%= column_attrs[:null] %>
|
6
|
+
<%- end -%>
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
<%%= title l(:heading_<%= model_name_underscored %>_new) %>
|
2
|
-
|
3
|
-
<%%= form_for([@project, @<%= model_name_underscored %>], html: {multipart: <%= acts_as_attachable? %>, id: '<%= model_name_underscored %>_form', class: 'tabular'}) do |f| %>
|
4
|
-
<%%= error_messages_for @<%= model_name_underscored %> %>
|
5
|
-
|
6
|
-
<div class="box">
|
7
|
-
<%%= render partial: 'form', locals: {<%= model_name_underscored %>: @<%= model_name_underscored %>} %>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<p>
|
11
|
-
<%%= submit_tag l(:button_create), title: l(:button_create) %>
|
12
|
-
</p>
|
13
|
-
<%% end %>
|
14
|
-
<%% ### PAGE CUSTOMS ########################################################## %>
|
15
|
-
<%% content_for :sidebar do %>
|
16
|
-
<%%= render :partial => '<%= model_name_pluralize_underscored %>/sidebar' %>
|
1
|
+
<%%= title l(:heading_<%= model_name_underscored %>_new) %>
|
2
|
+
|
3
|
+
<%%= form_for([@project, @<%= model_name_underscored %>], html: {multipart: <%= acts_as_attachable? %>, id: '<%= model_name_underscored %>_form', class: 'tabular'}) do |f| %>
|
4
|
+
<%%= error_messages_for @<%= model_name_underscored %> %>
|
5
|
+
|
6
|
+
<div class="box">
|
7
|
+
<%%= render partial: 'form', locals: {<%= model_name_underscored %>: @<%= model_name_underscored %>} %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<p>
|
11
|
+
<%%= submit_tag l(:button_create), title: l(:button_create) %>
|
12
|
+
</p>
|
13
|
+
<%% end %>
|
14
|
+
<%% ### PAGE CUSTOMS ########################################################## %>
|
15
|
+
<%% content_for :sidebar do %>
|
16
|
+
<%%= render :partial => '<%= model_name_pluralize_underscored %>/sidebar' %>
|
17
17
|
<%% end %>
|
@@ -30,7 +30,7 @@ class <%= model_name %>Query < EasyQuery
|
|
30
30
|
@available_columns
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def default_columns_names
|
34
34
|
super.presence || <%= db_columns.collect{|column_name, column_options| (column_options[:query_column_name] || column_name).to_sym}[0..3].to_s %>.flat_map{|c| [c.to_s, c.to_sym]}
|
35
35
|
end
|
36
36
|
|
@@ -1,13 +1,13 @@
|
|
1
|
-
<% if project? %>
|
2
|
-
resources :projects do
|
3
|
-
resources :<%= model_name_pluralize_underscored %>
|
4
|
-
end
|
5
|
-
<% end %>
|
6
|
-
resources :<%= model_name_pluralize_underscored %> do
|
7
|
-
collection do
|
8
|
-
get 'autocomplete'
|
9
|
-
get 'bulk_edit'
|
10
|
-
post 'bulk_update'
|
11
|
-
get 'context_menu'
|
12
|
-
end
|
1
|
+
<% if project? %>
|
2
|
+
resources :projects do
|
3
|
+
resources :<%= model_name_pluralize_underscored %>
|
4
|
+
end
|
5
|
+
<% end %>
|
6
|
+
resources :<%= model_name_pluralize_underscored %> do
|
7
|
+
collection do
|
8
|
+
get 'autocomplete'
|
9
|
+
get 'bulk_edit'
|
10
|
+
post 'bulk_update'
|
11
|
+
get 'context_menu'
|
12
|
+
end
|
13
13
|
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
<%%= title @<%= model_name_underscored %> %>
|
2
|
-
<div class="issue">
|
3
|
-
<table class="attributes">
|
4
|
-
<%%= issue_fields_rows do |rows| %>
|
5
|
-
<%- safe_columns.each_with_index do |column, idx| -%>
|
6
|
-
<%- next if description_column? && column[0] == description_column -%>
|
7
|
-
<%- if idx % 2 == 0 -%>
|
8
|
-
<%% rows.left ::<%= model_name %>.human_attribute_name(:<%= column[0] %>), format_object(@<%= model_name_underscored %>.<%= column[0] %>) %>
|
9
|
-
<%- else -%>
|
10
|
-
<%% rows.right ::<%= model_name %>.human_attribute_name(:<%= column[0] %>), format_object(@<%= model_name_underscored %>.<%= column[0] %>) %>
|
11
|
-
<%- end -%>
|
12
|
-
<%- end -%>
|
13
|
-
<%% end %>
|
14
|
-
<%%= render_custom_fields_rows(@<%= model_name_underscored %>) %>
|
15
|
-
<%%= call_hook(:view_<%= model_name_pluralize_underscored %>_show_details_bottom, :<%= model_name_underscored %> => @<%= model_name_underscored %>) %>
|
16
|
-
</table>
|
17
|
-
<%- if description_column? -%>
|
18
|
-
<%% if !@<%= model_name_underscored %>.<%= description_column %>.blank? %>
|
19
|
-
<hr />
|
20
|
-
<div class="description">
|
21
|
-
<p><strong><%%= ::<%= model_name %>.human_attribute_name(:<%= description_column %>) %></strong></p>
|
22
|
-
<div class="wiki">
|
23
|
-
<%%= textilizable @<%= model_name_underscored %>, :<%= description_column %>, attachments: @<%= model_name_underscored %>.attachments %>
|
24
|
-
</div>
|
25
|
-
</div>
|
26
|
-
<%% end %>
|
27
|
-
<%- end -%>
|
28
|
-
<%- if acts_as_attachable? -%>
|
29
|
-
<%% if @<%= model_name_underscored %>.attachments.any? -%>
|
30
|
-
<hr />
|
31
|
-
<%%= link_to_attachments @<%= model_name_underscored %>, :thumbnails => true %>
|
32
|
-
<%% end %>
|
33
|
-
<%- end -%>
|
34
|
-
</div>
|
35
|
-
<%% ### PAGE CUSTOMS ########################################################## %>
|
36
|
-
<%% content_for :sidebar do %>
|
37
|
-
<%%= render :partial => '<%= model_name_pluralize_underscored %>/sidebar' %>
|
1
|
+
<%%= title @<%= model_name_underscored %> %>
|
2
|
+
<div class="issue">
|
3
|
+
<table class="attributes">
|
4
|
+
<%%= issue_fields_rows do |rows| %>
|
5
|
+
<%- safe_columns.each_with_index do |column, idx| -%>
|
6
|
+
<%- next if description_column? && column[0] == description_column -%>
|
7
|
+
<%- if idx % 2 == 0 -%>
|
8
|
+
<%% rows.left ::<%= model_name %>.human_attribute_name(:<%= column[0] %>), format_object(@<%= model_name_underscored %>.<%= column[0] %>) %>
|
9
|
+
<%- else -%>
|
10
|
+
<%% rows.right ::<%= model_name %>.human_attribute_name(:<%= column[0] %>), format_object(@<%= model_name_underscored %>.<%= column[0] %>) %>
|
11
|
+
<%- end -%>
|
12
|
+
<%- end -%>
|
13
|
+
<%% end %>
|
14
|
+
<%%= render_custom_fields_rows(@<%= model_name_underscored %>) %>
|
15
|
+
<%%= call_hook(:view_<%= model_name_pluralize_underscored %>_show_details_bottom, :<%= model_name_underscored %> => @<%= model_name_underscored %>) %>
|
16
|
+
</table>
|
17
|
+
<%- if description_column? -%>
|
18
|
+
<%% if !@<%= model_name_underscored %>.<%= description_column %>.blank? %>
|
19
|
+
<hr />
|
20
|
+
<div class="description">
|
21
|
+
<p><strong><%%= ::<%= model_name %>.human_attribute_name(:<%= description_column %>) %></strong></p>
|
22
|
+
<div class="wiki">
|
23
|
+
<%%= textilizable @<%= model_name_underscored %>, :<%= description_column %>, attachments: @<%= model_name_underscored %>.attachments %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
<%% end %>
|
27
|
+
<%- end -%>
|
28
|
+
<%- if acts_as_attachable? -%>
|
29
|
+
<%% if @<%= model_name_underscored %>.attachments.any? -%>
|
30
|
+
<hr />
|
31
|
+
<%%= link_to_attachments @<%= model_name_underscored %>, :thumbnails => true %>
|
32
|
+
<%% end %>
|
33
|
+
<%- end -%>
|
34
|
+
</div>
|
35
|
+
<%% ### PAGE CUSTOMS ########################################################## %>
|
36
|
+
<%% content_for :sidebar do %>
|
37
|
+
<%%= render :partial => '<%= model_name_pluralize_underscored %>/sidebar' %>
|
38
38
|
<%% end %>
|
@@ -19,138 +19,157 @@ module RedmineExtensions
|
|
19
19
|
module ClassMethods
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
23
22
|
|
24
|
-
|
23
|
+
module QueryAdapter
|
25
24
|
|
26
|
-
|
25
|
+
# after_initialize :after_initialize
|
27
26
|
|
28
|
-
|
29
|
-
self.filters ||= {}
|
30
|
-
|
27
|
+
# def after_initialize
|
28
|
+
# self.filters ||= {}
|
29
|
+
# end
|
31
30
|
|
32
|
-
|
33
|
-
[].freeze
|
34
|
-
end
|
31
|
+
attr_writer :outputs
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
def outputs
|
34
|
+
@outputs ||= ['list']
|
35
|
+
end
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
def output=(output_t)
|
38
|
+
self.outputs = Array.wrap(output_t)
|
39
|
+
end
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
def filters
|
42
|
+
super || {}
|
43
|
+
end
|
47
44
|
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
def default_find_include
|
46
|
+
[].freeze
|
47
|
+
end
|
51
48
|
|
52
|
-
|
53
|
-
|
49
|
+
def default_find_preload
|
50
|
+
[].freeze
|
51
|
+
end
|
52
|
+
|
53
|
+
def default_find_joins
|
54
|
+
[].freeze
|
55
|
+
end
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
def default_list_columns
|
58
|
+
[].freeze
|
59
|
+
end
|
60
|
+
|
61
|
+
def formatter
|
62
|
+
@formatter
|
63
|
+
end
|
64
|
+
|
65
|
+
def init_formatter(object)
|
66
|
+
return @formatter if @formatter
|
67
|
+
|
68
|
+
if entity
|
69
|
+
begin
|
70
|
+
formatter_klass = "#{entity}Formatter".constantize
|
71
|
+
rescue NameError
|
72
|
+
end
|
59
73
|
end
|
74
|
+
|
75
|
+
formatter_klass ||= EasyEntityFormatter
|
76
|
+
@formatter = formatter_klass.new(object)
|
60
77
|
end
|
61
78
|
|
62
|
-
|
63
|
-
|
64
|
-
|
79
|
+
def entity
|
80
|
+
self.class.queried_class
|
81
|
+
end
|
65
82
|
|
66
|
-
|
67
|
-
|
68
|
-
|
83
|
+
def entity_scope
|
84
|
+
if !@entity_scope.nil?
|
85
|
+
@entity_scope
|
86
|
+
elsif entity.respond_to?(:visible)
|
87
|
+
entity.visible
|
88
|
+
else
|
89
|
+
entity
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def set_entity_scope(entity, reference_collection = nil)
|
94
|
+
return nil if entity.nil? || reference_collection.nil?
|
95
|
+
|
96
|
+
@entity_scope = entity.send(reference_collection.to_sym)
|
97
|
+
|
98
|
+
self.filters = {}
|
69
99
|
|
70
|
-
def entity_scope
|
71
|
-
if !@entity_scope.nil?
|
72
100
|
@entity_scope
|
73
|
-
elsif entity.respond_to?(:visible)
|
74
|
-
entity.visible
|
75
|
-
else
|
76
|
-
entity
|
77
101
|
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def set_entity_scope(entity, reference_collection = nil)
|
81
|
-
return nil if entity.nil? || reference_collection.nil?
|
82
102
|
|
83
|
-
|
103
|
+
def create_entity_scope(options={})
|
104
|
+
scope = entity_scope.where(statement)
|
84
105
|
|
85
|
-
|
106
|
+
includes = default_find_include.dup
|
107
|
+
includes.concat(Array.wrap(options[:includes]))
|
86
108
|
|
87
|
-
|
88
|
-
|
109
|
+
preload = default_find_preload.dup
|
110
|
+
preload.concat(Array.wrap(options[:preload]))
|
89
111
|
|
90
|
-
|
91
|
-
|
112
|
+
joins = default_find_joins.dup
|
113
|
+
joins.concat(Array.wrap(options[:joins]))
|
92
114
|
|
93
|
-
|
94
|
-
|
115
|
+
filters.keys.each do |filter|
|
116
|
+
f = available_filters[filter]
|
117
|
+
next if f.blank?
|
95
118
|
|
96
|
-
|
97
|
-
|
119
|
+
includes.concat(Array.wrap(f[:includes])) if f[:includes]
|
120
|
+
joins.concat(Array.wrap(f[:joins])) if f[:joins]
|
121
|
+
end if filters
|
98
122
|
|
99
|
-
|
100
|
-
|
123
|
+
columns.each do |c|
|
124
|
+
includes.concat(Array.wrap(c.includes)) if c.includes
|
125
|
+
joins.concat(Array.wrap(c.joins)) if c.joins
|
126
|
+
preload.concat(Array.wrap(c.preload)) if c.preload
|
127
|
+
end
|
101
128
|
|
102
|
-
|
103
|
-
|
104
|
-
|
129
|
+
if project
|
130
|
+
includes << :project
|
131
|
+
end
|
105
132
|
|
106
|
-
includes.
|
107
|
-
joins.
|
108
|
-
|
133
|
+
includes.uniq!
|
134
|
+
joins.uniq!
|
135
|
+
preload.uniq!
|
109
136
|
|
110
|
-
|
111
|
-
includes.concat(Array.wrap(c.includes)) if c.includes
|
112
|
-
joins.concat(Array.wrap(c.joins)) if c.joins
|
113
|
-
preload.concat(Array.wrap(c.preload)) if c.preload
|
137
|
+
scope.includes(includes).references(includes).joins(joins).preload(preload)
|
114
138
|
end
|
115
139
|
|
116
|
-
|
117
|
-
|
140
|
+
def entities(options={})
|
141
|
+
create_entity_scope(options).order(options[:order]).to_a
|
118
142
|
end
|
119
143
|
|
120
|
-
|
121
|
-
|
122
|
-
preload.uniq!
|
144
|
+
def add_available_column(name, options={})
|
145
|
+
@available_columns ||= []
|
123
146
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
def entities(options={})
|
128
|
-
create_entity_scope(options).order(options[:order]).to_a
|
129
|
-
end
|
147
|
+
@available_columns << QueryColumn.new(name.to_sym, options)
|
148
|
+
end
|
130
149
|
|
131
|
-
|
132
|
-
|
150
|
+
def to_partial_path
|
151
|
+
'easy_queries/index'
|
152
|
+
end
|
133
153
|
|
134
|
-
|
135
|
-
|
154
|
+
def default_columns_names
|
155
|
+
default_list_columns
|
156
|
+
end
|
136
157
|
|
137
|
-
|
138
|
-
|
139
|
-
|
158
|
+
def queried_table_name
|
159
|
+
entity.table_name
|
160
|
+
end
|
140
161
|
|
141
|
-
def default_columns_names
|
142
|
-
default_list_columns
|
143
162
|
end
|
144
163
|
|
145
|
-
|
146
|
-
entity.table_name
|
147
|
-
end
|
164
|
+
end
|
148
165
|
|
166
|
+
class EasyQueryAdapter < Query
|
149
167
|
end
|
150
168
|
|
151
169
|
if Redmine::Plugin.installed?(:easy_extensions)
|
152
170
|
# EasyQuery exist
|
153
171
|
else
|
154
172
|
QueryColumn.send(:include, RedmineExtensions::QueryColumnAdapter)
|
173
|
+
RedmineExtensions::PatchManager.register_model_patch('Query', "RedmineExtensions::QueryAdapter")
|
155
174
|
EasyQuery = EasyQueryAdapter
|
156
175
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module RedmineExtensions
|
2
|
+
module EasyQueryHelpers
|
3
|
+
# ----- OUTPUTS HELPER CLASS ----
|
4
|
+
class Outputs
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def initialize(presenter, view_context = nil)
|
8
|
+
if presenter.is_a?(RedmineExtensions::BasePresenter)
|
9
|
+
@presenter = presenter
|
10
|
+
@query = @presenter.model
|
11
|
+
else
|
12
|
+
@presenter = @query = presenter
|
13
|
+
end
|
14
|
+
@view_context = view_context
|
15
|
+
end
|
16
|
+
|
17
|
+
def view_context
|
18
|
+
@view_context || @presenter.h
|
19
|
+
end
|
20
|
+
|
21
|
+
def outputs
|
22
|
+
@outputs ||= enabled_outputs.map{|o| RedmineExtensions::QueryOutput.output_klass_for(o).new(@presenter, self) }.sort_by{|a| a.order}
|
23
|
+
end
|
24
|
+
|
25
|
+
def each(style = :enabled, &block)
|
26
|
+
if style == :enabled
|
27
|
+
outputs.each(&block)
|
28
|
+
else
|
29
|
+
available_outputs.each(&block)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def enabled_outputs
|
34
|
+
res = @query.outputs
|
35
|
+
res << 'list' if res.empty? && available_outputs.empty?
|
36
|
+
res
|
37
|
+
end
|
38
|
+
|
39
|
+
def available_output_names
|
40
|
+
@available_output_names ||= RedmineExtensions::QueryOutput.available_outputs_for( @query )
|
41
|
+
end
|
42
|
+
|
43
|
+
def available_outputs
|
44
|
+
@available_outputs ||= RedmineExtensions::QueryOutput.available_output_klasses_for( @query ).map{|klass| klass.new(@presenter, self) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def output_enabled?(output)
|
48
|
+
enabled_outputs.include?(output.to_s)
|
49
|
+
end
|
50
|
+
|
51
|
+
def render_edit_selects(style=:check_box, options={})
|
52
|
+
available_output_instances.map{|o| o.render_edit_box(style, options) }.join('').html_safe
|
53
|
+
end
|
54
|
+
|
55
|
+
def render_edit
|
56
|
+
outputs.map{ |output| output.render_edit }.join('').html_safe
|
57
|
+
end
|
58
|
+
|
59
|
+
def method_missing(name, *args)
|
60
|
+
if name.to_s.ends_with?('?')
|
61
|
+
output_enabled?(name.to_s[0..-2])
|
62
|
+
else
|
63
|
+
super
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end #EasyQueryHelpers
|
69
|
+
end #RedmineExtensions
|
@@ -4,6 +4,15 @@ require 'redmine_extensions/redmine_patches/patches'
|
|
4
4
|
module RedmineExtensions
|
5
5
|
class Engine < ::Rails::Engine
|
6
6
|
|
7
|
+
def self.automount!(path = nil)
|
8
|
+
engine = self
|
9
|
+
path ||= engine.to_s.underscore.split('/').first
|
10
|
+
Rails.application.routes.draw do
|
11
|
+
mount engine => path
|
12
|
+
resources :easy_settings, only: [:edit]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
7
16
|
config.generators do |g|
|
8
17
|
g.test_framework :rspec, :fixture => false
|
9
18
|
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
@@ -16,7 +25,8 @@ module RedmineExtensions
|
|
16
25
|
|
17
26
|
#config.to_prepare goes after Reloader.to_prepare
|
18
27
|
ActionDispatch::Reloader.to_prepare do
|
19
|
-
RedmineExtensions::QueryOutput.register_output
|
28
|
+
RedmineExtensions::QueryOutput.register_output RedmineExtensions::QueryOutputs::ListOutput
|
29
|
+
RedmineExtensions::QueryOutput.register_output RedmineExtensions::QueryOutputs::TileOutput
|
20
30
|
# RedmineExtensions::BasePresenter.register 'RedmineExtensions::EasyQueryPresenter', 'EasyQuery'
|
21
31
|
# ApplicationController.send :include, RedmineExtensions::RailsPatches::ControllerQueryHelpers
|
22
32
|
ApplicationController.send :include, RedmineExtensions::RenderingHelper
|