motor-admin 0.2.15 → 0.2.19

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: 0254bb1cf5ab3176c1c2e923ad755e1f6e445da757aa7981b93b127cb5757c57
4
- data.tar.gz: b8c3a27811eb765056a67ffd9f1cb35fbc374b810be25cfa1de2f9791764f162
3
+ metadata.gz: e1189d1c955046a61940254f58bc78e3743e51e912a6c1e1443ffa9d4df8b22e
4
+ data.tar.gz: 69cbcc3fcc34ee51c03979896f6862ada18d9bd410c297141d14959009e5f38f
5
5
  SHA512:
6
- metadata.gz: 07a1cfb97147d11a5f8abd505e7ab2f91a3568a817ced4043b0db394cf3c8d097ae1bbaca27a391af6b133aea89d9a9470afac9ed670b693098d854168c3656c
7
- data.tar.gz: be58770afa9930c45e0e66e34d5762de7f3d44acf8775afc01cc945c7a13410a0c1b342f6be0e44f0f59047a5fc7a50d20fec1df5e7d1aaeb3a3c541c3743db3
6
+ metadata.gz: 57f991559988e88d2a8abc00bc302946dc986fa75b5e6bc6953a1d05552810339a95d5ef5aae8b0c3bc98c806d7ecfc1b2bacf051471fd2088e10594c8e6fed6
7
+ data.tar.gz: d72ff24ee69ea6db86585efb92dfab69582fb6c712d12c97b19bbd16f5a506b41e72f95d1fea05a153fa430e9a1c014542db8e684dc91dd948027ae9464a5b73
@@ -274,3 +274,5 @@ en:
274
274
  sign_out: Sign out
275
275
  header: Header
276
276
  user_dropdown: User dropdown
277
+ upload: Upload
278
+ there_is_nothing_here_yet: There is nothing here yet 🤷‍♂️
@@ -271,9 +271,11 @@ es:
271
271
  downloading: Descargando
272
272
  display_id: Visualizar ID
273
273
  display_settings: Configuración de la pantalla
274
- sign_out: Sign out
275
- header: Header
276
- user_dropdown: User dropdown
274
+ sign_out: Firmar la salida
275
+ header: Cabecera
276
+ user_dropdown: Despliegue del usuario
277
+ upload: Subir a
278
+ there_is_nothing_here_yet: Todavía no hay nada aquí 🤷‍♂️
277
279
  i:
278
280
  locale: es
279
281
  select:
@@ -267,9 +267,11 @@ pt:
267
267
  downloading: Descarregamento
268
268
  display_id: Mostrar ID
269
269
  display_settings: Definições de visualização
270
- sign_out: Sign out
271
- header: Header
272
- user_dropdown: User dropdown
270
+ sign_out: Sair
271
+ header: Cabeçalho
272
+ user_dropdown: Desistência do utilizador
273
+ upload: Carregar
274
+ there_is_nothing_here_yet: Ainda não há nada aqui 🤷‍♂️
273
275
  i:
274
276
  locale: pt
275
277
  select:
@@ -16,6 +16,7 @@ module Motor
16
16
  'numeric' => 'float',
17
17
  'decimal' => 'float',
18
18
  'float4' => 'float',
19
+ 'bpchar' => 'string',
19
20
  'float8' => 'float',
20
21
  'float16' => 'float',
21
22
  'text' => 'string',
@@ -43,11 +44,13 @@ module Motor
43
44
 
44
45
  return UNIFIED_TYPES.fetch(name, name) if name
45
46
 
46
- DEFAULT_TYPE
47
+ nil
47
48
  end
48
49
 
49
50
  def build_types_hash
50
- type_map = ActiveRecord::Base.connection.send(:type_map)
51
+ connection_class = defined?(::ResourceRecord) ? ::ResourceRecord : ActiveRecord::Base
52
+
53
+ type_map = connection_class.connection.send(:type_map)
51
54
 
52
55
  type_map.instance_variable_get('@mapping').map do |name, type|
53
56
  next unless name.is_a?(String)
@@ -12,7 +12,7 @@ module Motor
12
12
  {
13
13
  name: model.name.underscore,
14
14
  slug: Utils.slugify(model),
15
- class_name: model.class.name,
15
+ class_name: model.name,
16
16
  table_name: model.table_name,
17
17
  primary_key: model.primary_key,
18
18
  display_name: model.model_name.human(count: 2, default: 'Attachments'),
@@ -86,10 +86,10 @@ module Motor
86
86
  result.columns.map.with_index do |column_name, index|
87
87
  column_type_class = result.column_types[column_name]
88
88
 
89
- column_type =
90
- if column_type_class
91
- ActiveRecordUtils::Types.find_name_for_type(column_type_class)
92
- else
89
+ column_type = ActiveRecordUtils::Types.find_name_for_type(column_type_class) if column_type_class
90
+
91
+ column_type ||=
92
+ begin
93
93
  not_nil_value = result.rows.reduce(nil) do |acc, row|
94
94
  column = row[index]
95
95
 
@@ -10,26 +10,19 @@ module Motor
10
10
  def call(model, cache_key:)
11
11
  configs = Motor::Configs::LoadFromCache.load_resources(cache_key: cache_key)
12
12
 
13
- return model if configs.blank?
13
+ return model if configs.blank? || sti_model?(model)
14
14
 
15
15
  maybe_fetch_from_cache(
16
16
  model,
17
17
  cache_key.to_s + model.object_id.to_s,
18
- lambda {
19
- resource_config = configs.find { |r| r.name == model.name.underscore }
20
-
21
- if resource_config
22
- build_configured_model(model, resource_config.preferences)
23
- else
24
- define_class_name_method(Class.new(model), model)
25
- end
26
- },
18
+ -> { build_configured_model_from_configs(model, configs) },
27
19
  ->(klass) { configure_reflection_classes(klass, cache_key) }
28
20
  )
29
21
  end
30
22
 
31
23
  def build_configured_model(model, config)
32
24
  klass = Class.new(model)
25
+ klass.inheritance_column = nil if model.superclass.abstract_class
33
26
 
34
27
  define_class_name_method(klass, model)
35
28
 
@@ -199,6 +192,20 @@ module Motor
199
192
  postprocess_block.call(result)
200
193
  end
201
194
  end
195
+
196
+ def build_configured_model_from_configs(model, configs)
197
+ resource_config = configs.find { |r| r.name == model.name.underscore }
198
+
199
+ if resource_config
200
+ build_configured_model(model, resource_config.preferences)
201
+ else
202
+ define_class_name_method(Class.new(model), model)
203
+ end
204
+ end
205
+
206
+ def sti_model?(model)
207
+ !model.superclass.abstract_class && model.columns_hash[model.inheritance_column.to_s]
208
+ end
202
209
  end
203
210
  end
204
211
  end
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.15'
4
+ VERSION = '0.2.19'
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-e5afce0ea81ef4505dc5.css.gz": "main-e5afce0ea81ef4505dc5.css.gz",
2605
- "main-e5afce0ea81ef4505dc5.js.LICENSE.txt": "main-e5afce0ea81ef4505dc5.js.LICENSE.txt",
2606
- "main-e5afce0ea81ef4505dc5.js.gz": "main-e5afce0ea81ef4505dc5.js.gz",
2607
- "main.css": "main-e5afce0ea81ef4505dc5.css",
2608
- "main.js": "main-e5afce0ea81ef4505dc5.js"
2604
+ "main-25e14f5ae8855e7368e7.css.gz": "main-25e14f5ae8855e7368e7.css.gz",
2605
+ "main-25e14f5ae8855e7368e7.js.LICENSE.txt": "main-25e14f5ae8855e7368e7.js.LICENSE.txt",
2606
+ "main-25e14f5ae8855e7368e7.js.gz": "main-25e14f5ae8855e7368e7.js.gz",
2607
+ "main.css": "main-25e14f5ae8855e7368e7.css",
2608
+ "main.js": "main-25e14f5ae8855e7368e7.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.15
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-27 00:00:00.000000000 Z
11
+ date: 2021-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -1525,8 +1525,8 @@ files:
1525
1525
  - ui/dist/icons/zoom-money.svg.gz
1526
1526
  - ui/dist/icons/zoom-out.svg.gz
1527
1527
  - ui/dist/icons/zoom-question.svg.gz
1528
- - ui/dist/main-e5afce0ea81ef4505dc5.css.gz
1529
- - ui/dist/main-e5afce0ea81ef4505dc5.js.gz
1528
+ - ui/dist/main-25e14f5ae8855e7368e7.css.gz
1529
+ - ui/dist/main-25e14f5ae8855e7368e7.js.gz
1530
1530
  - ui/dist/manifest.json
1531
1531
  homepage:
1532
1532
  licenses: