motor-admin 0.2.27 → 0.2.31
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/build_schema/active_storage_attachment_schema.rb +1 -1
- data/lib/motor/resources/fetch_configured_model.rb +20 -7
- data/lib/motor/version.rb +1 -1
- data/ui/dist/main-bbd8f938004172b512b9.css.gz +0 -0
- data/ui/dist/main-bbd8f938004172b512b9.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: 8730558d792eeae0e0468acf367e89e7c9ff55e6fe59c64ff1b8f769fa04e554
|
4
|
+
data.tar.gz: 40b909df7e968eb8c26aa2e06704371ed8b4bebed4d0cf8fce26100cf64d8ad8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1259b8f633301feaef1d0d05e54a96d5c42e841769e556e1b5382c52375633d282ce502eb87829f9dc462267c1b8e4fe31ad5f6151044b1e4d2d734c422c87d
|
7
|
+
data.tar.gz: da7e9a7d859ebf45fc8ad8da2f8008cbf523ef6a3f53408d8cc31760113dfa7b459447184f14187934a627765995fc2ff83cb98571e7bec64d0a7b7d7d93f0ac
|
@@ -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=")
|
@@ -115,7 +115,7 @@ module Motor
|
|
115
115
|
scopes: [],
|
116
116
|
actions: Motor::BuildSchema::Defaults.actions.reject { |e| e[:name] == 'edit' },
|
117
117
|
tabs: Motor::BuildSchema::Defaults.tabs,
|
118
|
-
visible:
|
118
|
+
visible: false
|
119
119
|
}.with_indifferent_access
|
120
120
|
end
|
121
121
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
@@ -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)
|
@@ -143,9 +148,11 @@ module Motor
|
|
143
148
|
ref_dup.instance_variable_set(:@klass, call(ref.klass, cache_key: cache_key))
|
144
149
|
end
|
145
150
|
|
146
|
-
klass.
|
151
|
+
klass.reflections[key] = ref_dup
|
147
152
|
end
|
148
153
|
|
154
|
+
klass._reflections = klass.reflections
|
155
|
+
|
149
156
|
klass
|
150
157
|
end
|
151
158
|
|
@@ -157,11 +164,17 @@ module Motor
|
|
157
164
|
|
158
165
|
filters = options.delete(:filters)
|
159
166
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
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)
|
165
178
|
end
|
166
179
|
end
|
167
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-bbd8f938004172b512b9.css.gz": "main-bbd8f938004172b512b9.css.gz",
|
2605
|
+
"main-bbd8f938004172b512b9.js.LICENSE.txt": "main-bbd8f938004172b512b9.js.LICENSE.txt",
|
2606
|
+
"main-bbd8f938004172b512b9.js.gz": "main-bbd8f938004172b512b9.js.gz",
|
2607
|
+
"main.css": "main-bbd8f938004172b512b9.css",
|
2608
|
+
"main.js": "main-bbd8f938004172b512b9.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.31
|
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-25 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-bbd8f938004172b512b9.css.gz
|
1529
|
+
- ui/dist/main-bbd8f938004172b512b9.js.gz
|
1530
1530
|
- ui/dist/manifest.json
|
1531
1531
|
homepage:
|
1532
1532
|
licenses:
|
Binary file
|
Binary file
|