cm-admin 4.2.1 → 4.3.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/.github/workflows/release-cm-gem.yml +38 -38
- data/Gemfile.lock +82 -83
- data/app/controllers/cm_admin/resource_controller.rb +6 -6
- data/app/models/concerns/exportable.rb +1 -1
- data/docs/RoleManagement.md +1 -1
- data/lib/cm_admin/model.rb +5 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/page_info_helper.rb +1 -1
- data/lib/cm_admin.rb +16 -2
- data/upload.sh +12 -0
- metadata +3 -4
- data/.gem/credentials +0 -5
- data/config/initializers/active_record_extension.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22c229302e864612a0df2da35d51c384510fed62e4fd791e154537d2dccd7584
|
4
|
+
data.tar.gz: 3f7a97d73f9107a9a203b9ca8418bdfc33ced87d34c52d50ce998a38c50afd77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46524b7ea8d7c189c3c08e54d457ec69839e72acdb66304b9485413a3b629b1e2d81b1a0a3d296b505030b17d7f4e5be0a9bbf0f3c5d759a66758b51095b94e7
|
7
|
+
data.tar.gz: ee892966943c3407da7e26918c6ba4f6943174094c9a4b915c63d5874397c1a349c69607289953995f71acf242d64315e3c0ff33c53ec364a5447a0ad6c1ae10
|
@@ -16,56 +16,56 @@ permissions:
|
|
16
16
|
contents: read
|
17
17
|
|
18
18
|
jobs:
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
build:
|
20
|
+
name: Build gem
|
21
|
+
runs-on: ubuntu-latest
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
permissions:
|
24
|
+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
25
|
+
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
steps:
|
28
|
+
# Set up
|
29
|
+
- uses: actions/checkout@v4
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
31
|
+
- name: set git config
|
32
|
+
env:
|
33
|
+
GH_TOKEN: ${{ github.token }}
|
34
|
+
run: |
|
35
|
+
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
|
36
|
+
git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)"
|
37
|
+
git config -l
|
38
|
+
- name: Set up Ruby
|
39
|
+
uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
bundler-cache: true
|
42
|
+
ruby-version: ruby
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
- name: Install the gem-release
|
45
|
+
run: gem install gem-release
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
- name: Bump the gem
|
48
|
+
run: gem bump --version ${{ github.event.inputs.bump_type }} -p
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
- name: Remove lock on bundle
|
51
|
+
run: bundle config set frozen false
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
- name: Bundle Install
|
54
|
+
run: bundle install
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
- name: Git Add files
|
57
|
+
run: git add Gemfile.lock
|
58
58
|
|
59
|
-
|
60
|
-
|
59
|
+
- name: Git Commit
|
60
|
+
run: git commit -m "Add bundle files"
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
- name: Push the new version
|
63
|
+
run: git push origin ${{ github.ref_name }}
|
64
64
|
|
65
65
|
release:
|
66
66
|
name: Release gem
|
67
67
|
runs-on: ubuntu-latest
|
68
|
-
|
68
|
+
needs: build
|
69
69
|
permissions:
|
70
70
|
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
71
71
|
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
|
@@ -99,7 +99,7 @@ jobs:
|
|
99
99
|
|
100
100
|
- name: Push gem
|
101
101
|
env:
|
102
|
-
|
102
|
+
CM_GEMS_PASSWORD: ${{ vars.CM_GEMS_PASSWORD }}
|
103
103
|
CM_GEMS_HOST: ${{ vars.CM_GEMS_HOST }}
|
104
104
|
run: |
|
105
|
-
|
105
|
+
./upload.sh $CM_GEMS_PASSWORD $CM_GEMS_HOST
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cm-admin (4.
|
4
|
+
cm-admin (4.3.0)
|
5
5
|
caxlsx_rails
|
6
6
|
cocoon (~> 1.2.15)
|
7
7
|
csv (>= 3.3.0)
|
@@ -16,86 +16,84 @@ PATH
|
|
16
16
|
GEM
|
17
17
|
remote: https://rubygems.org/
|
18
18
|
specs:
|
19
|
-
actioncable (
|
20
|
-
actionpack (=
|
21
|
-
activesupport (=
|
19
|
+
actioncable (8.0.0)
|
20
|
+
actionpack (= 8.0.0)
|
21
|
+
activesupport (= 8.0.0)
|
22
22
|
nio4r (~> 2.0)
|
23
23
|
websocket-driver (>= 0.6.1)
|
24
24
|
zeitwerk (~> 2.6)
|
25
|
-
actionmailbox (
|
26
|
-
actionpack (=
|
27
|
-
activejob (=
|
28
|
-
activerecord (=
|
29
|
-
activestorage (=
|
30
|
-
activesupport (=
|
31
|
-
mail (>= 2.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
activejob (= 7.1.4.1)
|
39
|
-
activesupport (= 7.1.4.1)
|
40
|
-
mail (~> 2.5, >= 2.5.4)
|
41
|
-
net-imap
|
42
|
-
net-pop
|
43
|
-
net-smtp
|
25
|
+
actionmailbox (8.0.0)
|
26
|
+
actionpack (= 8.0.0)
|
27
|
+
activejob (= 8.0.0)
|
28
|
+
activerecord (= 8.0.0)
|
29
|
+
activestorage (= 8.0.0)
|
30
|
+
activesupport (= 8.0.0)
|
31
|
+
mail (>= 2.8.0)
|
32
|
+
actionmailer (8.0.0)
|
33
|
+
actionpack (= 8.0.0)
|
34
|
+
actionview (= 8.0.0)
|
35
|
+
activejob (= 8.0.0)
|
36
|
+
activesupport (= 8.0.0)
|
37
|
+
mail (>= 2.8.0)
|
44
38
|
rails-dom-testing (~> 2.2)
|
45
|
-
actionpack (
|
46
|
-
actionview (=
|
47
|
-
activesupport (=
|
39
|
+
actionpack (8.0.0)
|
40
|
+
actionview (= 8.0.0)
|
41
|
+
activesupport (= 8.0.0)
|
48
42
|
nokogiri (>= 1.8.5)
|
49
|
-
racc
|
50
43
|
rack (>= 2.2.4)
|
51
44
|
rack-session (>= 1.0.1)
|
52
45
|
rack-test (>= 0.6.3)
|
53
46
|
rails-dom-testing (~> 2.2)
|
54
47
|
rails-html-sanitizer (~> 1.6)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
48
|
+
useragent (~> 0.16)
|
49
|
+
actiontext (8.0.0)
|
50
|
+
actionpack (= 8.0.0)
|
51
|
+
activerecord (= 8.0.0)
|
52
|
+
activestorage (= 8.0.0)
|
53
|
+
activesupport (= 8.0.0)
|
60
54
|
globalid (>= 0.6.0)
|
61
55
|
nokogiri (>= 1.8.5)
|
62
|
-
actionview (
|
63
|
-
activesupport (=
|
56
|
+
actionview (8.0.0)
|
57
|
+
activesupport (= 8.0.0)
|
64
58
|
builder (~> 3.1)
|
65
59
|
erubi (~> 1.11)
|
66
60
|
rails-dom-testing (~> 2.2)
|
67
61
|
rails-html-sanitizer (~> 1.6)
|
68
|
-
activejob (
|
69
|
-
activesupport (=
|
62
|
+
activejob (8.0.0)
|
63
|
+
activesupport (= 8.0.0)
|
70
64
|
globalid (>= 0.3.6)
|
71
|
-
activemodel (
|
72
|
-
activesupport (=
|
73
|
-
activerecord (
|
74
|
-
activemodel (=
|
75
|
-
activesupport (=
|
65
|
+
activemodel (8.0.0)
|
66
|
+
activesupport (= 8.0.0)
|
67
|
+
activerecord (8.0.0)
|
68
|
+
activemodel (= 8.0.0)
|
69
|
+
activesupport (= 8.0.0)
|
76
70
|
timeout (>= 0.4.0)
|
77
|
-
activestorage (
|
78
|
-
actionpack (=
|
79
|
-
activejob (=
|
80
|
-
activerecord (=
|
81
|
-
activesupport (=
|
71
|
+
activestorage (8.0.0)
|
72
|
+
actionpack (= 8.0.0)
|
73
|
+
activejob (= 8.0.0)
|
74
|
+
activerecord (= 8.0.0)
|
75
|
+
activesupport (= 8.0.0)
|
82
76
|
marcel (~> 1.0)
|
83
|
-
activesupport (
|
77
|
+
activesupport (8.0.0)
|
84
78
|
base64
|
79
|
+
benchmark (>= 0.3)
|
85
80
|
bigdecimal
|
86
|
-
concurrent-ruby (~> 1.0, >= 1.
|
81
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
87
82
|
connection_pool (>= 2.2.5)
|
88
83
|
drb
|
89
84
|
i18n (>= 1.6, < 2)
|
85
|
+
logger (>= 1.4.2)
|
90
86
|
minitest (>= 5.1)
|
91
|
-
|
92
|
-
tzinfo (~> 2.0)
|
87
|
+
securerandom (>= 0.3)
|
88
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
89
|
+
uri (>= 0.13.1)
|
93
90
|
ast (2.4.2)
|
94
91
|
axiom-types (0.1.1)
|
95
92
|
descendants_tracker (~> 0.0.4)
|
96
93
|
ice_nine (~> 0.11.0)
|
97
94
|
thread_safe (~> 0.3, >= 0.3.1)
|
98
95
|
base64 (0.2.0)
|
96
|
+
benchmark (0.4.0)
|
99
97
|
bigdecimal (3.1.8)
|
100
98
|
builder (3.3.0)
|
101
99
|
caxlsx (4.1.0)
|
@@ -115,7 +113,7 @@ GEM
|
|
115
113
|
csv (3.3.0)
|
116
114
|
csv-importer (0.8.2)
|
117
115
|
virtus
|
118
|
-
date (3.
|
116
|
+
date (3.4.0)
|
119
117
|
descendants_tracker (0.0.4)
|
120
118
|
thread_safe (~> 0.3, >= 0.3.1)
|
121
119
|
diff-lcs (1.5.1)
|
@@ -138,7 +136,8 @@ GEM
|
|
138
136
|
json (2.7.2)
|
139
137
|
language_server-protocol (3.17.0.3)
|
140
138
|
local_time (3.0.2)
|
141
|
-
|
139
|
+
logger (1.6.1)
|
140
|
+
loofah (2.23.1)
|
142
141
|
crass (~> 1.0.2)
|
143
142
|
nokogiri (>= 1.12.0)
|
144
143
|
mail (2.8.1)
|
@@ -148,10 +147,9 @@ GEM
|
|
148
147
|
net-smtp
|
149
148
|
marcel (1.0.4)
|
150
149
|
mini_mime (1.1.5)
|
151
|
-
mini_portile2 (2.8.
|
150
|
+
mini_portile2 (2.8.8)
|
152
151
|
minitest (5.25.1)
|
153
|
-
|
154
|
-
net-imap (0.4.17)
|
152
|
+
net-imap (0.5.1)
|
155
153
|
date
|
156
154
|
net-protocol
|
157
155
|
net-pop (0.1.2)
|
@@ -160,7 +158,7 @@ GEM
|
|
160
158
|
timeout
|
161
159
|
net-smtp (0.5.0)
|
162
160
|
net-protocol
|
163
|
-
nio4r (2.7.
|
161
|
+
nio4r (2.7.4)
|
164
162
|
nokogiri (1.16.7)
|
165
163
|
mini_portile2 (~> 2.8.2)
|
166
164
|
racc (~> 1.4)
|
@@ -173,7 +171,7 @@ GEM
|
|
173
171
|
parser (3.3.5.0)
|
174
172
|
ast (~> 2.4.1)
|
175
173
|
racc
|
176
|
-
psych (5.
|
174
|
+
psych (5.2.0)
|
177
175
|
stringio
|
178
176
|
pundit (2.2.0)
|
179
177
|
activesupport (>= 3.0.0)
|
@@ -183,23 +181,22 @@ GEM
|
|
183
181
|
rack (>= 3.0.0)
|
184
182
|
rack-test (2.1.0)
|
185
183
|
rack (>= 1.3)
|
186
|
-
rackup (2.1
|
184
|
+
rackup (2.2.1)
|
187
185
|
rack (>= 3)
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
activesupport (= 7.1.4.1)
|
186
|
+
rails (8.0.0)
|
187
|
+
actioncable (= 8.0.0)
|
188
|
+
actionmailbox (= 8.0.0)
|
189
|
+
actionmailer (= 8.0.0)
|
190
|
+
actionpack (= 8.0.0)
|
191
|
+
actiontext (= 8.0.0)
|
192
|
+
actionview (= 8.0.0)
|
193
|
+
activejob (= 8.0.0)
|
194
|
+
activemodel (= 8.0.0)
|
195
|
+
activerecord (= 8.0.0)
|
196
|
+
activestorage (= 8.0.0)
|
197
|
+
activesupport (= 8.0.0)
|
201
198
|
bundler (>= 1.15.0)
|
202
|
-
railties (=
|
199
|
+
railties (= 8.0.0)
|
203
200
|
rails-dom-testing (2.2.0)
|
204
201
|
activesupport (>= 5.0.0)
|
205
202
|
minitest
|
@@ -207,20 +204,20 @@ GEM
|
|
207
204
|
rails-html-sanitizer (1.6.0)
|
208
205
|
loofah (~> 2.21)
|
209
206
|
nokogiri (~> 1.14)
|
210
|
-
railties (
|
211
|
-
actionpack (=
|
212
|
-
activesupport (=
|
213
|
-
irb
|
207
|
+
railties (8.0.0)
|
208
|
+
actionpack (= 8.0.0)
|
209
|
+
activesupport (= 8.0.0)
|
210
|
+
irb (~> 1.13)
|
214
211
|
rackup (>= 1.0.0)
|
215
212
|
rake (>= 12.2)
|
216
213
|
thor (~> 1.0, >= 1.2.2)
|
217
214
|
zeitwerk (~> 2.6)
|
218
215
|
rainbow (3.1.1)
|
219
216
|
rake (12.3.3)
|
220
|
-
rdoc (6.
|
217
|
+
rdoc (6.8.1)
|
221
218
|
psych (>= 4.0.0)
|
222
219
|
regexp_parser (2.9.2)
|
223
|
-
reline (0.5.
|
220
|
+
reline (0.5.11)
|
224
221
|
io-console (~> 0.5)
|
225
222
|
rspec (3.13.0)
|
226
223
|
rspec-core (~> 3.13.0)
|
@@ -257,27 +254,29 @@ GEM
|
|
257
254
|
rubocop-ast (>= 1.31.1, < 2.0)
|
258
255
|
ruby-progressbar (1.13.0)
|
259
256
|
rubyzip (2.3.2)
|
257
|
+
securerandom (0.3.2)
|
260
258
|
slim (4.1.0)
|
261
259
|
temple (>= 0.7.6, < 0.9)
|
262
260
|
tilt (>= 2.0.6, < 2.1)
|
263
|
-
stringio (3.1.
|
261
|
+
stringio (3.1.2)
|
264
262
|
temple (0.8.2)
|
265
263
|
thor (1.3.2)
|
266
264
|
thread_safe (0.3.6)
|
267
265
|
tilt (2.0.11)
|
268
|
-
timeout (0.4.
|
266
|
+
timeout (0.4.2)
|
269
267
|
tzinfo (2.0.6)
|
270
268
|
concurrent-ruby (~> 1.0)
|
271
269
|
unicode-display_width (2.6.0)
|
270
|
+
uri (1.0.2)
|
271
|
+
useragent (0.16.10)
|
272
272
|
virtus (2.0.0)
|
273
273
|
axiom-types (~> 0.1)
|
274
274
|
coercible (~> 1.0)
|
275
275
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
276
|
-
webrick (1.8.2)
|
277
276
|
websocket-driver (0.7.6)
|
278
277
|
websocket-extensions (>= 0.1.0)
|
279
278
|
websocket-extensions (0.1.5)
|
280
|
-
zeitwerk (2.
|
279
|
+
zeitwerk (2.7.1)
|
281
280
|
|
282
281
|
PLATFORMS
|
283
282
|
arm64-darwin-20
|
@@ -299,4 +298,4 @@ DEPENDENCIES
|
|
299
298
|
slim
|
300
299
|
|
301
300
|
BUNDLED WITH
|
302
|
-
2.5.
|
301
|
+
2.5.9
|
@@ -12,7 +12,7 @@ module CmAdmin
|
|
12
12
|
@current_action = CmAdmin::Models::Action.find_by(@model, name: 'index')
|
13
13
|
# Based on the params the filter and pagination object to be set
|
14
14
|
authorize @ar_object, policy_class: "CmAdmin::#{controller_name.classify}Policy".constantize if defined? "CmAdmin::#{controller_name.classify}Policy".constantize
|
15
|
-
records = "CmAdmin::#{@model.name}
|
15
|
+
records = "CmAdmin::#{@model.name}PolicyIndexScope".constantize.new(Current.user, @model.name.constantize).resolve
|
16
16
|
records = records.includes(@current_action.eager_load_associations) if @current_action.eager_load_associations.present?
|
17
17
|
records = apply_scopes(records)
|
18
18
|
@ar_object = if %w[table card].include?(params[:view_type]) || %i[table card].include?(@current_action.view_type)
|
@@ -35,7 +35,7 @@ module CmAdmin
|
|
35
35
|
|
36
36
|
def cm_show(params)
|
37
37
|
@current_action = CmAdmin::Models::Action.find_by(@model, name: 'show')
|
38
|
-
scoped_model = "CmAdmin::#{@model.name}
|
38
|
+
scoped_model = "CmAdmin::#{@model.name}PolicyShowScope".constantize.new(Current.user, @model.name.constantize).resolve
|
39
39
|
@ar_object = fetch_ar_object(scoped_model, params[:id])
|
40
40
|
@alerts = @model.alerts
|
41
41
|
resource_identifier
|
@@ -161,7 +161,7 @@ module CmAdmin
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def cm_custom_method(params)
|
164
|
-
records = "CmAdmin::#{@model.name}Policy
|
164
|
+
records = "CmAdmin::#{@model.name}Policy#{@action.name.classify}Scope".constantize.new(Current.user, @model.name.constantize).resolve
|
165
165
|
@current_action = @action
|
166
166
|
if @action.parent == 'index'
|
167
167
|
records = apply_scopes(records)
|
@@ -204,7 +204,7 @@ module CmAdmin
|
|
204
204
|
end
|
205
205
|
|
206
206
|
def cm_custom_action_modal(params)
|
207
|
-
scoped_model = "CmAdmin::#{@model.name}Policy
|
207
|
+
scoped_model = "CmAdmin::#{@model.name}Policy#{params[:action_name].classify}Scope".constantize.new(Current.user, @model.name.constantize).resolve
|
208
208
|
@ar_object = fetch_ar_object(scoped_model, params[:id])
|
209
209
|
if params[:action_name] == 'destroy'
|
210
210
|
render partial: '/layouts/destroy_action_modal', locals: { ar_object: @ar_object, from_action: 'custom_action_modal' }
|
@@ -302,7 +302,7 @@ module CmAdmin
|
|
302
302
|
@current_action = CmAdmin::Models::Action.find_by(@model, name: action_name.to_s)
|
303
303
|
return unless @current_action
|
304
304
|
|
305
|
-
scoped_model = "CmAdmin::#{@model.name}Policy
|
305
|
+
scoped_model = "CmAdmin::#{@model.name}Policy#{action_name.classify}Scope".constantize.new(Current.user, @model.ar_model.name.classify.constantize).resolve
|
306
306
|
@ar_object = fetch_ar_object(scoped_model, params[:id])
|
307
307
|
return @ar_object unless @current_action.child_records
|
308
308
|
|
@@ -341,7 +341,7 @@ module CmAdmin
|
|
341
341
|
cm_model.default_sort_column
|
342
342
|
end
|
343
343
|
sort_direction = params[:sort_direction] || cm_model.default_sort_direction
|
344
|
-
records = "CmAdmin::#{@model.name}Policy
|
344
|
+
records = "CmAdmin::#{@model.name}Policy#{@current_action.name.classify}Scope".constantize.new(Current.user, @model.name.constantize).resolve if records.nil?
|
345
345
|
records = records.order("#{sort_column} #{sort_direction}") if sort_column.present?
|
346
346
|
final_data = CmAdmin::Models::Filter.filtered_data(filter_params, records, cm_model.filters)
|
347
347
|
pagy, records = pagy(final_data)
|
@@ -21,7 +21,7 @@ module Exportable
|
|
21
21
|
current_action = CmAdmin::Models::Action.find_by(model, name: action_name)
|
22
22
|
|
23
23
|
if associated_klass_name.present? && params[:parent_id].present?
|
24
|
-
scoped_model = "CmAdmin::#{model.name}Policy
|
24
|
+
scoped_model = "CmAdmin::#{model.name}Policy#{action_name.classify}Scope".constantize.new(Current.user, klass).resolve
|
25
25
|
parent_model = model
|
26
26
|
model = CmAdmin::Model.find_by({ name: associated_klass_name })
|
27
27
|
parent_record = fetch_ar_object(scoped_model, params[:parent_id])
|
data/docs/RoleManagement.md
CHANGED
@@ -116,7 +116,7 @@ tab :details, '' do
|
|
116
116
|
row do
|
117
117
|
cm_show_section 'Details' do
|
118
118
|
field :status, field_type: :tag, tag_class: Item::STATUS_TAG_COLOR, display_if: -> (record) {
|
119
|
-
scoped_model = CmAdmin::
|
119
|
+
scoped_model = CmAdmin::ItemPolicyArchiveScope.new(Current.user, ::Item).resolve
|
120
120
|
return scoped_model.find_by(id: record.id).present?
|
121
121
|
}
|
122
122
|
end
|
data/lib/cm_admin/model.rb
CHANGED
@@ -64,6 +64,10 @@ module CmAdmin
|
|
64
64
|
def find_by(search_hash)
|
65
65
|
CmAdmin.config.cm_admin_models.find { |x| x.name == search_hash[:name] }
|
66
66
|
end
|
67
|
+
|
68
|
+
def delete_entity(entity_name)
|
69
|
+
CmAdmin.config.cm_admin_models.delete_if { |x| x.name == entity_name }
|
70
|
+
end
|
67
71
|
end
|
68
72
|
|
69
73
|
def custom_controller_action(action_name, params)
|
@@ -225,7 +229,7 @@ module CmAdmin
|
|
225
229
|
|
226
230
|
attr_reader :user, :scope
|
227
231
|
end
|
228
|
-
|
232
|
+
CmAdmin.const_set "#{ar_model.name}Policy#{action.name.classify}Scope", klass
|
229
233
|
policy.const_set "#{action.name.classify}Scope", klass
|
230
234
|
end
|
231
235
|
end
|
data/lib/cm_admin/version.rb
CHANGED
@@ -41,7 +41,7 @@ module CmAdmin
|
|
41
41
|
action_name = "#{custom_action.name}?".to_sym
|
42
42
|
return unless custom_action.name.present? && policy([:cm_admin, @model.name.classify.constantize]).respond_to?(action_name) && policy([:cm_admin, @model.name.classify.constantize]).send(action_name)
|
43
43
|
|
44
|
-
scoped_model = "CmAdmin::#{@model.name}Policy
|
44
|
+
scoped_model = "CmAdmin::#{@model.name}Policy#{custom_action.name.classify}Scope".constantize.new(Current.user, @model.name.constantize).resolve
|
45
45
|
has_scoped_record = if current_action_name == 'index'
|
46
46
|
scoped_model.present?
|
47
47
|
else
|
data/lib/cm_admin.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'zeitwerk'
|
1
2
|
require 'slim'
|
2
3
|
require 'cm_admin/version'
|
3
4
|
require 'cm_admin/engine'
|
@@ -6,7 +7,20 @@ require 'cm_admin/view_helpers'
|
|
6
7
|
require 'cm_admin/utils'
|
7
8
|
require 'cm_admin/configuration'
|
8
9
|
|
10
|
+
ActiveSupport.on_load(:active_record) do
|
11
|
+
module ActiveRecord
|
12
|
+
class Base
|
13
|
+
def self.cm_admin(&block)
|
14
|
+
CmAdmin.initialize_model(self, &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
9
20
|
module CmAdmin
|
21
|
+
# autoload :Model, 'cm_admin/model'
|
22
|
+
# autoload :ViewHelpers, 'cm_admin/view_helpers'
|
23
|
+
|
10
24
|
class Error < StandardError; end
|
11
25
|
|
12
26
|
mattr_accessor :layout, :authorized_roles
|
@@ -30,9 +44,9 @@ module CmAdmin
|
|
30
44
|
|
31
45
|
def initialize_model(entity, &block)
|
32
46
|
return unless entity.is_a?(Class)
|
33
|
-
|
47
|
+
CmAdmin::Model.delete_entity(entity.name) if CmAdmin::Model.find_by({ name: entity.name })
|
34
48
|
|
35
49
|
config.cm_admin_models << CmAdmin::Model.new(entity, &block)
|
36
50
|
end
|
37
51
|
end
|
38
|
-
end
|
52
|
+
end
|
data/upload.sh
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: exe
|
16
16
|
cert_chain: []
|
17
|
-
date: 2024-12-
|
17
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: caxlsx_rails
|
@@ -172,7 +172,6 @@ executables: []
|
|
172
172
|
extensions: []
|
173
173
|
extra_rdoc_files: []
|
174
174
|
files:
|
175
|
-
- ".gem/credentials"
|
176
175
|
- ".github/CODEOWNERS"
|
177
176
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
178
177
|
- ".github/ISSUE_TEMPLATE/config.yml"
|
@@ -422,7 +421,6 @@ files:
|
|
422
421
|
- bin/setup
|
423
422
|
- cm_admin.gemspec
|
424
423
|
- config/importmap.rb
|
425
|
-
- config/initializers/active_record_extension.rb
|
426
424
|
- config/routes.rb
|
427
425
|
- docs/AddingAlert.md
|
428
426
|
- docs/CustomFilterMethod.md
|
@@ -499,6 +497,7 @@ files:
|
|
499
497
|
- package-lock.json
|
500
498
|
- package.json
|
501
499
|
- postcss.config.js
|
500
|
+
- upload.sh
|
502
501
|
- yarn.lock
|
503
502
|
homepage: https://github.com/commutatus/cm-admin
|
504
503
|
licenses:
|
data/.gem/credentials
DELETED