motor-admin 0.2.17 → 0.2.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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/types.rb +5 -2
- 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 +2 -0
- data/lib/motor/queries/run_query.rb +4 -4
- 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-fa2bc70ab29bad641f1a.css.gz} +0 -0
- data/ui/dist/main-fa2bc70ab29bad641f1a.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: a6fc72d7b1968213aa4845a2df527a839baeff558af4676719eaf8ea3f8ddc93
|
4
|
+
data.tar.gz: fdc2e35bbdead105ff8e92f90f7b172320941f7ca92af085918517ea27c6eb52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe3ff74c52022c83a4e51c1bdb67b0fe7239f644c1b2d70ad689bb70850a9d1955f5abfe2e92e237b936d01177847e7ac2197e492b024cfc52fbc5b15a07e793
|
7
|
+
data.tar.gz: 00c722957541fcb93b3f22d3c3ed59da71b39517cb9f0f0631990c80f5ae50963a57a26b656d95460175936a6f1214e9bf5185c0f5dfc44aab6252731eccda9d
|
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/pt.yml
CHANGED
@@ -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
|
-
|
47
|
+
nil
|
47
48
|
end
|
48
49
|
|
49
50
|
def build_types_hash
|
50
|
-
|
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)
|
@@ -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
|
|
@@ -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
|
-
|
91
|
-
|
92
|
-
|
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
|
-
|
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-fa2bc70ab29bad641f1a.css.gz": "main-fa2bc70ab29bad641f1a.css.gz",
|
2605
|
+
"main-fa2bc70ab29bad641f1a.js.LICENSE.txt": "main-fa2bc70ab29bad641f1a.js.LICENSE.txt",
|
2606
|
+
"main-fa2bc70ab29bad641f1a.js.gz": "main-fa2bc70ab29bad641f1a.js.gz",
|
2607
|
+
"main.css": "main-fa2bc70ab29bad641f1a.css",
|
2608
|
+
"main.js": "main-fa2bc70ab29bad641f1a.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.21
|
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-08 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-fa2bc70ab29bad641f1a.css.gz
|
1529
|
+
- ui/dist/main-fa2bc70ab29bad641f1a.js.gz
|
1530
1530
|
- ui/dist/manifest.json
|
1531
1531
|
homepage:
|
1532
1532
|
licenses:
|
Binary file
|