redmine_extensions 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/redmine_extensions/_development_mode.html.erb +33 -0
- data/lib/redmine_extensions/engine.rb +1 -4
- data/lib/redmine_extensions/hooks.rb +5 -0
- data/lib/redmine_extensions/patch_manager.rb +56 -3
- data/lib/redmine_extensions/version.rb +1 -1
- metadata +3 -5
- data/lib/redmine_extensions/easy_entity_formatters/easy_entity_formatter.rb +0 -27
- data/lib/redmine_extensions/easy_query_adapter.rb +0 -175
- data/lib/redmine_extensions/redmine_patches/patches.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f421201ad531afbd5de4df6dbaabcdb76a0118d
|
4
|
+
data.tar.gz: f8590c69aeb9812efdfe110682fff9f91d9ba900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2f2030116481690fdae03a6c749a4bd367c7bf69a37685acaeed8a62f2e2cb21d37afac4bc4a32ec68792a5e9a9212aa8775217adfd420fdf3ec93c32292225
|
7
|
+
data.tar.gz: 04ba05638b6a38cd141ad892c71ff7fc3771e308f7638200bce082e4ed060e6a3182f5dda0a226caa499280d31351156811ece6c28303992b8a5414e660989e7
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<% if RedmineExtensions::PatchManager.reloadable_patches_applied > 1 %>
|
2
|
+
<div class="patches-applied">
|
3
|
+
<i class="icon icon-reload"></i> Patches applied (<%= RedmineExtensions::PatchManager.reloadable_patches_applied %>x)
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<style>
|
7
|
+
.patches-applied {
|
8
|
+
position: fixed;
|
9
|
+
bottom: 0;
|
10
|
+
left: 0;
|
11
|
+
padding: 2px 10px;
|
12
|
+
background: #f44336;
|
13
|
+
border-top: 1px solid #b71c1c;
|
14
|
+
border-right: 1px solid #b71c1c;
|
15
|
+
animation: patches-applied-pulse 2s 5;
|
16
|
+
color: #fff;
|
17
|
+
z-index: 9999999;
|
18
|
+
}
|
19
|
+
|
20
|
+
@keyframes patches-applied-pulse {
|
21
|
+
0% {
|
22
|
+
box-shadow: 0 0 0 0 rgba(229, 115, 115, 0.4);
|
23
|
+
}
|
24
|
+
70% {
|
25
|
+
box-shadow: 0 0 0 20px rgba(229, 115, 115, 0);
|
26
|
+
}
|
27
|
+
100% {
|
28
|
+
box-shadow: 0 0 0 0 rgba(229, 115, 115, 0);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
</style>
|
32
|
+
<% end %>
|
33
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'active_support/dependencies'
|
2
2
|
require_relative './patch_manager'
|
3
|
-
require_relative './redmine_patches/
|
3
|
+
require_relative './redmine_patches/controllers/application_controller_patch'
|
4
4
|
|
5
5
|
require_relative './query_output'
|
6
6
|
|
@@ -70,9 +70,6 @@ module RedmineExtensions
|
|
70
70
|
unless Redmine::Plugin.installed?(:easy_extensions)
|
71
71
|
ActiveSupport.run_load_hooks(:easyproject, self)
|
72
72
|
end
|
73
|
-
|
74
|
-
require_relative './easy_query_adapter'
|
75
|
-
require_relative './easy_entity_formatters/easy_entity_formatter'
|
76
73
|
end
|
77
74
|
|
78
75
|
# initializer :add_html_formatting do |app|
|
@@ -1,6 +1,10 @@
|
|
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
|
+
|
4
8
|
if defined?(EasyExtensions)
|
5
9
|
if EasyExtensions.try(:deferred_js)
|
6
10
|
|
@@ -37,5 +41,6 @@ module RedmineExtensions
|
|
37
41
|
javascript_include_tag('redmine_extensions/redmine_extensions')
|
38
42
|
end
|
39
43
|
end
|
44
|
+
|
40
45
|
end
|
41
46
|
end
|
@@ -4,6 +4,11 @@ module RedmineExtensions
|
|
4
4
|
|
5
5
|
PERSISTING_PATCHES = [:force_first, :ruby, :rails, :redmine_plugins, :others]
|
6
6
|
|
7
|
+
@@patches_locations = {}
|
8
|
+
|
9
|
+
@@reloading_code = false
|
10
|
+
@@reloadable_patches_applied = 0
|
11
|
+
|
7
12
|
# is called after EasyPatchesSection load
|
8
13
|
def self.initialize_sections
|
9
14
|
@@registered_patches ||= ActiveSupport::OrderedHash.new
|
@@ -18,6 +23,20 @@ module RedmineExtensions
|
|
18
23
|
@@registered_patches[:models] ||= EasyPatchesSection.new
|
19
24
|
end
|
20
25
|
|
26
|
+
def self.patches_locations
|
27
|
+
@@patches_locations
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.with_reloading_code
|
31
|
+
@@reloading_code = true
|
32
|
+
yield
|
33
|
+
ensure
|
34
|
+
@@reloading_code = false
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.reloadable_patches_applied
|
38
|
+
@@reloadable_patches_applied
|
39
|
+
end
|
21
40
|
|
22
41
|
# register_patch
|
23
42
|
# => original_klass_to_patch: 'Project', 'CustomField'
|
@@ -29,8 +48,19 @@ module RedmineExtensions
|
|
29
48
|
# => :last
|
30
49
|
# => :if => Proc.new{ Object.const_defined?(:EasyBudgetSheetQuery) }
|
31
50
|
def self.register_patch(original_klasses_to_patch, patching_module, options={})
|
51
|
+
return if @@reloading_code
|
52
|
+
|
32
53
|
options ||= {}
|
33
54
|
|
55
|
+
begin
|
56
|
+
const = patching_module.constantize
|
57
|
+
@@patches_locations[patching_module] = const.methods(false).map{|m| const.method(m) }.first.source_location.first
|
58
|
+
rescue
|
59
|
+
# [0] is register_*_patch
|
60
|
+
from_location = caller_locations[1]
|
61
|
+
@@patches_locations[patching_module] = from_location.absolute_path
|
62
|
+
end
|
63
|
+
|
34
64
|
raise ArgumentError, 'EasyPatchManager->register_patch: The \'patching_module\' have to be a string!' unless patching_module.is_a?(String)
|
35
65
|
|
36
66
|
if original_klasses_to_patch.is_a?(String)
|
@@ -136,14 +166,21 @@ module RedmineExtensions
|
|
136
166
|
|
137
167
|
def self.apply_reloadable_patches
|
138
168
|
(@@registered_patches.keys - PERSISTING_PATCHES).each do |section|
|
139
|
-
|
169
|
+
reloading_log "Applying #{section} patches (#{@@registered_patches[section].count})"
|
140
170
|
@@registered_patches[section].apply_all_patches
|
141
171
|
end
|
142
172
|
|
173
|
+
reloading_log("Applying page module patches")
|
143
174
|
apply_easy_page_patches
|
175
|
+
|
176
|
+
@@reloadable_patches_applied += 1
|
144
177
|
true
|
145
178
|
end
|
146
179
|
|
180
|
+
def self.reloading_log(message)
|
181
|
+
return if @@reloadable_patches_applied <= 1
|
182
|
+
puts "PatchManager: #{message}"
|
183
|
+
end
|
147
184
|
|
148
185
|
class EasyPatchesSection
|
149
186
|
include Enumerable
|
@@ -349,8 +386,10 @@ module RedmineExtensions
|
|
349
386
|
return unless cond.call
|
350
387
|
end
|
351
388
|
|
352
|
-
pm_klass = patching_module
|
353
|
-
|
389
|
+
pm_klass = easy_constantize(patching_module)
|
390
|
+
# pm_klass.class_eval { unloadable }
|
391
|
+
|
392
|
+
oktp_klass = easy_constantize(original_klass_to_patch)
|
354
393
|
|
355
394
|
if @options[:prepend]
|
356
395
|
oktp_klass.prepend pm_klass # unless oktp_klass.include?(pm_klass)
|
@@ -359,6 +398,20 @@ module RedmineExtensions
|
|
359
398
|
end
|
360
399
|
end
|
361
400
|
|
401
|
+
def easy_constantize(name)
|
402
|
+
const = name.constantize
|
403
|
+
rescue NameError
|
404
|
+
if RedmineExtensions::PatchManager.patches_locations.has_key?(name)
|
405
|
+
RedmineExtensions::PatchManager.with_reloading_code do
|
406
|
+
load RedmineExtensions::PatchManager.patches_locations[patching_module]
|
407
|
+
end
|
408
|
+
|
409
|
+
name.constantize
|
410
|
+
else
|
411
|
+
raise
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
362
415
|
end
|
363
416
|
|
364
417
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Easy Software Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- app/views/easy_queries/_index.html.erb
|
182
182
|
- app/views/easy_queries/_settings.html.erb
|
183
183
|
- app/views/easy_settings/edit.html.erb
|
184
|
+
- app/views/redmine_extensions/_development_mode.html.erb
|
184
185
|
- config/locales/cs.yml
|
185
186
|
- config/locales/en.yml
|
186
187
|
- config/routes.rb
|
@@ -238,9 +239,7 @@ files:
|
|
238
239
|
- lib/redmine_extensions/core_ext/object.rb
|
239
240
|
- lib/redmine_extensions/core_ext/string.rb
|
240
241
|
- lib/redmine_extensions/deprecator.rb
|
241
|
-
- lib/redmine_extensions/easy_entity_formatters/easy_entity_formatter.rb
|
242
242
|
- lib/redmine_extensions/easy_form_builder.rb
|
243
|
-
- lib/redmine_extensions/easy_query_adapter.rb
|
244
243
|
- lib/redmine_extensions/easy_query_helpers/outputs.rb
|
245
244
|
- lib/redmine_extensions/easy_settings.rb
|
246
245
|
- lib/redmine_extensions/easy_settings/form_model.rb
|
@@ -264,7 +263,6 @@ files:
|
|
264
263
|
- lib/redmine_extensions/rails_patches/form_builder_patch.rb
|
265
264
|
- lib/redmine_extensions/rails_patches/route_set_generator_patch.rb
|
266
265
|
- lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
|
267
|
-
- lib/redmine_extensions/redmine_patches/patches.rb
|
268
266
|
- lib/redmine_extensions/tags/autocomplete_field.rb
|
269
267
|
- lib/redmine_extensions/version.rb
|
270
268
|
- lib/tasks/redmine_extensions_tasks.rake
|
@@ -1,27 +0,0 @@
|
|
1
|
-
class EasyEntityFormatter
|
2
|
-
|
3
|
-
def initialize(view_context)
|
4
|
-
@view_context = view_context
|
5
|
-
end
|
6
|
-
|
7
|
-
def view
|
8
|
-
@view_context
|
9
|
-
end
|
10
|
-
|
11
|
-
def l(*args)
|
12
|
-
view.l(*args)
|
13
|
-
end
|
14
|
-
|
15
|
-
def format_column(column, entity)
|
16
|
-
format_object column.value_object(entity)
|
17
|
-
end
|
18
|
-
|
19
|
-
def format_object(value)
|
20
|
-
view.format_object(value)
|
21
|
-
end
|
22
|
-
|
23
|
-
def ending_buttons?
|
24
|
-
false
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
@@ -1,175 +0,0 @@
|
|
1
|
-
require 'query'
|
2
|
-
|
3
|
-
module RedmineExtensions
|
4
|
-
module QueryColumnAdapter
|
5
|
-
def self.included(base)
|
6
|
-
base.extend ClassMethods
|
7
|
-
base.include InstanceMethods
|
8
|
-
|
9
|
-
base.class_eval do
|
10
|
-
attr_accessor :includes
|
11
|
-
attr_accessor :joins
|
12
|
-
attr_accessor :preload
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module InstanceMethods
|
17
|
-
end
|
18
|
-
|
19
|
-
module ClassMethods
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
module QueryAdapter
|
24
|
-
|
25
|
-
attr_writer :outputs
|
26
|
-
|
27
|
-
def outputs
|
28
|
-
@outputs ||= ['list']
|
29
|
-
end
|
30
|
-
|
31
|
-
def output=(output_t)
|
32
|
-
self.outputs = Array.wrap(output_t)
|
33
|
-
end
|
34
|
-
|
35
|
-
def default_find_include
|
36
|
-
[].freeze
|
37
|
-
end
|
38
|
-
|
39
|
-
def default_find_preload
|
40
|
-
[].freeze
|
41
|
-
end
|
42
|
-
|
43
|
-
def default_find_joins
|
44
|
-
[].freeze
|
45
|
-
end
|
46
|
-
|
47
|
-
def default_list_columns
|
48
|
-
[].freeze
|
49
|
-
end
|
50
|
-
|
51
|
-
def formatter
|
52
|
-
@formatter
|
53
|
-
end
|
54
|
-
|
55
|
-
def init_formatter(object)
|
56
|
-
return @formatter if @formatter
|
57
|
-
|
58
|
-
if entity
|
59
|
-
begin
|
60
|
-
formatter_klass = "#{entity}Formatter".constantize
|
61
|
-
rescue NameError
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
formatter_klass ||= EasyEntityFormatter
|
66
|
-
@formatter = formatter_klass.new(object)
|
67
|
-
end
|
68
|
-
|
69
|
-
def entity
|
70
|
-
self.class.queried_class
|
71
|
-
end
|
72
|
-
|
73
|
-
def entity_scope
|
74
|
-
if !@entity_scope.nil?
|
75
|
-
@entity_scope
|
76
|
-
elsif entity.respond_to?(:visible)
|
77
|
-
entity.visible
|
78
|
-
else
|
79
|
-
entity
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def set_entity_scope(entity, reference_collection = nil)
|
84
|
-
return nil if entity.nil? || reference_collection.nil?
|
85
|
-
|
86
|
-
@entity_scope = entity.send(reference_collection.to_sym)
|
87
|
-
|
88
|
-
self.filters = {}
|
89
|
-
|
90
|
-
@entity_scope
|
91
|
-
end
|
92
|
-
|
93
|
-
def create_entity_scope(options={})
|
94
|
-
scope = entity_scope.where(statement)
|
95
|
-
|
96
|
-
includes = default_find_include.dup
|
97
|
-
includes.concat(Array.wrap(options[:includes]))
|
98
|
-
|
99
|
-
preload = default_find_preload.dup
|
100
|
-
preload.concat(Array.wrap(options[:preload]))
|
101
|
-
|
102
|
-
joins = default_find_joins.dup
|
103
|
-
joins.concat(Array.wrap(options[:joins]))
|
104
|
-
|
105
|
-
filters.keys.each do |filter|
|
106
|
-
f = available_filters[filter]
|
107
|
-
next if f.blank?
|
108
|
-
|
109
|
-
includes.concat(Array.wrap(f[:includes])) if f[:includes]
|
110
|
-
joins.concat(Array.wrap(f[:joins])) if f[:joins]
|
111
|
-
end if filters
|
112
|
-
|
113
|
-
columns.each do |c|
|
114
|
-
includes.concat(Array.wrap(c.includes)) if c.includes
|
115
|
-
joins.concat(Array.wrap(c.joins)) if c.joins
|
116
|
-
preload.concat(Array.wrap(c.preload)) if c.preload
|
117
|
-
end
|
118
|
-
|
119
|
-
if project
|
120
|
-
includes << :project
|
121
|
-
end
|
122
|
-
|
123
|
-
includes.uniq!
|
124
|
-
joins.uniq!
|
125
|
-
preload.uniq!
|
126
|
-
|
127
|
-
scope.includes(includes).references(includes).joins(joins).preload(preload)
|
128
|
-
end
|
129
|
-
|
130
|
-
def entities(options={})
|
131
|
-
create_entity_scope(options).order(options[:order]).to_a
|
132
|
-
end
|
133
|
-
|
134
|
-
def add_available_column(name, options={})
|
135
|
-
@available_columns ||= []
|
136
|
-
|
137
|
-
@available_columns << QueryColumn.new(name.to_sym, options)
|
138
|
-
end
|
139
|
-
|
140
|
-
def to_partial_path
|
141
|
-
'easy_queries/index'
|
142
|
-
end
|
143
|
-
|
144
|
-
def default_columns_names
|
145
|
-
default_list_columns
|
146
|
-
end
|
147
|
-
|
148
|
-
def queried_table_name
|
149
|
-
entity.table_name
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
module QueryAdapterDefaults
|
155
|
-
|
156
|
-
def initialize(attributes=nil, *args)
|
157
|
-
super
|
158
|
-
self.filters ||= {}
|
159
|
-
end
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
end
|
164
|
-
|
165
|
-
class EasyQueryAdapter < Query
|
166
|
-
end
|
167
|
-
|
168
|
-
if Redmine::Plugin.installed?(:easy_extensions)
|
169
|
-
# EasyQuery exist
|
170
|
-
else
|
171
|
-
QueryColumn.include RedmineExtensions::QueryColumnAdapter
|
172
|
-
RedmineExtensions::PatchManager.register_model_patch('Query', 'RedmineExtensions::QueryAdapter')
|
173
|
-
EasyQuery = EasyQueryAdapter
|
174
|
-
EasyQuery.prepend RedmineExtensions::QueryAdapterDefaults
|
175
|
-
end
|