redmine_nonproject_modules 0.3.13 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88b51cb0833e8a780aec7e675021595329310eec2a02b4ee5832394bf26b2458
4
- data.tar.gz: fe397fd0f0d46ef361c445b059262cf1d502c16e8f152ebd9bab58f26026eafc
3
+ metadata.gz: 9c393719a43c09b1fcaa018311f53571ba1943532d1254f17c7e3248b30ac285
4
+ data.tar.gz: aabcd0192dbede3d36b45e15c52930826bd84d7967404cc6448a833dd36f1da6
5
5
  SHA512:
6
- metadata.gz: bd3beb69e696bb50702929177b9aa8fd4c1ebf6de789d37d2e0d26f6630bb43ef9633e02c7c29ec47af9a2e9d26fcd5b15a66ce30ba816de16b2ad52e36bd0eb
7
- data.tar.gz: 69c0bbfe878852c912732d172f181d9da3ac19fa09de76fd7ff1e41983c54be067fa15ec7a47ebceb3f830fb2c06d0697d84cbd8aaabf8a6850b1bc60dbf9684
6
+ metadata.gz: c052d43b5619ddf692720f3da0c54facf5baf72c6a9e6afdaea0f9ac40bcecdde6758f74710776805bd0f3b0f89feb8a1a46c9494874c3a0c7476eec8fe94f11
7
+ data.tar.gz: b207fa51fb6d973da1f537265edd40883ffac3e27ade190f65d416c07b93ccff456361b49513fcd35f4f4edd907a96ef8414152389266db79dfe7612c2235d18
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_rails_utils/models/tableless'
4
4
 
5
- class GroupMerge < ::EacRailsUtils::Models::Tableless
5
+ class GroupMerge < EacRailsUtils::Models::Tableless
6
6
  ONLY_ON_TARGET = :only_on_target
7
7
  ONLY_ON_SOURCE = :only_on_source
8
8
  ON_BOTH = :on_both
@@ -12,9 +12,6 @@ class GroupMerge < ::EacRailsUtils::Models::Tableless
12
12
  belongs_to :source, class_name: 'Group'
13
13
  belongs_to :target, class_name: 'Group'
14
14
 
15
- validates :source, presence: true
16
- validates :target, presence: true
17
-
18
15
  def to_merge_elements
19
16
  (target_elements + source_elements).uniq.map do |x|
20
17
  [x[0], element_on_status(x)]
@@ -2,11 +2,10 @@
2
2
 
3
3
  require 'eac_ruby_utils/simple_cache'
4
4
 
5
- class GroupPermission < ActiveRecord::Base
5
+ class GroupPermission < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
6
6
  belongs_to :group
7
7
 
8
- validates :group, presence: true
9
- validates :permission, presence: true, uniqueness: { scope: [:group],
8
+ validates :permission, presence: true, uniqueness: { scope: [:group], # rubocop:disable Rails/UniqueValidationWithoutIndex
10
9
  case_sensitive: false }
11
10
 
12
11
  def permission=(value)
@@ -27,7 +26,7 @@ class GroupPermission < ActiveRecord::Base
27
26
  permission(key).description
28
27
  end
29
28
 
30
- def permission?(permission, user = false)
29
+ def permission?(permission, user = false) # rubocop:disable Style/OptionalBooleanParameter
31
30
  return permission_by_hash?(permission, user) if permission.is_a?(Hash)
32
31
 
33
32
  permission(permission).user_has?(user || User.current)
@@ -3,5 +3,6 @@
3
3
  require 'redmine_nonproject_modules/patches/controller_patch'
4
4
  require 'redmine_nonproject_modules/patches/group_patch'
5
5
  require 'redmine_nonproject_modules/patches/redmine/i18n_patch'
6
- require 'redmine_nonproject_modules/patches/redmine/menu_manager_patch'
6
+ require 'redmine_nonproject_modules/patches/redmine/menu_manager/mapper'
7
+ require 'redmine_nonproject_modules/patches/redmine/plugin'
7
8
  require 'redmine_nonproject_modules/patches/user_patch'
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ::GroupPermission.add_permission('group_permissions')
4
- ::GroupPermission.add_permission('group_merge')
3
+ GroupPermission.add_permission('group_permissions')
4
+ GroupPermission.add_permission('group_merge')
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'i18n/backend/recursive_lookup'
4
+ I18n::Backend::Simple.include I18n::Backend::RecursiveLookup
data/init.rb CHANGED
@@ -4,18 +4,13 @@ require 'active_scaffold'
4
4
  require 'jquery/rails'
5
5
 
6
6
  require 'redmine'
7
-
8
- require 'redmine_nonproject_modules/patches/controller_patch'
9
- require 'redmine_nonproject_modules/patches/group_patch'
10
- require 'redmine_nonproject_modules/patches/redmine/i18n_patch'
11
- require 'redmine_nonproject_modules/patches/redmine/menu_manager_patch'
12
7
  require 'redmine_nonproject_modules/version'
13
8
 
14
9
  Redmine::Plugin.register :redmine_nonproject_modules do
15
10
  name 'Redmine non-project modules'
16
- author ::RedmineNonprojectModules::AUTHOR
17
- description ::RedmineNonprojectModules::SUMMARY
18
- version ::RedmineNonprojectModules::VERSION
19
- url ::RedmineNonprojectModules::HOMEPAGE
11
+ author RedmineNonprojectModules::AUTHOR
12
+ description RedmineNonprojectModules::SUMMARY
13
+ version RedmineNonprojectModules::VERSION
14
+ url RedmineNonprojectModules::HOMEPAGE
20
15
  author_url 'https://github.com/eduardobogoni'
21
16
  end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module RedmineNonprojectModules
6
+ class MenuControllerEntry
7
+ # @!method initialize(controller, options = {})
8
+ # @param controller [String]
9
+ # @param options [Hash]
10
+ common_constructor :controller, :options, default: [{}] do
11
+ self.controller = controller.to_s
12
+ self.options = options.with_indifferent_access
13
+ end
14
+
15
+ def build
16
+ [build_name, build_url, build_options]
17
+ end
18
+
19
+ def permissions
20
+ parse_permissions(permissions_const)
21
+ end
22
+
23
+ private
24
+
25
+ def build_name
26
+ r = controller
27
+ r = "#{r}_#{action}" unless action == 'index'
28
+ r.to_sym
29
+ end
30
+
31
+ def build_url
32
+ { controller: controller, action: action, id: id }
33
+ end
34
+
35
+ def build_options
36
+ {
37
+ caption: build_caption,
38
+ if: proc { GroupPermission.permission?(permissions_const) }
39
+ }
40
+ end
41
+
42
+ def build_caption
43
+ "label_#{build_name}".to_sym
44
+ end
45
+
46
+ def controller_class
47
+ Object.const_get("#{controller.camelize}Controller")
48
+ end
49
+
50
+ def action
51
+ options[:action] || 'index'
52
+ end
53
+
54
+ def id
55
+ options[:id]
56
+ end
57
+
58
+ def permissions_const
59
+ controller_class.const_get('PERMISSIONS')
60
+ end
61
+
62
+ def parse_permissions(permission)
63
+ return parse_permissions(permission.values) if permission.is_a?(Hash)
64
+ return permission.flat_map { |v| parse_permissions(v) } if permission.is_a?(Enumerable)
65
+
66
+ [permission.to_s]
67
+ end
68
+ end
69
+ end
@@ -28,5 +28,7 @@ end
28
28
  unless ActionController::Base.included_modules.include?(
29
29
  RedmineNonprojectModules::Patches::ControllerPatch
30
30
  )
31
- ActionController::Base.include RedmineNonprojectModules::Patches::ControllerPatch
31
+ ActiveSupport.on_load(:action_controller) do
32
+ include RedmineNonprojectModules::Patches::ControllerPatch
33
+ end
32
34
  end
@@ -22,6 +22,6 @@ module RedmineNonprojectModules
22
22
  end
23
23
  end
24
24
 
25
- unless ::Group.included_modules.include?(RedmineNonprojectModules::Patches::GroupPatch)
26
- ::Group.include RedmineNonprojectModules::Patches::GroupPatch
25
+ unless Group.included_modules.include?(RedmineNonprojectModules::Patches::GroupPatch)
26
+ Group.include RedmineNonprojectModules::Patches::GroupPatch
27
27
  end
@@ -23,7 +23,7 @@ module RedmineNonprojectModules
23
23
  end
24
24
  end
25
25
 
26
- x = ::Redmine::I18n
27
- y = ::RedmineNonprojectModules::Patches::Redmine::I18nPatch
26
+ x = Redmine::I18n
27
+ y = RedmineNonprojectModules::Patches::Redmine::I18nPatch
28
28
 
29
29
  x.send(:include, y) unless x.included_modules.include?(y)
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RedmineNonprojectModules
4
+ module Patches
5
+ module Redmine
6
+ module MenuManagerMapperPatch
7
+ def push_controller(*args)
8
+ e = ::RedmineNonprojectModules::MenuControllerEntry.new(*args)
9
+ push(*e.build)
10
+ e.permissions.each do |p|
11
+ ::GroupPermission.add_permission(p)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Redmine::MenuManager::Mapper
20
+ .include(RedmineNonprojectModules::Patches::Redmine::MenuManagerMapperPatch)
@@ -3,92 +3,31 @@
3
3
  module RedmineNonprojectModules
4
4
  module Patches
5
5
  module Redmine
6
- module MenuManagerMapperPatch
7
- def self.included(base)
8
- base.send(:include, InstanceMethods)
9
- end
10
- end
11
-
12
- module InstanceMethods
13
- def push_controller(*args)
14
- e = ControllerEntry.new(*args)
15
- push(*e.build)
16
- e.permissions.each do |p|
17
- ::GroupPermission.add_permission(p)
6
+ module MenuManager
7
+ module Mapper
8
+ def self.included(base)
9
+ base.send(:include, InstanceMethods)
18
10
  end
19
11
  end
20
- end
21
-
22
- class ControllerEntry
23
- def initialize(controller, options = {})
24
- @controller = controller.to_s
25
- @options = options.with_indifferent_access
26
- end
27
-
28
- def build
29
- [build_name, build_url, build_options]
30
- end
31
-
32
- def permissions
33
- parse_permissions(permissions_const)
34
- end
35
-
36
- private
37
-
38
- attr_reader :controller, :options
39
-
40
- def build_name
41
- r = controller
42
- r = "#{r}_#{action}" unless action == 'index'
43
- r.to_sym
44
- end
45
-
46
- def build_url
47
- { controller: controller, action: action, id: id }
48
- end
49
-
50
- def build_options
51
- {
52
- caption: build_caption,
53
- if: proc { GroupPermission.permission?(permissions_const) }
54
- }
55
- end
56
-
57
- def build_caption
58
- "label_#{build_name}".to_sym
59
- end
60
-
61
- def controller_class
62
- Object.const_get("#{controller.camelize}Controller")
63
- end
64
12
 
65
- def action
66
- @options[:action] || 'index'
67
- end
68
-
69
- def id
70
- @options[:id]
71
- end
72
-
73
- def permissions_const
74
- controller_class.const_get('PERMISSIONS')
75
- end
76
-
77
- def parse_permissions(permission)
78
- return parse_permissions(permission.values) if permission.is_a?(Hash)
79
- return permission.flat_map { |v| parse_permissions(v) } if permission.is_a?(Enumerable)
80
-
81
- [permission.to_s]
13
+ module InstanceMethods
14
+ def push_controller(*args)
15
+ e = ::RedmineNonprojectModules::MenuControllerEntry.new(*args)
16
+ push(*e.build)
17
+ e.permissions.each do |p|
18
+ ::GroupPermission.add_permission(p)
19
+ end
20
+ end
82
21
  end
83
22
  end
84
23
  end
85
24
  end
86
25
  end
87
26
 
88
- unless ::Redmine::MenuManager::Mapper.included_modules.include?(
89
- ::RedmineNonprojectModules::Patches::Redmine::MenuManagerMapperPatch
27
+ unless Redmine::MenuManager::Mapper.included_modules.include?(
28
+ RedmineNonprojectModules::Patches::Redmine::MenuManager::Mapper
90
29
  )
91
- ::Redmine::MenuManager::Mapper.include(
92
- ::RedmineNonprojectModules::Patches::Redmine::MenuManagerMapperPatch
30
+ Redmine::MenuManager::Mapper.include(
31
+ RedmineNonprojectModules::Patches::Redmine::MenuManager::Mapper
93
32
  )
94
33
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module RedmineNonprojectModules
6
+ module Patches
7
+ module Redmine
8
+ module Plugin
9
+ common_concern
10
+
11
+ def nonprojects_menu(&block)
12
+ ::Redmine::MenuManager.map(id, &block)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Redmine::Plugin.include(RedmineNonprojectModules::Patches::Redmine::Plugin)
@@ -16,6 +16,6 @@ module RedmineNonprojectModules
16
16
  end
17
17
  end
18
18
 
19
- unless ::User.included_modules.include?(RedmineNonprojectModules::Patches::UserPatch)
20
- ::User.include RedmineNonprojectModules::Patches::UserPatch
19
+ unless User.included_modules.include?(RedmineNonprojectModules::Patches::UserPatch)
20
+ User.include RedmineNonprojectModules::Patches::UserPatch
21
21
  end
@@ -4,5 +4,5 @@ module RedmineNonprojectModules
4
4
  AUTHOR = 'Eduardo Henrique Bogoni'
5
5
  HOMEPAGE = 'https://github.com/esquilo-azul/redmine_nonproject_modules'
6
6
  SUMMARY = 'Support to non-project modules.'
7
- VERSION = '0.3.13'
7
+ VERSION = '0.5.0'
8
8
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'redmine_plugins_helper/test_tasks/rspec'
4
- ::RedminePluginsHelper::TestTasks::Rspec.register(:redmine_nonproject_modules, :test)
4
+ RedminePluginsHelper::TestTasks::Rspec.register(:redmine_nonproject_modules, :test)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_nonproject_modules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.13
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
- - 0.3.13
7
+ - 0.5.0
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-20 00:00:00.000000000 Z
11
+ date: 2023-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_active_scaffold
@@ -36,14 +36,20 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.21'
39
+ version: '0.22'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.22.2
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
47
  - - "~>"
45
48
  - !ruby/object:Gem::Version
46
- version: '0.21'
49
+ version: '0.22'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.22.2
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: eac_ruby_utils
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -64,6 +70,26 @@ dependencies:
64
70
  - - ">="
65
71
  - !ruby/object:Gem::Version
66
72
  version: 0.119.2
73
+ - !ruby/object:Gem::Dependency
74
+ name: i18n-recursive-lookup
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.0'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.0.5
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.0'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 0.0.5
67
93
  - !ruby/object:Gem::Dependency
68
94
  name: jquery-rails
69
95
  requirement: !ruby/object:Gem::Requirement
@@ -84,14 +110,14 @@ dependencies:
84
110
  requirements:
85
111
  - - "~>"
86
112
  - !ruby/object:Gem::Version
87
- version: 0.5.1
113
+ version: 0.8.1
88
114
  type: :development
89
115
  prerelease: false
90
116
  version_requirements: !ruby/object:Gem::Requirement
91
117
  requirements:
92
118
  - - "~>"
93
119
  - !ruby/object:Gem::Version
94
- version: 0.5.1
120
+ version: 0.8.1
95
121
  description:
96
122
  email:
97
123
  executables: []
@@ -119,6 +145,7 @@ files:
119
145
  - config/initializers/001_patches.rb
120
146
  - config/initializers/assets.rb
121
147
  - config/initializers/group_permissions.rb
148
+ - config/initializers/i18n.rb
122
149
  - config/initializers/menus.rb
123
150
  - config/locales/en.yml
124
151
  - config/locales/pt-BR.yml
@@ -126,10 +153,13 @@ files:
126
153
  - init.rb
127
154
  - lib/redmine_nonproject_modules.rb
128
155
  - lib/redmine_nonproject_modules/dispatcher_finder.rb
156
+ - lib/redmine_nonproject_modules/menu_controller_entry.rb
129
157
  - lib/redmine_nonproject_modules/patches/controller_patch.rb
130
158
  - lib/redmine_nonproject_modules/patches/group_patch.rb
131
159
  - lib/redmine_nonproject_modules/patches/redmine/i18n_patch.rb
160
+ - lib/redmine_nonproject_modules/patches/redmine/menu_manager/mapper.rb
132
161
  - lib/redmine_nonproject_modules/patches/redmine/menu_manager_patch.rb
162
+ - lib/redmine_nonproject_modules/patches/redmine/plugin.rb
133
163
  - lib/redmine_nonproject_modules/patches/user_patch.rb
134
164
  - lib/redmine_nonproject_modules/version.rb
135
165
  - lib/tasks/redmine_nonproject_modules.rake
@@ -144,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
174
  requirements:
145
175
  - - ">="
146
176
  - !ruby/object:Gem::Version
147
- version: '0'
177
+ version: 2.7.0
148
178
  required_rubygems_version: !ruby/object:Gem::Requirement
149
179
  requirements:
150
180
  - - ">="