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 +4 -4
- data/app/controllers/concerns/motor/current_ability.rb +1 -1
- data/config/locales/en.yml +2 -0
- data/config/locales/es.yml +2 -0
- data/config/locales/pt.yml +2 -0
- data/lib/motor/active_record_utils.rb +9 -1
- data/lib/motor/api_query/filter.rb +4 -0
- data/lib/motor/build_schema/load_from_rails.rb +5 -0
- data/lib/motor/resources/fetch_configured_model.rb +17 -10
- data/lib/motor/version.rb +1 -1
- data/ui/dist/{main-25e14f5ae8855e7368e7.css.gz → main-6570149f716eae327cdc.css.gz} +0 -0
- data/ui/dist/main-6570149f716eae327cdc.js.gz +0 -0
- data/ui/dist/manifest.json +5 -5
- metadata +4 -4
- data/ui/dist/main-25e14f5ae8855e7368e7.js.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed518fa82c6c64047a2cafd677f6e749314e3a38a055ec752cb71b082228e1c6
|
4
|
+
data.tar.gz: 87a804c67093186a0f72ff236b25016614f3e820326404337dd097f0d5672103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16aff2d26bf9c99340e1af7ac17c889f5ad421cdcd9adbeda0b6590c5421c6e1a92ed354d79a048600488de4bb6384f35bba766d6c266371805d97a44ae57734
|
7
|
+
data.tar.gz: a9e5b0ca229032349ef8f863dfd0f495047a73d7c0f19bce4f2f8c4df12fc22a705eb8dfa36d6549baf161b3a1385407e7fc74eb7b9674bca3b2b2e54c0846e8
|
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/pt.yml
CHANGED
@@ -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 =
|
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
|
|
@@ -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
|
-
|
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
Binary file
|
Binary file
|
data/ui/dist/manifest.json
CHANGED
@@ -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-
|
2605
|
-
"main-
|
2606
|
-
"main-
|
2607
|
-
"main.css": "main-
|
2608
|
-
"main.js": "main-
|
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.
|
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-
|
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-
|
1529
|
-
- ui/dist/main-
|
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:
|
Binary file
|