motor-admin 0.2.28 → 0.2.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/motor/active_storage_attachments_controller.rb +11 -2
- data/lib/motor/active_record_utils/types.rb +2 -1
- data/lib/motor/resources/fetch_configured_model.rb +17 -6
- data/lib/motor/version.rb +1 -1
- data/ui/dist/main-67a3a033614f741d7e27.css.gz +0 -0
- data/ui/dist/main-67a3a033614f741d7e27.js.gz +0 -0
- data/ui/dist/manifest.json +5 -5
- metadata +4 -4
- data/ui/dist/main-9f6b19ff999e209e9d33.css.gz +0 -0
- data/ui/dist/main-9f6b19ff999e209e9d33.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: df2bbffc1e4cccc31af216322ef484259e7acc71741bf721dc2359bbd9267c4e
|
4
|
+
data.tar.gz: 8f8f8cfa03ab51e5f3ac697aaa3caf04803523689e8c240df130f2e59696b021
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaa0388d363a6d3a0116a6f78e6d212027152226cd89faabdcb832f622395426d7487d27a2dd3268d97d6112fb2df6175113183dd689940a9f6748ad306ca134
|
7
|
+
data.tar.gz: b8837f8486c38a10e86f11415ceac1ace48f5bcb113db9a97cf2f0a3cd11cc798f8b401e03015b62594d5f75e1decb7e54c1be51001c60aa0d18e8540859ec97
|
@@ -9,8 +9,8 @@ module Motor
|
|
9
9
|
load_and_authorize_resource :attachment, class: 'ActiveStorage::Attachment', parent: false
|
10
10
|
|
11
11
|
def create
|
12
|
-
if attachable?(
|
13
|
-
|
12
|
+
if attachable?(record)
|
13
|
+
record.public_send(@attachment.name).attach(file_params)
|
14
14
|
|
15
15
|
head :ok
|
16
16
|
else
|
@@ -20,6 +20,15 @@ module Motor
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
+
def record
|
24
|
+
record_pk = @attachment.record.class.primary_key
|
25
|
+
|
26
|
+
Motor::Resources::FetchConfiguredModel.call(
|
27
|
+
@attachment.record.class,
|
28
|
+
cache_key: Motor::Resource.maximum(:updated_at)
|
29
|
+
).find_by(record_pk => @attachment.record[record_pk])
|
30
|
+
end
|
31
|
+
|
23
32
|
def attachable?(record)
|
24
33
|
record.respond_to?("#{@attachment.name}_attachment=") ||
|
25
34
|
record.respond_to?("#{@attachment.name}_attachments=")
|
@@ -12,6 +12,7 @@ module Motor
|
|
12
12
|
def call(model, cache_key:)
|
13
13
|
configs = Motor::Configs::LoadFromCache.load_resources(cache_key: cache_key)
|
14
14
|
|
15
|
+
return model if model.name == 'ActiveStorage::Attachment'
|
15
16
|
return model if configs.blank? || sti_model?(model)
|
16
17
|
|
17
18
|
maybe_fetch_from_cache(
|
@@ -128,7 +129,11 @@ module Motor
|
|
128
129
|
|
129
130
|
options = options.merge(config[:options] || {})
|
130
131
|
|
131
|
-
|
132
|
+
if config[:model_name] == 'active_storage/attachment'
|
133
|
+
klass.has_one_attached config[:name].delete_suffix('_attachment').to_sym
|
134
|
+
else
|
135
|
+
klass.has_one(config[:name].to_sym, **options.symbolize_keys)
|
136
|
+
end
|
132
137
|
end
|
133
138
|
|
134
139
|
def configure_reflection_classes(klass, cache_key)
|
@@ -159,11 +164,17 @@ module Motor
|
|
159
164
|
|
160
165
|
filters = options.delete(:filters)
|
161
166
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
+
define_association(klass, association[:name], options, filters)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def define_association(klass, name, options, filters)
|
172
|
+
if options[:class_name] == 'ActiveStorage::Attachment'
|
173
|
+
klass.has_many_attached name.delete_suffix('_attachments').to_sym
|
174
|
+
elsif filters.present?
|
175
|
+
klass.has_many(name.to_sym, -> { filter(filters).tap(&:arel) }, **options.symbolize_keys)
|
176
|
+
else
|
177
|
+
klass.has_many(name.to_sym, **options.symbolize_keys)
|
167
178
|
end
|
168
179
|
end
|
169
180
|
|
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-67a3a033614f741d7e27.css.gz": "main-67a3a033614f741d7e27.css.gz",
|
2605
|
+
"main-67a3a033614f741d7e27.js.LICENSE.txt": "main-67a3a033614f741d7e27.js.LICENSE.txt",
|
2606
|
+
"main-67a3a033614f741d7e27.js.gz": "main-67a3a033614f741d7e27.js.gz",
|
2607
|
+
"main.css": "main-67a3a033614f741d7e27.css",
|
2608
|
+
"main.js": "main-67a3a033614f741d7e27.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.29
|
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-24 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-67a3a033614f741d7e27.css.gz
|
1529
|
+
- ui/dist/main-67a3a033614f741d7e27.js.gz
|
1530
1530
|
- ui/dist/manifest.json
|
1531
1531
|
homepage:
|
1532
1532
|
licenses:
|
Binary file
|
Binary file
|