motor-admin 0.2.49 → 0.2.54

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: d1454fff2b666e21bca8bff4acf49f1be8d5cbeae176356c051a879f46f78226
4
- data.tar.gz: 8c027639c95b04a69e337b8cd5749ed65babeb0df755855fd6ba423cbe8214e5
3
+ metadata.gz: 15b533466db4a33c9391b0b6b01ccc843db7f69641e45b94588f8fd73b58bdd6
4
+ data.tar.gz: 1eca4eb32893da6b571a24e6ce75fa58c2290c759e973fea99186a5e795d2bca
5
5
  SHA512:
6
- metadata.gz: b6e22434dd4b722606f31ecfdc5ed2e0c6e547b115b097dc8f00e885765649cd45be069d19984d72ac8e2cca91544b3fd7c16d8393c7e4aa801e3c77a88c5fa5
7
- data.tar.gz: 77839d0bfb147200dfaf46b8e4b105b15ed1230c5fd85cab0954bccd454b76c83229d8fd7cd09a56c558741657be25372eac5c9411d982133d57fc9f117eefc8
6
+ metadata.gz: 1526cd8885184c8e4e3b8863f7a5c3c5a6adc240c5dc6cd976a5e804f0538635973977f6bb7dcb23c8042a6997817e529d7ff368fe349d5236c13528ff704301
7
+ data.tar.gz: 202b9a9b155b23ae205c278d1301d5d58e7eaf19571d2d0b8d539635586c2227d49b72bcbf3a605c2b98e85da5545161ddc46c27837c4343f2a281c981874f04
@@ -300,3 +300,4 @@ en:
300
300
  expand: Expand
301
301
  add_api: Add API
302
302
  on_collection: On collection
303
+ association: Association
@@ -300,6 +300,7 @@ es:
300
300
  expand: Expandir
301
301
  add_api: De API
302
302
  on_collection: En la colección
303
+ association: Asociación
303
304
  i:
304
305
  locale: es
305
306
  select:
@@ -296,6 +296,7 @@ pt:
296
296
  expand: Expandir
297
297
  add_api: De API
298
298
  on_collection: Na coleção
299
+ association: Associação
299
300
  i:
300
301
  locale: pt
301
302
  select:
data/lib/motor/admin.rb CHANGED
@@ -109,6 +109,8 @@ module Motor
109
109
  ' to perform data migration and enable the latest features'
110
110
  puts
111
111
  end
112
+ rescue ActiveRecord::NoDatabaseError
113
+ nil
112
114
  end
113
115
  end
114
116
  end
@@ -21,7 +21,9 @@ module Motor
21
21
 
22
22
  def filter_associations(associations, ability)
23
23
  associations.select do |assoc|
24
- ability.can?(:read, assoc[:model_name].classify.constantize)
24
+ model_class = assoc[:model_name].classify.safe_constantize
25
+
26
+ model_class && ability.can?(:read, model_class)
25
27
  end
26
28
  end
27
29
 
@@ -29,8 +31,11 @@ module Motor
29
31
  columns.map do |column|
30
32
  next unless ability.can?(:read, model, column[:name])
31
33
 
32
- next if column.dig(:reference, :model_name).present? &&
33
- !ability.can?(:read, column[:reference][:model_name].classify.constantize)
34
+ reference_model_name = column.dig(:reference, :model_name)
35
+ model_class = reference_model_name&.classify&.safe_constantize
36
+
37
+ next if reference_model_name &&
38
+ (model_class.nil? || !ability.can?(:read, model_class))
34
39
 
35
40
  unless ability.can?(:update, model, column[:name])
36
41
  column = column.merge(access_type: BuildSchema::ColumnAccessTypes::READ_ONLY)
@@ -154,7 +154,8 @@ module Motor
154
154
 
155
155
  return {} if column.name == 'year'
156
156
 
157
- return { number_format: true } if !column.name.match?(/_(?:id|year)\z/) &&
157
+ return { number_format: true } if !column.name == 'id' &&
158
+ !column.name.match?(/_(?:id|year)\z/) &&
158
159
  %i[integer float].include?(column.type)
159
160
 
160
161
  {}
@@ -13,7 +13,7 @@ module Motor
13
13
  module_function
14
14
 
15
15
  def call(current_user = nil, current_ability = nil, cache_keys: LoadFromCache.load_cache_keys)
16
- CACHE_STORE.fetch("#{I18n.locale}#{cache_keys.hash}#{current_user&.id}#{current_ability&.rules_hash}") do
16
+ CACHE_STORE.fetch(app_tag_cache_key(cache_keys, current_user, current_ability)) do
17
17
  CACHE_STORE.clear
18
18
 
19
19
  data = build_data(cache_keys, current_user, current_ability)
@@ -21,6 +21,14 @@ module Motor
21
21
  end
22
22
  end
23
23
 
24
+ def app_tag_cache_key(cache_keys, current_user, current_ability)
25
+ key = "#{I18n.locale}#{cache_keys.hash}#{current_user&.id}#{current_ability&.rules_hash}"
26
+
27
+ key += Motor::DefineArModels.defined_models_schema_md5.to_s if defined?(Motor::DefineArModels)
28
+
29
+ key
30
+ end
31
+
24
32
  # rubocop:disable Metrics/AbcSize
25
33
  # @return [Hash]
26
34
  def build_data(cache_keys = {}, current_user = nil, current_ability = nil)
data/lib/motor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.2.49'
4
+ VERSION = '0.2.54'
5
5
  end
@@ -2601,9 +2601,9 @@
2601
2601
  "icons/zoom-out.svg.gz": "icons/zoom-out.svg.gz",
2602
2602
  "icons/zoom-question.svg": "icons/zoom-question.svg",
2603
2603
  "icons/zoom-question.svg.gz": "icons/zoom-question.svg.gz",
2604
- "main-405235dcc7061ef18101.css.gz": "main-405235dcc7061ef18101.css.gz",
2605
- "main-405235dcc7061ef18101.js.LICENSE.txt": "main-405235dcc7061ef18101.js.LICENSE.txt",
2606
- "main-405235dcc7061ef18101.js.gz": "main-405235dcc7061ef18101.js.gz",
2607
- "main.css": "main-405235dcc7061ef18101.css",
2608
- "main.js": "main-405235dcc7061ef18101.js"
2604
+ "main-14416e12b7c4f3d4ccf4.css.gz": "main-14416e12b7c4f3d4ccf4.css.gz",
2605
+ "main-14416e12b7c4f3d4ccf4.js.LICENSE.txt": "main-14416e12b7c4f3d4ccf4.js.LICENSE.txt",
2606
+ "main-14416e12b7c4f3d4ccf4.js.gz": "main-14416e12b7c4f3d4ccf4.js.gz",
2607
+ "main.css": "main-14416e12b7c4f3d4ccf4.css",
2608
+ "main.js": "main-14416e12b7c4f3d4ccf4.js"
2609
2609
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.49
4
+ version: 0.2.54
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-04 00:00:00.000000000 Z
11
+ date: 2022-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -1532,8 +1532,8 @@ files:
1532
1532
  - ui/dist/icons/zoom-money.svg.gz
1533
1533
  - ui/dist/icons/zoom-out.svg.gz
1534
1534
  - ui/dist/icons/zoom-question.svg.gz
1535
- - ui/dist/main-405235dcc7061ef18101.css.gz
1536
- - ui/dist/main-405235dcc7061ef18101.js.gz
1535
+ - ui/dist/main-14416e12b7c4f3d4ccf4.css.gz
1536
+ - ui/dist/main-14416e12b7c4f3d4ccf4.js.gz
1537
1537
  - ui/dist/manifest.json
1538
1538
  homepage:
1539
1539
  licenses: