cm-admin 0.8.7 → 0.8.8

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: 7c6cf3d2c260e9964ab1aa9865d14af11fe287e49b6216ae260ae575567c0e89
4
- data.tar.gz: 495df145a9060198ca69bfd1eaeea836b6bba24287a804e69d100fab5d36cbd1
3
+ metadata.gz: 1b0716af97418b0a394649987f80dc9ccffa7ebe3476f53c71be4ffee7d3121f
4
+ data.tar.gz: c920089946afedbe268496bd0a8cb05d44dd950aad3c5b5dd7eb296180700871
5
5
  SHA512:
6
- metadata.gz: 03b3e0f445067d05f32313a7c4e519545ee6396eca549e75719de294380df8be3be2d5e95c6dfcf262d563eb5db4cd8e3ebabcae753075a4b61f69a6957c5c1d
7
- data.tar.gz: 498e3dfb9d3580fa69bfaf959df282567590cbdee12d2ad3bc65fcbb7f7101c70fd9d7d5aba2e78ea6a09547afe0fc4161dd478495110bcfe8efe3887e0d7040
6
+ metadata.gz: e7e2cea04419473813adb4d3d5500bf6fb3e5a897aaf0572387c9a42bff4207e1a7539b4314e1d6bea138b76708788018f9c30ac3132e685da992f0b649e4a6a
7
+ data.tar.gz: 95cda0809b447a0cce7cc4b20ffce7308a74ec8feac2b91e0b63ac02060472abe2fb360e8c44a525a3609be956ce18d7adb232b64a730911b93ce59951e19e33
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cm-admin (0.8.7)
4
+ cm-admin (0.8.8)
5
5
  caxlsx_rails
6
6
  cocoon (~> 1.2.15)
7
7
  csv-importer (~> 0.8.2)
@@ -38,7 +38,7 @@ GEM
38
38
  ice_nine (~> 0.11.0)
39
39
  thread_safe (~> 0.3, >= 0.3.1)
40
40
  builder (3.2.4)
41
- caxlsx (3.2.0)
41
+ caxlsx (3.3.0)
42
42
  htmlentities (~> 4.3, >= 4.3.4)
43
43
  marcel (~> 1.0)
44
44
  nokogiri (~> 1.10, >= 1.10.4)
@@ -69,7 +69,7 @@ GEM
69
69
  method_source (1.0.0)
70
70
  mini_portile2 (2.8.0)
71
71
  minitest (5.16.2)
72
- nokogiri (1.13.8)
72
+ nokogiri (1.13.9)
73
73
  mini_portile2 (~> 2.8.0)
74
74
  racc (~> 1.4)
75
75
  pagy (4.11.0)
@@ -146,7 +146,7 @@ GEM
146
146
  rack-proxy (>= 0.6.1)
147
147
  railties (>= 5.2)
148
148
  semantic_range (>= 2.3.0)
149
- zeitwerk (2.6.1)
149
+ zeitwerk (2.6.4)
150
150
 
151
151
  PLATFORMS
152
152
  ruby
@@ -72,7 +72,7 @@ a {
72
72
  position: sticky;
73
73
  top: 0;
74
74
  background-color: #fff;
75
- z-index: 1;
75
+ z-index: 4;
76
76
  }
77
77
 
78
78
  .scrollable {
@@ -6,7 +6,6 @@
6
6
  overflow: auto;
7
7
 
8
8
  .sticky-container {
9
- z-index: 4;
10
9
  .cm-filters-v2 {
11
10
  padding: 16px 24px 36px 24px;
12
11
  }
@@ -153,22 +153,25 @@ module CmAdmin
153
153
  end
154
154
 
155
155
  def custom_controller_action(action_name, params)
156
- current_action = CmAdmin::Models::Action.find_by(@model, name: action_name.to_s)
157
- if current_action
158
- @current_action = current_action
159
- @ar_object = @model.ar_model.name.classify.constantize.find(params[:id])
160
- if @current_action.child_records
161
- child_records = @ar_object.send(@current_action.child_records)
162
- @associated_model = CmAdmin::Model.find_by(name: @model.ar_model.reflect_on_association(@current_action.child_records).klass.name)
163
- if child_records.is_a? ActiveRecord::Relation
164
- @associated_ar_object = filter_by(params, child_records, @associated_model.filter_params(params))
165
- else
166
- @associated_ar_object = child_records
167
- end
168
- return @ar_object, @associated_model, @associated_ar_object
169
- end
170
- return @ar_object
171
- end
156
+ @current_action = CmAdmin::Models::Action.find_by(@model, name: action_name.to_s)
157
+ return unless @current_action
158
+
159
+ @ar_object = @model.ar_model.name.classify.constantize.find(params[:id])
160
+ return @ar_object unless @current_action.child_records
161
+
162
+ child_records = @ar_object.send(@current_action.child_records)
163
+ @reflection = @model.ar_model.reflect_on_association(@current_action.child_records)
164
+ @associated_model = if @reflection.klass.column_names.include?('type')
165
+ CmAdmin::Model.find_by(name: @reflection.plural_name.classify)
166
+ else
167
+ CmAdmin::Model.find_by(name: @reflection.klass.name)
168
+ end
169
+ @associated_ar_object = if child_records.is_a? ActiveRecord::Relation
170
+ filter_by(params, child_records, @associated_model.filter_params(params))
171
+ else
172
+ child_records
173
+ end
174
+ return @ar_object, @associated_model, @associated_ar_object
172
175
  end
173
176
 
174
177
  def filter_by(params, records, filter_params={}, sort_params={})
@@ -176,7 +179,7 @@ module CmAdmin
176
179
  sort_column = "created_at"
177
180
  sort_direction = %w[asc desc].include?(sort_params[:sort_direction]) ? sort_params[:sort_direction] : "asc"
178
181
  sort_params = {sort_column: sort_column, sort_direction: sort_direction}
179
-
182
+
180
183
  records = "CmAdmin::#{@model.name}Policy::Scope".constantize.new(Current.user, @model.name.constantize).resolve if records.nil?
181
184
  records = records.order("#{@current_action.sort_column} #{@current_action.sort_direction}")
182
185
  final_data = CmAdmin::Models::Filter.filtered_data(filter_params, records, @associated_model ? @associated_model.filters : @model.filters)
data/lib/cm-admin.rb ADDED
@@ -0,0 +1 @@
1
+ require 'cm_admin'
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = "0.8.7"
2
+ VERSION = "0.8.8"
3
3
  end
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: 0.8.7
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - sajinmp
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-10-22 00:00:00.000000000 Z
13
+ date: 2022-11-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: caxlsx_rails
@@ -231,6 +231,7 @@ files:
231
231
  - config/webpack/test.js
232
232
  - config/webpacker.yml
233
233
  - lib/.DS_Store
234
+ - lib/cm-admin.rb
234
235
  - lib/cm_admin.rb
235
236
  - lib/cm_admin/configuration.rb
236
237
  - lib/cm_admin/constants.rb
@@ -316,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
317
  - !ruby/object:Gem::Version
317
318
  version: '0'
318
319
  requirements: []
319
- rubygems_version: 3.2.3
320
+ rubygems_version: 3.2.33
320
321
  signing_key:
321
322
  specification_version: 4
322
323
  summary: This is an admin panel gem