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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c44311ddd3f0ebf6e1d4f95955770a545780720121c06fda39b9c54d9c9d0daa
4
- data.tar.gz: cb582aaa8202e30c06d7c60bdc880d240d6175b4fb7b44d6636509a0a4da9c63
3
+ metadata.gz: 22c229302e864612a0df2da35d51c384510fed62e4fd791e154537d2dccd7584
4
+ data.tar.gz: 3f7a97d73f9107a9a203b9ca8418bdfc33ced87d34c52d50ce998a38c50afd77
5
5
  SHA512:
6
- metadata.gz: 756da465d4b28250f4f2fd9ea258660fde6fe75354c39c44d29c5081e47f07dbdaf12a42b2adfcd69f4c12cf6ff37c78f67e486ada7d5e34a1967083f3b4894d
7
- data.tar.gz: 84d6e56e30f677f9dc996ff708bf43d0a754f2e776a3185ca22771a985a9bb471d7f1d44a62f959c194fc864f32556a45d3142b842a396d0e5e4455ffb82c2d6
6
+ metadata.gz: 46524b7ea8d7c189c3c08e54d457ec69839e72acdb66304b9485413a3b629b1e2d81b1a0a3d296b505030b17d7f4e5be0a9bbf0f3c5d759a66758b51095b94e7
7
+ data.tar.gz: ee892966943c3407da7e26918c6ba4f6943174094c9a4b915c63d5874397c1a349c69607289953995f71acf242d64315e3c0ff33c53ec364a5447a0ad6c1ae10
@@ -16,56 +16,56 @@ permissions:
16
16
  contents: read
17
17
 
18
18
  jobs:
19
- # build:
20
- # name: Build gem
21
- # runs-on: ubuntu-latest
19
+ build:
20
+ name: Build gem
21
+ runs-on: ubuntu-latest
22
22
 
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
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
- # steps:
28
- # # Set up
29
- # - uses: actions/checkout@v4
27
+ steps:
28
+ # Set up
29
+ - uses: actions/checkout@v4
30
30
 
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
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
- # - name: Install the gem-release
45
- # run: gem install gem-release
44
+ - name: Install the gem-release
45
+ run: gem install gem-release
46
46
 
47
- # - name: Bump the gem
48
- # run: gem bump --version ${{ github.event.inputs.bump_type }} -p
47
+ - name: Bump the gem
48
+ run: gem bump --version ${{ github.event.inputs.bump_type }} -p
49
49
 
50
- # - name: Remove lock on bundle
51
- # run: bundle config set frozen false
50
+ - name: Remove lock on bundle
51
+ run: bundle config set frozen false
52
52
 
53
- # - name: Bundle Install
54
- # run: bundle install
53
+ - name: Bundle Install
54
+ run: bundle install
55
55
 
56
- # - name: Git Add files
57
- # run: git add Gemfile.lock
56
+ - name: Git Add files
57
+ run: git add Gemfile.lock
58
58
 
59
- # - name: Git Commit
60
- # run: git commit -m "Add bundle files"
59
+ - name: Git Commit
60
+ run: git commit -m "Add bundle files"
61
61
 
62
- # - name: Push the new version
63
- # run: git push origin ${{ github.ref_name }}
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
- # needs: build
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
- GEM_FILE: ${{ env.GEM_FILE }}
102
+ CM_GEMS_PASSWORD: ${{ vars.CM_GEMS_PASSWORD }}
103
103
  CM_GEMS_HOST: ${{ vars.CM_GEMS_HOST }}
104
104
  run: |
105
- gem push $GEM_FILE --host $CM_GEMS_HOST
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.2.1)
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 (7.1.4.1)
20
- actionpack (= 7.1.4.1)
21
- activesupport (= 7.1.4.1)
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 (7.1.4.1)
26
- actionpack (= 7.1.4.1)
27
- activejob (= 7.1.4.1)
28
- activerecord (= 7.1.4.1)
29
- activestorage (= 7.1.4.1)
30
- activesupport (= 7.1.4.1)
31
- mail (>= 2.7.1)
32
- net-imap
33
- net-pop
34
- net-smtp
35
- actionmailer (7.1.4.1)
36
- actionpack (= 7.1.4.1)
37
- actionview (= 7.1.4.1)
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 (7.1.4.1)
46
- actionview (= 7.1.4.1)
47
- activesupport (= 7.1.4.1)
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
- actiontext (7.1.4.1)
56
- actionpack (= 7.1.4.1)
57
- activerecord (= 7.1.4.1)
58
- activestorage (= 7.1.4.1)
59
- activesupport (= 7.1.4.1)
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 (7.1.4.1)
63
- activesupport (= 7.1.4.1)
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 (7.1.4.1)
69
- activesupport (= 7.1.4.1)
62
+ activejob (8.0.0)
63
+ activesupport (= 8.0.0)
70
64
  globalid (>= 0.3.6)
71
- activemodel (7.1.4.1)
72
- activesupport (= 7.1.4.1)
73
- activerecord (7.1.4.1)
74
- activemodel (= 7.1.4.1)
75
- activesupport (= 7.1.4.1)
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 (7.1.4.1)
78
- actionpack (= 7.1.4.1)
79
- activejob (= 7.1.4.1)
80
- activerecord (= 7.1.4.1)
81
- activesupport (= 7.1.4.1)
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 (7.1.4.1)
77
+ activesupport (8.0.0)
84
78
  base64
79
+ benchmark (>= 0.3)
85
80
  bigdecimal
86
- concurrent-ruby (~> 1.0, >= 1.0.2)
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
- mutex_m
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.3.4)
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
- loofah (2.22.0)
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.7)
150
+ mini_portile2 (2.8.8)
152
151
  minitest (5.25.1)
153
- mutex_m (0.2.0)
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.3)
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.1.2)
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.0)
184
+ rackup (2.2.1)
187
185
  rack (>= 3)
188
- webrick (~> 1.8)
189
- rails (7.1.4.1)
190
- actioncable (= 7.1.4.1)
191
- actionmailbox (= 7.1.4.1)
192
- actionmailer (= 7.1.4.1)
193
- actionpack (= 7.1.4.1)
194
- actiontext (= 7.1.4.1)
195
- actionview (= 7.1.4.1)
196
- activejob (= 7.1.4.1)
197
- activemodel (= 7.1.4.1)
198
- activerecord (= 7.1.4.1)
199
- activestorage (= 7.1.4.1)
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 (= 7.1.4.1)
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 (7.1.4.1)
211
- actionpack (= 7.1.4.1)
212
- activesupport (= 7.1.4.1)
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.7.0)
217
+ rdoc (6.8.1)
221
218
  psych (>= 4.0.0)
222
219
  regexp_parser (2.9.2)
223
- reline (0.5.10)
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.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.1)
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.6.18)
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.13
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}Policy::IndexScope".constantize.new(Current.user, @model.name.constantize).resolve
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}Policy::ShowScope".constantize.new(Current.user, @model.name.constantize).resolve
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::#{@action.name.classify}Scope".constantize.new(Current.user, @model.name.constantize).resolve
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::#{params[:action_name].classify}Scope".constantize.new(Current.user, @model.name.constantize).resolve
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::#{action_name.classify}Scope".constantize.new(Current.user, @model.ar_model.name.classify.constantize).resolve
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::#{@current_action.name.classify}Scope".constantize.new(Current.user, @model.name.constantize).resolve if records.nil?
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::#{action_name.classify}Scope".constantize.new(Current.user, klass).resolve
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])
@@ -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::ItemPolicy::ArchiveScope.new(Current.user, ::Item).resolve
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = '4.2.1'
2
+ VERSION = '4.3.0'
3
3
  end
@@ -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::#{custom_action.name.classify}Scope".constantize.new(Current.user, @model.name.constantize).resolve
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
- return if CmAdmin::Model.find_by({ name: entity.name })
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
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+
3
+ URL="$2/upload"
4
+
5
+ USERNAME="$1"
6
+ PASSWORD="$1"
7
+
8
+ GEM_FILE=$(ls *.gem | tail -n 1)
9
+
10
+ curl -X POST "$URL" \
11
+ -u "$USERNAME:$PASSWORD" \
12
+ -F "file=@$GEM_FILE"
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.2.1
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-16 00:00:00.000000000 Z
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
@@ -1,5 +0,0 @@
1
- ---
2
- :hosts:
3
- d83830bbef49f4bc@cm-gems.commutatus.com:
4
- :username: d83830bbef49f4bc
5
- :password: d83830bbef49f4bc
@@ -1,9 +0,0 @@
1
- ActiveSupport.on_load(:active_record) do
2
- module ActiveRecord
3
- class Base
4
- def self.cm_admin(&block)
5
- CmAdmin.initialize_model(self, &block)
6
- end
7
- end
8
- end
9
- end