motor-admin 0.2.18 → 0.2.22

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: dc4b3959711130ff5e711c91a8a3ae30f996dcbbf83c98a6d2bb108ffed665e6
4
- data.tar.gz: c5090823346eb41d62bb400cce5b7c4c4c17b9a9261017aa374a31fa33ca3630
3
+ metadata.gz: ed518fa82c6c64047a2cafd677f6e749314e3a38a055ec752cb71b082228e1c6
4
+ data.tar.gz: 87a804c67093186a0f72ff236b25016614f3e820326404337dd097f0d5672103
5
5
  SHA512:
6
- metadata.gz: c46b67ac2fe96276806252c3c56e0472b32b6f91aa2351dd7d8ae76485de59260e2079dd42336c61beb1d28de9f6c0177e32e60d9a5e35c9b7dd8b9e770ff0bf
7
- data.tar.gz: d49105316054eab5561cfbbad123cf4e106d7d837446cab63f91149f225022466c7ef3e10442e20789c4c920e9a222dbf27ad552a253cd23267e71356d34fa68
6
+ metadata.gz: 16aff2d26bf9c99340e1af7ac17c889f5ad421cdcd9adbeda0b6590c5421c6e1a92ed354d79a048600488de4bb6384f35bba766d6c266371805d97a44ae57734
7
+ data.tar.gz: a9e5b0ca229032349ef8f863dfd0f495047a73d7c0f19bce4f2f8c4df12fc22a705eb8dfa36d6549baf161b3a1385407e7fc74eb7b9674bca3b2b2e54c0846e8
@@ -4,7 +4,7 @@ module Motor
4
4
  module CurrentAbility
5
5
  def current_ability
6
6
  @current_ability ||=
7
- if defined?(Motor::Ability) && current_user
7
+ if defined?(Motor::Ability)
8
8
  klass = Motor::Ability.dup.tap do |k|
9
9
  k.prepend(Motor::CancanUtils::AbilityPatch)
10
10
  end
@@ -276,3 +276,5 @@ en:
276
276
  user_dropdown: User dropdown
277
277
  upload: Upload
278
278
  there_is_nothing_here_yet: There is nothing here yet 🤷‍♂️
279
+ is_null: Is null
280
+ is_not_null: Is not null
@@ -276,6 +276,8 @@ es:
276
276
  user_dropdown: Despliegue del usuario
277
277
  upload: Subir a
278
278
  there_is_nothing_here_yet: Todavía no hay nada aquí 🤷‍♂️
279
+ is_null: Es nulo
280
+ is_not_null: No es nulo
279
281
  i:
280
282
  locale: es
281
283
  select:
@@ -272,6 +272,8 @@ pt:
272
272
  user_dropdown: Desistência do utilizador
273
273
  upload: Carregar
274
274
  there_is_nothing_here_yet: Ainda não há nada aqui 🤷‍♂️
275
+ is_null: É nulo
276
+ is_not_null: Não é nulo
275
277
  i:
276
278
  locale: pt
277
279
  select:
@@ -16,7 +16,7 @@ module Motor
16
16
  def generate_csv_for_relation(relation, reset_limit: false)
17
17
  relation = relation.limit(nil).offset(nil) if reset_limit
18
18
 
19
- result = relation.klass.connection.exec_query(relation.to_sql)
19
+ result = load_query_for_csv(relation)
20
20
 
21
21
  CSV.generate do |csv|
22
22
  csv << result.columns
@@ -24,6 +24,14 @@ module Motor
24
24
  result.rows.each { |row| csv << row }
25
25
  end
26
26
  end
27
+
28
+ def load_query_for_csv(relation)
29
+ model_name = relation.klass.model_name.human(count: :many, default: relation.klass.name.titleize.pluralize)
30
+
31
+ query = Motor::Query.find_by(name: "Export #{model_name}")
32
+
33
+ relation.klass.connection.exec_query(query&.sql_body || relation.to_sql)
34
+ end
27
35
  end
28
36
  end
29
37
 
@@ -67,6 +67,10 @@ module Motor
67
67
  ['ilike', value.sub(LIKE_FILTER_VALUE_REGEXP, '\1%')]
68
68
  when 'ends_with'
69
69
  ['ilike', value.sub(LIKE_FILTER_VALUE_REGEXP, '%\1')]
70
+ when 'eqnull'
71
+ ['eq', nil]
72
+ when 'neqnull'
73
+ ['neq', nil]
70
74
  else
71
75
  [action, value]
72
76
  end
@@ -142,6 +142,11 @@ module Motor
142
142
 
143
143
  return { select_options: enum.keys } if enum
144
144
 
145
+ return {} if column.name == 'year'
146
+
147
+ return { number_format: true } if !column.name.match?(/_(?:id|year)\z/) &&
148
+ %i[integer float].include?(column.type)
149
+
145
150
  {}
146
151
  end
147
152
 
@@ -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.18'
4
+ VERSION = '0.2.22'
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-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"
2604
+ "main-6570149f716eae327cdc.css.gz": "main-6570149f716eae327cdc.css.gz",
2605
+ "main-6570149f716eae327cdc.js.LICENSE.txt": "main-6570149f716eae327cdc.js.LICENSE.txt",
2606
+ "main-6570149f716eae327cdc.js.gz": "main-6570149f716eae327cdc.js.gz",
2607
+ "main.css": "main-6570149f716eae327cdc.css",
2608
+ "main.js": "main-6570149f716eae327cdc.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.18
4
+ version: 0.2.22
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-11-03 00:00:00.000000000 Z
11
+ date: 2021-11-10 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-25e14f5ae8855e7368e7.css.gz
1529
- - ui/dist/main-25e14f5ae8855e7368e7.js.gz
1528
+ - ui/dist/main-6570149f716eae327cdc.css.gz
1529
+ - ui/dist/main-6570149f716eae327cdc.js.gz
1530
1530
  - ui/dist/manifest.json
1531
1531
  homepage:
1532
1532
  licenses: