redmine_extensions 0.4.4 → 0.6.0
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/README.md +51 -0
- data/app/assets/javascripts/redmine_extensions/redmine_extensions.js +1 -0
- data/app/helpers/redmine_extensions/application_helper.rb +27 -36
- data/app/views/common/_collapsible_module_layout.html.erb +20 -2
- data/app/views/easy_front_end/_easy_front_end.html.erb +1 -19
- data/db/migrate/20150705172511_create_easy_settings.rb +1 -1
- data/db/migrate/20160519161300_create_entity_assignments.rb +1 -1
- data/db/migrate/20190206121100_remove_foreign_key_from_easy_settings.rb +1 -1
- data/lib/generators/redmine_extensions/entity/templates/_sidebar.html.erb.erb +1 -1
- data/lib/generators/redmine_extensions/entity/templates/show.html.erb.erb +1 -1
- data/lib/redmine_extensions/engine.rb +9 -23
- data/lib/redmine_extensions/hooks.rb +1 -9
- data/lib/redmine_extensions/migration.rb +1 -1
- data/lib/redmine_extensions/patch_manager.rb +43 -43
- data/lib/redmine_extensions/version.rb +3 -1
- metadata +11 -35
- data/app/assets/javascripts/redmine_extensions/jasmine_lib/boot.js +0 -153
- data/app/assets/javascripts/redmine_extensions/jasmine_lib/jasmine_helper.js +0 -292
- data/app/assets/javascripts/redmine_extensions/jasmine_lib/jasmine_lib.js +0 -3
- data/app/assets/javascripts/redmine_extensions/jasmine_tests/extend.js +0 -32
- data/app/assets/javascripts/redmine_extensions/jasmine_tests/jasmine_tests.js +0 -1
- data/app/assets/javascripts/redmine_extensions/jasmine_tests/modules.js +0 -164
- data/app/assets/stylesheets/redmine_extensions/jasmine.css +0 -35
- data/app/views/redmine_extensions/_development_mode.html.erb +0 -33
- data/app/views/redmine_extensions/_jasmine.html.erb +0 -7
- data/lib/redmine_extensions/html_formatting/formatter.rb +0 -86
- data/lib/redmine_extensions/html_formatting/helper.rb +0 -73
- data/lib/redmine_extensions/html_formatting/internals.rb +0 -23
- data/lib/redmine_extensions/html_formatting.rb +0 -3
- data/spec/features/autocomplete_spec.rb +0 -17
- data/spec/features/jasmine_spec.rb +0 -9
- data/spec/support/plugin_generator.rb +0 -111
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83a259a0df79f133ef83c0d83a97867065e72ba53718b6021f4ea4f199350300
|
4
|
+
data.tar.gz: 498ecf0ad2f97992ecb43b5e9f08af3e8d7dd6e73260b1bf6539e1cce8c7f21b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fadd35b5ab3c6ebfd7254b760ddbf17cd56a39fc3de03a673d15e7e2dda50ae83c4469a1e5f4d6264e87733284097d619c2181724021b8ebadf0f9d591f98f28
|
7
|
+
data.tar.gz: e7a1aaca2e52ec55f08178b5526aae5f82d155582683359c4f853ee7d0c3d13c79603949371cc333310d14d0af939d35d990124093ecfdef3dfeb478568dd1ee
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Redmine Extensions
|
2
|
+
|
3
|
+
[](https://git.easy.cz/redmine/redmine_extensions_gem/-/commits/master)
|
4
|
+
|
5
|
+
[](https://git.easy.cz/redmine/redmine_extensions_gem/-/releases)
|
6
|
+
|
7
|
+
[](http://badge.fury.io/rb/redmine_extensions)
|
8
|
+
|
9
|
+
|
10
|
+
⚠️ This gem currently not working with Redmine at all.
|
11
|
+
|
12
|
+
---
|
13
|
+
This gem provides an extended funcionality for a Redmine project
|
14
|
+
|
15
|
+
## Provided functionalities
|
16
|
+
* EasySetting - per project settings
|
17
|
+
* Redmine Plugin Generator
|
18
|
+
* Redmine Entity Generator
|
19
|
+
|
20
|
+
## Redmine Plugin Generator
|
21
|
+
|
22
|
+
Description:
|
23
|
+
The plugin generator creates stubs for a new Redmine plugin.
|
24
|
+
Plugin is prepared for use in Redmine and Easy Redmine as well.
|
25
|
+
You can use --customer flag to generate a special plugin if you can make just a few changes to code. Backup this plugin before Redmine or Easy Redmine upgrade and move back for keep you changes.
|
26
|
+
|
27
|
+
Example:
|
28
|
+
rails g redmine_extensions:plugin NameOfNewPlugin
|
29
|
+
create plugins/name_of_new_plugin/app/controllers
|
30
|
+
...
|
31
|
+
|
32
|
+
Help:
|
33
|
+
rails g redmine_extensions:plugin --help
|
34
|
+
|
35
|
+
|
36
|
+
## Redmine Entity Generator
|
37
|
+
|
38
|
+
Description:
|
39
|
+
The entity generator creates new entity for Redmine plugin.
|
40
|
+
New entity is prepared for use in Redmine and Easy Redmine as well.
|
41
|
+
|
42
|
+
Example:
|
43
|
+
rails g redmine_extensions:entity NameOfNewPlugin Post
|
44
|
+
create plugins/name_of_new_plugin/app/controllers
|
45
|
+
...
|
46
|
+
|
47
|
+
Help:
|
48
|
+
rails g redmine_extensions:entity --help
|
49
|
+
|
50
|
+
## Licence
|
51
|
+
This is published under GPL-2 license.
|
@@ -14,7 +14,7 @@ module RedmineExtensions
|
|
14
14
|
|
15
15
|
# -------= Rendering and presenting methods =-------
|
16
16
|
|
17
|
-
def present(model, options={}, &block)
|
17
|
+
def present(model, options = {}, &block)
|
18
18
|
if model.is_a?(RedmineExtensions::BasePresenter)
|
19
19
|
presenter = model.update_options(options.merge(view_context: self))
|
20
20
|
else
|
@@ -31,11 +31,12 @@ module RedmineExtensions
|
|
31
31
|
|
32
32
|
# hide elements for issues and users
|
33
33
|
def detect_hide_elements(uniq_id, user = nil, default = true)
|
34
|
-
return
|
35
|
-
|
34
|
+
return if uniq_id.blank?
|
35
|
+
|
36
|
+
'style="display:none"'.html_safe if !toggle_button_expanded?(uniq_id, user, default)
|
36
37
|
end
|
37
38
|
|
38
|
-
def url_to_entity(entity, options={})
|
39
|
+
def url_to_entity(entity, options = {})
|
39
40
|
m = "url_to_#{entity.class.name.underscore}".to_sym
|
40
41
|
if respond_to?(m)
|
41
42
|
send(m, entity, options)
|
@@ -87,7 +88,7 @@ module RedmineExtensions
|
|
87
88
|
render(:partial => 'easy_entity_assignments/assignments_container', :locals => {
|
88
89
|
:entity => entity,
|
89
90
|
:query => query, :project => project,
|
90
|
-
:entities => entities, :entities_count => entities_count, :options => options})
|
91
|
+
:entities => entities, :entities_count => entities_count, :options => options })
|
91
92
|
end
|
92
93
|
|
93
94
|
def entity_css_icon(entity_or_entity_class)
|
@@ -116,7 +117,7 @@ module RedmineExtensions
|
|
116
117
|
else
|
117
118
|
content_or_options_with_block
|
118
119
|
end
|
119
|
-
html_options.reverse_merge!({type:'application/javascript'})
|
120
|
+
html_options.reverse_merge!({ type: 'application/javascript' })
|
120
121
|
priority = html_options.delete(:priority) || 0
|
121
122
|
content = " EasyGem.schedule.late(function(){#{content} }, #{priority});"
|
122
123
|
|
@@ -139,27 +140,16 @@ module RedmineExtensions
|
|
139
140
|
javascript_tag content.html_safe, html_options
|
140
141
|
end
|
141
142
|
|
142
|
-
def get_jasmine_tags
|
143
|
-
tags = params[:jasmine]
|
144
|
-
return [] if tags == 'true'
|
145
|
-
if tags.is_a?(String)
|
146
|
-
[tags.to_sym]
|
147
|
-
elsif tags.is_a?(Array)
|
148
|
-
tags.map &:to_sym
|
149
|
-
else
|
150
|
-
[]
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
143
|
def easy_avatar_url(user = nil)
|
144
|
+
return avatar_url(user) if respond_to?(:avatar_url)
|
145
|
+
|
155
146
|
user ||= User.current
|
156
|
-
|
157
|
-
options = {:
|
158
|
-
email =
|
159
|
-
|
160
|
-
email = user.mail
|
147
|
+
if Setting.gravatar_enabled?
|
148
|
+
options = { ssl: (request&.ssl?), default: Setting.gravatar_default }
|
149
|
+
email = if user.respond_to?(:mail)
|
150
|
+
user.mail
|
161
151
|
elsif user.to_s =~ %r{<(.+?)>}
|
162
|
-
|
152
|
+
$1
|
163
153
|
end
|
164
154
|
email ? gravatar_url(email, options) : ''
|
165
155
|
elsif user.easy_avatar_url.present?
|
@@ -167,7 +157,6 @@ module RedmineExtensions
|
|
167
157
|
elsif user.respond_to?(:easy_avatar) && (av = user.easy_avatar).present? && (img_url = av.image.url(:small))
|
168
158
|
get_easy_absolute_uri_for(img_url).to_s
|
169
159
|
end
|
170
|
-
result
|
171
160
|
end
|
172
161
|
|
173
162
|
# ==== Options
|
@@ -180,13 +169,14 @@ module RedmineExtensions
|
|
180
169
|
# * <tt>remember: false</tt> - This disable remember function of toggle container
|
181
170
|
# ** Aliases for this options are: ajax_call
|
182
171
|
#
|
183
|
-
def render_module_easy_box(id, heading, options = {}, &block)
|
172
|
+
def render_module_easy_box(id, heading, options = {}, &block)
|
173
|
+
# with fallback to old
|
184
174
|
options[:toggle] = true unless options.key?(:toggle)
|
185
175
|
options[:remember] = options.delete(:ajax_call) if options.key?(:ajax_call)
|
186
176
|
options[:collapsible] = !options.delete(:no_expander) if options.key?(:no_expander)
|
187
177
|
|
188
178
|
renderer = EasyBoxRenderer.new(self, id, heading, options)
|
189
|
-
renderer.content = capture {yield renderer}
|
179
|
+
renderer.content = capture { yield renderer }
|
190
180
|
|
191
181
|
renderer.render
|
192
182
|
end
|
@@ -247,8 +237,9 @@ module RedmineExtensions
|
|
247
237
|
end
|
248
238
|
|
249
239
|
def render
|
250
|
-
view.render({partial: 'common/collapsible_module_layout', locals: {renderer: self, content: content}}
|
240
|
+
view.render({ partial: 'common/collapsible_module_layout', locals: { renderer: self, content: content } })
|
251
241
|
end
|
242
|
+
|
252
243
|
private
|
253
244
|
|
254
245
|
def css_classes
|
@@ -257,9 +248,9 @@ module RedmineExtensions
|
|
257
248
|
@css_classes = css_class
|
258
249
|
else
|
259
250
|
@css_classes = {
|
260
|
-
|
261
|
-
|
262
|
-
|
251
|
+
container: css_class,
|
252
|
+
heading: css_class,
|
253
|
+
content: css_class
|
263
254
|
}
|
264
255
|
end
|
265
256
|
end
|
@@ -287,7 +278,7 @@ module RedmineExtensions
|
|
287
278
|
# * +rootElement+ - Has sence only if jsonpath is used for available values. It tells if the json response has values wrapped under root element.
|
288
279
|
# For response like <tt>{projects: [[<name>, <id>], [<name2>, <id2>]]}</tt> user option <tt>rootElement: 'projects'</tt>
|
289
280
|
def autocomplete_field_tag(name, jsonpath_or_array, selected_values, options = {})
|
290
|
-
options.reverse_merge!(
|
281
|
+
options.reverse_merge!(select_first_value: false, load_immediately: false, preload: true, multiple: true, combo: false)
|
291
282
|
options[:id] ||= sanitize_to_id(name)
|
292
283
|
|
293
284
|
selected_values ||= []
|
@@ -298,9 +289,9 @@ module RedmineExtensions
|
|
298
289
|
source = "'#{jsonpath_or_array}'"
|
299
290
|
end
|
300
291
|
|
301
|
-
content_tag(:span, :
|
302
|
-
search_field_tag('', '', (options[:html_options] || {}).merge(id: options[:id])) +
|
303
|
-
late_javascript_tag("$('##{options[:id]}').easymultiselect({multiple: #{options[:multiple]}, rootElement: #{options[:rootElement].to_json}, inputName: '#{name}', preload: #{options[:preload]}, combo: #{options[:combo]}, source: #{source}, selected: #{selected_values.to_json}, select_first_value: #{options[:select_first_value]}, load_immediately: #{options[:load_immediately]}, autocomplete_options: #{(options[:jquery_auto_complete_options]||{}).to_json} });")
|
292
|
+
content_tag(:span, class: 'easy-multiselect-tag-container', data: { cy: "container_old_autocomplete--#{name}" }) do
|
293
|
+
search_field_tag('', '', (options[:html_options] || {}).merge(id: options[:id], data: { cy: "search_old_autocomplete--#{name}" })) +
|
294
|
+
late_javascript_tag("$('##{options[:id]}').easymultiselect({multiple: #{options[:multiple]}, rootElement: #{options[:rootElement].to_json}, inputName: '#{name}', preload: #{options[:preload]}, combo: #{options[:combo]}, source: #{source}, selected: #{selected_values.to_json}, select_first_value: #{options[:select_first_value]}, load_immediately: #{options[:load_immediately]}, autocomplete_options: #{(options[:jquery_auto_complete_options] || {}).to_json} });")
|
304
295
|
end
|
305
296
|
end
|
306
297
|
|
@@ -323,7 +314,7 @@ module RedmineExtensions
|
|
323
314
|
# <input type="hidden" name="issue[tag_ids][]" value="#{@issue.tag_ids.second}" />
|
324
315
|
# ...(wraping service tags end)
|
325
316
|
# </span>
|
326
|
-
def autocomplete_field(object_name, method, choices, options={}, html_options={})
|
317
|
+
def autocomplete_field(object_name, method, choices, options = {}, html_options = {})
|
327
318
|
Tags::AutocompleteField.new(object_name, method, self, choices, options, html_options).render
|
328
319
|
end
|
329
320
|
|
@@ -1,8 +1,26 @@
|
|
1
1
|
<div class="module box <%= renderer.container_class %>"<%=raw renderer.saving_state_enabled? && %Q{ data-toggle="#{renderer.id}"} || nil %>>
|
2
2
|
<%= content_tag(:div, class: 'module-heading ' + renderer.heading_class, onclick: (renderer.collapsible? && 'EasyToggler.toggle(this.nextElementSibling, event)' || nil)) do %>
|
3
|
-
<%= content_tag(:span, ' ', class: 'expander module-toggler') if renderer.collapsible? %>
|
4
3
|
<%= content_tag(renderer.heading_tag, renderer.heading, class: renderer.icon) %>
|
5
|
-
|
4
|
+
<% if renderer.heading_links.presence %>
|
5
|
+
<div class="module-heading-links">
|
6
|
+
<a class="module-heading-links__control icon-more-horiz control--<%= renderer.id %>" title="<%= l(:button_heading_links) %>" aria-label="<%= l(:button_heading_links) %>" role="button"></a>
|
7
|
+
<ul class="module-heading-links__tooltip tooltip tooltip--<%= renderer.id %>">
|
8
|
+
<%= renderer.heading_links %>
|
9
|
+
<% if renderer.collapsible? -%>
|
10
|
+
<li><span href="#" class="icon-chevron-up module__expander" data-cy="expander__toggle--module" title="Expander" aria-label="Expander" role="button"> </span></li>
|
11
|
+
<% end -%>
|
12
|
+
</ul>
|
13
|
+
<script>
|
14
|
+
EASY.schedule.require(function(){
|
15
|
+
$('.control--<%= renderer.id %>').toggleable({
|
16
|
+
observer: EASY.defaultClickObserver,
|
17
|
+
content: $('.tooltip--<%= renderer.id %>')
|
18
|
+
})},function () {
|
19
|
+
return EASY.defaultClickObserver;
|
20
|
+
})
|
21
|
+
</script>
|
22
|
+
</div>
|
23
|
+
<% end -%>
|
6
24
|
<% end if renderer.heading.present? %>
|
7
25
|
<div class="module-content" id="<%= renderer.id %>"<%=raw renderer.collapsed? && %q{ style="display:none"} || nil %>>
|
8
26
|
<%= content -%>
|
@@ -1,22 +1,4 @@
|
|
1
1
|
<% content_for :header_tags do %>
|
2
|
-
<%=
|
3
|
-
if params['combine_by_pipeline'].nil?
|
4
|
-
if Rails.env.development? && ENV['DART'] == '1'
|
5
|
-
javascript_include_tag('dart/localhost', plugin: plugin, defer: true)
|
6
|
-
else
|
7
|
-
javascript_include_tag("#{plugin}.dart", defer: true)
|
8
|
-
end
|
9
|
-
else
|
10
|
-
if params['combine_by_pipeline'] == 'false'
|
11
|
-
#javascript_include_tag('dart/debug', plugin: plugin, defer: true)
|
12
|
-
if ENV['DART'] == '1'
|
13
|
-
javascript_include_tag('dart/localhost', plugin: plugin, defer: true)
|
14
|
-
end
|
15
|
-
else
|
16
|
-
javascript_include_tag("#{plugin}.dart", defer: true)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
%>
|
20
2
|
|
21
3
|
<%
|
22
4
|
standard_lang_files = [
|
@@ -87,6 +69,6 @@
|
|
87
69
|
|
88
70
|
%>
|
89
71
|
<script>
|
90
|
-
window.frontEndCommons = "<%=
|
72
|
+
window.frontEndCommons = "<%= j(front_end_commons.to_json.html_safe) %>";
|
91
73
|
</script>
|
92
74
|
<% end %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%% if @<%= model_name_underscored %> && !@<%= model_name_underscored %>.new_record? %>
|
3
3
|
<%%= content_tag(:li, link_to(l(:button_edit), edit_polymorphic_path([@project, @<%= model_name_underscored %>]), title: l(:button_edit), class: 'icon icon-edit button')) %>
|
4
4
|
<%% end %>
|
5
|
-
<%%
|
5
|
+
<%% if @<%= model_name_underscored %>.nil? %>
|
6
6
|
<%%= content_tag(:li, link_to(l(:button_<%= model_name_underscored %>_new), new_polymorphic_path([@project, :<%= model_name_underscored %>]), title: l(:title_<%= model_name_underscored %>_new), class: 'icon icon-add button button-positive')) %>
|
7
7
|
<%% end %>
|
8
8
|
<%%= content_tag(:li, link_to(l(:label_<%= model_name_pluralize_underscored %>), polymorphic_path([@project, :<%= model_name_pluralize_underscored %>], set_filter: '1'), title: l(:label_<%= model_name_pluralize_underscored %>), class: 'icon icon-folder button')) %>
|
@@ -24,7 +24,7 @@
|
|
24
24
|
<hr />
|
25
25
|
<%%= render partial: 'redmine_extensions/custom_field_rows', locals: { custom_field_values: @<%= model_name_underscored %>.visible_custom_field_values } %>
|
26
26
|
<%- end -%>
|
27
|
-
<%%= call_hook(:view_<%= model_name_pluralize_underscored %>_show_details_bottom,
|
27
|
+
<%%= call_hook(:view_<%= model_name_pluralize_underscored %>_show_details_bottom, <%= model_name_underscored%>: @<%= model_name_underscored %>) %>
|
28
28
|
</table>
|
29
29
|
<%- if description_column? -%>
|
30
30
|
<%% if !@<%= model_name_underscored %>.<%= description_column %>.blank? %>
|
@@ -8,10 +8,9 @@ require_relative './query_output'
|
|
8
8
|
|
9
9
|
module RedmineExtensions
|
10
10
|
class Engine < ::Rails::Engine
|
11
|
-
|
12
11
|
config.generators do |g|
|
13
|
-
g.test_framework :rspec, :
|
14
|
-
g.fixture_replacement :factory_girl, :
|
12
|
+
g.test_framework :rspec, fixture: false
|
13
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
15
14
|
g.assets false
|
16
15
|
g.helper false
|
17
16
|
end
|
@@ -23,14 +22,10 @@ module RedmineExtensions
|
|
23
22
|
if config.respond_to?(:assets)
|
24
23
|
config.assets.precompile << 'redmine_extensions/applications.js'
|
25
24
|
config.assets.precompile << 'redmine_extensions/blocking.js'
|
26
|
-
unless Rails.env.production?
|
27
|
-
config.assets.precompile << 'redmine_extensions/jasmine_lib/jasmine_lib.js'
|
28
|
-
config.assets.precompile << 'redmine_extensions/jasmine.css'
|
29
|
-
end
|
30
25
|
end
|
31
26
|
end
|
32
27
|
|
33
|
-
#config.to_prepare goes after Reloader.to_prepare
|
28
|
+
# config.to_prepare goes after Reloader.to_prepare
|
34
29
|
RedmineExtensions::Reloader.to_prepare do
|
35
30
|
RedmineExtensions::QueryOutput.register_output RedmineExtensions::QueryOutputs::ListOutput
|
36
31
|
RedmineExtensions::QueryOutput.register_output RedmineExtensions::QueryOutputs::TilesOutput
|
@@ -39,7 +34,7 @@ module RedmineExtensions
|
|
39
34
|
ApplicationController.include RedmineExtensions::RenderingHelper
|
40
35
|
end
|
41
36
|
|
42
|
-
initializer 'redmine_extensions.initialize' do |
|
37
|
+
initializer 'redmine_extensions.initialize' do |_app|
|
43
38
|
ActionDispatch::Routing::RouteSet::Generator.prepend RedmineExtensions::RailsPatches::RouteSetGeneratorPatch
|
44
39
|
end
|
45
40
|
|
@@ -52,17 +47,15 @@ module RedmineExtensions
|
|
52
47
|
if true
|
53
48
|
js_dir = app.root.join('public', 'javascripts', 'redmine_extensions')
|
54
49
|
FileUtils.mkdir(js_dir) unless File.directory?(js_dir)
|
55
|
-
Dir.glob(
|
56
|
-
|
57
|
-
|
58
|
-
rescue
|
59
|
-
end
|
50
|
+
Dir.glob(root.join('app', 'assets', 'javascripts', 'redmine_extensions', '*.js')) do |js_file|
|
51
|
+
FileUtils.cp(js_file, app.root.join('public', 'javascripts', 'redmine_extensions'))
|
52
|
+
rescue StandardError
|
60
53
|
end
|
61
54
|
end
|
62
55
|
end
|
63
56
|
|
64
57
|
# include helpers
|
65
|
-
initializer 'redmine_extensions.rails_patching', before: :load_config_initializers do |
|
58
|
+
initializer 'redmine_extensions.rails_patching', before: :load_config_initializers do |_app|
|
66
59
|
ActiveSupport.on_load(Rails::VERSION::MAJOR >= 5 ? :action_controller_base : :action_controller) do
|
67
60
|
helper RedmineExtensions::ApplicationHelper
|
68
61
|
# helper RedmineExtensions::EasyQueryHelper
|
@@ -78,17 +71,10 @@ module RedmineExtensions
|
|
78
71
|
initializer 'redmine_extensions.initialize_easy_plugins', after: :load_config_initializers do
|
79
72
|
require_relative './hooks'
|
80
73
|
|
81
|
-
unless Redmine::Plugin.installed?(:easy_extensions)
|
82
|
-
ActiveSupport.run_load_hooks(:easyproject, self)
|
83
|
-
end
|
74
|
+
ActiveSupport.run_load_hooks(:easyproject, self) unless Redmine::Plugin.installed?(:easy_extensions)
|
84
75
|
|
85
76
|
require_relative './easy_entity_formatters/easy_entity_formatter'
|
86
77
|
end
|
87
78
|
|
88
|
-
# initializer :add_html_formatting do |app|
|
89
|
-
# require_relative "./html_formatting"
|
90
|
-
# Redmine::WikiFormatting.register(:HTML, RedmineExtensions::HTMLFormatting::Formatter, RedmineExtensions::HTMLFormatting::Helper)
|
91
|
-
# end
|
92
|
-
|
93
79
|
end
|
94
80
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module RedmineExtensions
|
2
2
|
class Hooks < Redmine::Hook::ViewListener
|
3
3
|
|
4
|
-
if Rails.env.development?
|
5
|
-
render_on :view_layouts_base_body_bottom, partial: 'redmine_extensions/development_mode'
|
6
|
-
end
|
7
|
-
|
8
4
|
if defined?(EasyExtensions)
|
9
5
|
if EasyExtensions.try(:deferred_js)
|
10
6
|
|
@@ -23,9 +19,6 @@ module RedmineExtensions
|
|
23
19
|
context[:template].require_asset('redmine_extensions/application')
|
24
20
|
end
|
25
21
|
end
|
26
|
-
if Rails.env.development? || Rails.env.test?
|
27
|
-
render_on :view_layouts_base_html_head, partial: 'redmine_extensions/jasmine'
|
28
|
-
end
|
29
22
|
else
|
30
23
|
### JAVASCRIPTS IN REDMINE ###
|
31
24
|
def view_layouts_base_html_head(context = {})
|
@@ -42,8 +35,7 @@ module RedmineExtensions
|
|
42
35
|
javascript_include_tag('redmine_extensions/easy_togglers') +
|
43
36
|
javascript_include_tag('redmine_extensions/jquery.entityarray') +
|
44
37
|
javascript_include_tag('redmine_extensions/render_polyfill') +
|
45
|
-
javascript_include_tag('redmine_extensions/redmine_extensions')
|
46
|
-
(context[:controller].send(:render_to_string, partial: 'redmine_extensions/jasmine') if Rails.env.development? || Rails.env.test?)
|
38
|
+
javascript_include_tag('redmine_extensions/redmine_extensions')
|
47
39
|
end
|
48
40
|
end
|
49
41
|
|
@@ -47,14 +47,14 @@ module RedmineExtensions
|
|
47
47
|
# => :after => 'Project'
|
48
48
|
# => :last
|
49
49
|
# => :if => Proc.new{ Object.const_defined?(:EasyBudgetSheetQuery) }
|
50
|
-
def self.register_patch(original_klasses_to_patch, patching_module, options={})
|
50
|
+
def self.register_patch(original_klasses_to_patch, patching_module, options = {})
|
51
51
|
return if @@reloading_code
|
52
52
|
|
53
53
|
options ||= {}
|
54
54
|
|
55
55
|
begin
|
56
56
|
const = patching_module.constantize
|
57
|
-
@@patches_locations[patching_module] = const.methods(false).map{|m| const.method(m) }.first.source_location.first
|
57
|
+
@@patches_locations[patching_module] = const.methods(false).map { |m| const.method(m) }.first.source_location.first
|
58
58
|
rescue
|
59
59
|
# [0] is register_*_patch
|
60
60
|
from_location = caller_locations(2..2).first
|
@@ -71,7 +71,7 @@ module RedmineExtensions
|
|
71
71
|
raise ArgumentError, 'EasyPatchManager->register_patch: The \'original_klass_to_patch\' have to be a string or array of strings!'
|
72
72
|
end
|
73
73
|
|
74
|
-
raise ArgumentError, "EasyPatchManager->register_patch: The \'patching_module\' (#{patching_module}) already exists!" if EasyPatch.all_patching_modules.include?(
|
74
|
+
raise ArgumentError, "EasyPatchManager->register_patch: The \'patching_module\' (#{patching_module}) already exists!" if EasyPatch.all_patching_modules.include?(patching_module)
|
75
75
|
|
76
76
|
if options[:section]
|
77
77
|
section = options.delete(:section).to_sym
|
@@ -81,47 +81,47 @@ module RedmineExtensions
|
|
81
81
|
raise ArgumentError, "EasyPatchManager->register_patch: The section (#{section}) must be one of x#{@@registered_patches.keys.join(', ')}x " unless @@registered_patches.key?(section)
|
82
82
|
|
83
83
|
original_klasses_to_patch.each do |original_klass_to_patch|
|
84
|
-
pcollection = @@registered_patches[section].move_and_get_or_insert(
|
84
|
+
pcollection = @@registered_patches[section].move_and_get_or_insert(original_klass_to_patch, options)
|
85
85
|
pcollection << EasyPatch.new(original_klass_to_patch, patching_module, options)
|
86
86
|
end
|
87
87
|
end
|
88
|
-
private_class_method :register_patch
|
89
88
|
|
89
|
+
private_class_method :register_patch
|
90
90
|
|
91
|
-
def self.register_ruby_patch(original_klass_to_patch, patching_module, options={})
|
92
|
-
register_patch(original_klass_to_patch, patching_module, {:
|
91
|
+
def self.register_ruby_patch(original_klass_to_patch, patching_module, options = {})
|
92
|
+
register_patch(original_klass_to_patch, patching_module, { section: :ruby }.merge(options))
|
93
93
|
end
|
94
94
|
|
95
|
-
def self.register_rails_patch(original_klass_to_patch, patching_module, options={})
|
96
|
-
register_patch(original_klass_to_patch, patching_module, {:
|
95
|
+
def self.register_rails_patch(original_klass_to_patch, patching_module, options = {})
|
96
|
+
register_patch(original_klass_to_patch, patching_module, { section: :rails }.merge(options))
|
97
97
|
end
|
98
98
|
|
99
|
-
def self.register_redmine_plugin_patch(original_klass_to_patch, patching_module, options={})
|
100
|
-
register_patch(original_klass_to_patch, patching_module, {:section => :redmine_plugins}.merge(options))
|
99
|
+
def self.register_redmine_plugin_patch(original_klass_to_patch, patching_module, options = {})
|
100
|
+
register_patch(original_klass_to_patch, patching_module, { :section => :redmine_plugins }.merge(options))
|
101
101
|
end
|
102
102
|
|
103
|
-
def self.register_other_patch(original_klass_to_patch, patching_module, options={})
|
104
|
-
register_patch(original_klass_to_patch, patching_module, {:section => :others}.merge(options))
|
103
|
+
def self.register_other_patch(original_klass_to_patch, patching_module, options = {})
|
104
|
+
register_patch(original_klass_to_patch, patching_module, { :section => :others }.merge(options))
|
105
105
|
end
|
106
106
|
|
107
|
-
def self.register_concern_patch(original_klass_to_patch, patching_module, options={})
|
108
|
-
register_patch(original_klass_to_patch, patching_module, {:section => :concerns}.merge(options))
|
107
|
+
def self.register_concern_patch(original_klass_to_patch, patching_module, options = {})
|
108
|
+
register_patch(original_klass_to_patch, patching_module, { :section => :concerns }.merge(options))
|
109
109
|
end
|
110
110
|
|
111
|
-
def self.register_controller_patch(original_klass_to_patch, patching_module, options={})
|
112
|
-
register_patch(original_klass_to_patch, patching_module, {:section => :controllers}.merge(options))
|
111
|
+
def self.register_controller_patch(original_klass_to_patch, patching_module, options = {})
|
112
|
+
register_patch(original_klass_to_patch, patching_module, { :section => :controllers }.merge(options))
|
113
113
|
end
|
114
114
|
|
115
|
-
def self.register_helper_patch(original_klass_to_patch, patching_module, options={})
|
116
|
-
register_patch(original_klass_to_patch, patching_module, {:section => :helpers}.merge(options))
|
115
|
+
def self.register_helper_patch(original_klass_to_patch, patching_module, options = {})
|
116
|
+
register_patch(original_klass_to_patch, patching_module, { :section => :helpers }.merge(options))
|
117
117
|
end
|
118
118
|
|
119
|
-
def self.register_model_patch(original_klass_to_patch, patching_module, options={})
|
120
|
-
register_patch(original_klass_to_patch, patching_module, {:section => :models}.merge(options))
|
119
|
+
def self.register_model_patch(original_klass_to_patch, patching_module, options = {})
|
120
|
+
register_patch(original_klass_to_patch, patching_module, { :section => :models }.merge(options))
|
121
121
|
end
|
122
122
|
|
123
|
-
def self.register_patch_to_be_first(original_klass_to_patch, patching_module, options={})
|
124
|
-
register_patch(original_klass_to_patch, patching_module, {:section => :force_first}.merge(options))
|
123
|
+
def self.register_patch_to_be_first(original_klass_to_patch, patching_module, options = {})
|
124
|
+
register_patch(original_klass_to_patch, patching_module, { :section => :force_first }.merge(options))
|
125
125
|
end
|
126
126
|
|
127
127
|
def self.register_easy_page_helper(*helper_or_helpers_klass_name)
|
@@ -208,28 +208,28 @@ module RedmineExtensions
|
|
208
208
|
end
|
209
209
|
|
210
210
|
def [](name)
|
211
|
-
pcollection = @patches_collections.detect{|patch_col| patch_col.name == name }
|
211
|
+
pcollection = @patches_collections.detect { |patch_col| patch_col.name == name }
|
212
212
|
end
|
213
213
|
|
214
214
|
def include_patch?(name)
|
215
|
-
!!@patches_collections.detect{|patch_col| patch_col.name == name }
|
215
|
+
!!@patches_collections.detect { |patch_col| patch_col.name == name }
|
216
216
|
end
|
217
217
|
|
218
|
-
def move_and_get_or_insert(
|
219
|
-
pcollection = @patches_collections.detect{|patch_col| patch_col.name == name }
|
220
|
-
founded_order = find_order(
|
218
|
+
def move_and_get_or_insert(name, options)
|
219
|
+
pcollection = @patches_collections.detect { |patch_col| patch_col.name == name }
|
220
|
+
founded_order = find_order(options)
|
221
221
|
if pcollection
|
222
222
|
if founded_order
|
223
223
|
pcollection.order = founded_order
|
224
224
|
update_order_by(pcollection)
|
225
225
|
end
|
226
226
|
else
|
227
|
-
pcollection = insert(
|
227
|
+
pcollection = insert(name, founded_order)
|
228
228
|
end
|
229
229
|
pcollection
|
230
230
|
end
|
231
231
|
|
232
|
-
def find_order(
|
232
|
+
def find_order(options)
|
233
233
|
if options.delete(:first)
|
234
234
|
return 1
|
235
235
|
elsif before = options.delete(:before)
|
@@ -240,7 +240,7 @@ module RedmineExtensions
|
|
240
240
|
actual = nil
|
241
241
|
before_patch = self[before_class_name]
|
242
242
|
actual = before_patch.order if before_patch
|
243
|
-
if actual && (
|
243
|
+
if actual && (!min || actual < min)
|
244
244
|
min = actual
|
245
245
|
end
|
246
246
|
end
|
@@ -277,7 +277,7 @@ module RedmineExtensions
|
|
277
277
|
|
278
278
|
private
|
279
279
|
|
280
|
-
def push_back(
|
280
|
+
def push_back(collection)
|
281
281
|
# => ambitious, if it is private method...
|
282
282
|
# raise ArgumentError, "Section already contains a collection #{collection.name}" if @patches_collections.detect{ |coll| collection.name == coll.name }
|
283
283
|
@patches_collections << collection
|
@@ -287,16 +287,16 @@ module RedmineExtensions
|
|
287
287
|
@last_order += 1
|
288
288
|
end
|
289
289
|
|
290
|
-
def insert(
|
290
|
+
def insert(name, order = nil)
|
291
291
|
final_order = order || last_order
|
292
|
-
collection = EasyPatchesCollection.new(
|
293
|
-
push_back(
|
294
|
-
update_order_by(
|
292
|
+
collection = EasyPatchesCollection.new(name, final_order)
|
293
|
+
push_back(collection)
|
294
|
+
update_order_by(collection) if order
|
295
295
|
collection
|
296
296
|
end
|
297
297
|
|
298
|
-
def update_order_by(
|
299
|
-
@patches_collections.select {|patch_coll| (
|
298
|
+
def update_order_by(collection)
|
299
|
+
@patches_collections.select { |patch_coll| (patch_coll.name != collection.name) && (patch_coll.order >= collection.order) }.each do |col|
|
300
300
|
col.order = col.order + 1
|
301
301
|
end
|
302
302
|
@patches_collections.sort!
|
@@ -347,7 +347,6 @@ module RedmineExtensions
|
|
347
347
|
|
348
348
|
end
|
349
349
|
|
350
|
-
|
351
350
|
class EasyPatch
|
352
351
|
|
353
352
|
def self.all_patching_modules
|
@@ -374,9 +373,7 @@ module RedmineExtensions
|
|
374
373
|
end
|
375
374
|
|
376
375
|
def apply_patch
|
377
|
-
if (cond = @options[:if]) && cond.respond_to?(:call)
|
378
|
-
return unless cond.call
|
379
|
-
end
|
376
|
+
return if (cond = @options[:if]) && cond.respond_to?(:call) && !cond.call
|
380
377
|
|
381
378
|
pm_klass = easy_constantize(patching_module)
|
382
379
|
# pm_klass.class_eval { unloadable }
|
@@ -392,10 +389,13 @@ module RedmineExtensions
|
|
392
389
|
oktp_klass.include pm_klass
|
393
390
|
end
|
394
391
|
end
|
392
|
+
rescue NameError => e
|
393
|
+
patch_location = Module.const_source_location(patching_module)
|
394
|
+
raise NameError, "#{e.message} in #{patch_location}"
|
395
395
|
end
|
396
396
|
|
397
397
|
def easy_constantize(name)
|
398
|
-
|
398
|
+
name.constantize
|
399
399
|
rescue NameError
|
400
400
|
if RedmineExtensions::PatchManager.patches_locations.has_key?(name)
|
401
401
|
RedmineExtensions::PatchManager.with_reloading_code do
|