motor-admin 0.2.68 → 0.2.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb174ffc114c2f0f9ecdb0d1b03d81747ba71fee2d332dab70730256b59543c7
4
- data.tar.gz: 3bd3a2c65424ab782bf5e67985e9cc01638f516dd0bb16b8d04c9c43cf6358c9
3
+ metadata.gz: ecd151cc5a37089827f85405b84aefc194a57dc95000ea8c5e9372ed5cdfc00b
4
+ data.tar.gz: 283a02208d984f0ec91201774944bbf80b0eb3b8a4c61ced9d5f585e40931982
5
5
  SHA512:
6
- metadata.gz: c5034a5834c324421487fffcb23e4f33fc487366996c4692b718a11df579022ee7feb596503100e03251846da7e73ca00e5ce08e0ceae072534c3c42971cadd6
7
- data.tar.gz: 954f0668eba4b17c52e58a4bfb7175ca92dc6e9c97638056aa2c850b2b5469b6bd064cbbfdeac657bde9daf23067633aeb555340a2ccff19198f6f086ade7549
6
+ metadata.gz: 3df0bd92070c470e9e7100c0fb16975c4f08aa936b2d52b1411a5f9c070397bbf4a4f070a5ad7f8808a015f631733f28f827a0ad698ceb29e883d160cf008bee
7
+ data.tar.gz: ce24ce1a1499f5d4899aeda240cd1769e21a19e53f92882fd60a903eb659d0ec9d88aed412536ac87303aed45833d88fe94033df5561ae9613eecced11038645
@@ -9,29 +9,30 @@ module Motor
9
9
  load_and_authorize_resource :attachment, class: 'ActiveStorage::Attachment', parent: false
10
10
 
11
11
  def create
12
- if attachable?(record)
13
- record.public_send(@attachment.name).attach(file_params)
12
+ @attachment.assign_attributes(blob: ActiveStorage::Blob.create_and_upload!(file_params), record: record)
13
+ @attachment.assign_attributes(record_type: '', record_id: 0) unless record
14
14
 
15
- head :ok
15
+ if @attachment.save(validate: false)
16
+ render json: { data: Motor::ApiQuery::BuildJson.call(@attachment, params, current_ability) }
16
17
  else
17
- head :unprocessable_entity
18
+ render json: { errors: @attachment.errors }, status: :unprocessable_entity
18
19
  end
19
20
  end
20
21
 
21
22
  private
22
23
 
23
24
  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
-
32
- def attachable?(record)
33
- record.respond_to?("#{@attachment.name}_attachment=") ||
34
- record.respond_to?("#{@attachment.name}_attachments=")
25
+ @record ||=
26
+ if @attachment.record
27
+ record_pk = @attachment.record.class.primary_key
28
+
29
+ Motor::Resources::FetchConfiguredModel.call(
30
+ @attachment.record.class,
31
+ cache_key: Motor::Resource.maximum(:updated_at)
32
+ ).find_by(record_pk => @attachment.record[record_pk])
33
+ else
34
+ current_user
35
+ end
35
36
  end
36
37
 
37
38
  def file_params
@@ -304,6 +304,8 @@ el:
304
304
  action_has_been_removed: Η ενέργεια αυτή έχει καταργηθεί
305
305
  html: HTML
306
306
  edit_html: Edit HTML
307
+ there_are_unsaved_changes_close_form: "There are unsaved changes. Close form?"
308
+ send_file_url: Send file URL
307
309
  i:
308
310
  locale: el
309
311
  select:
@@ -309,3 +309,5 @@ en:
309
309
  do_not_refresh: Do not refresh
310
310
  html: HTML
311
311
  edit_html: Edit HTML
312
+ there_are_unsaved_changes_close_form: "There are unsaved changes. Close form?"
313
+ send_file_url: Send file URL
@@ -304,6 +304,8 @@ es:
304
304
  action_has_been_removed: Esta acción ha sido eliminada
305
305
  html: HTML
306
306
  edit_html: Edit HTML
307
+ there_are_unsaved_changes_close_form: "There are unsaved changes. Close form?"
308
+ send_file_url: Send file URL
307
309
  i:
308
310
  locale: es
309
311
  select:
@@ -300,6 +300,8 @@ pt:
300
300
  action_has_been_removed: Esta ação foi removida
301
301
  html: HTML
302
302
  edit_html: Edit HTML
303
+ there_are_unsaved_changes_close_form: "There are unsaved changes. Close form?"
304
+ send_file_url: Send file URL
303
305
  i:
304
306
  locale: pt
305
307
  select:
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.68'
4
+ VERSION = '0.2.69'
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-f0622588acc207c89190.css.gz": "main-f0622588acc207c89190.css.gz",
2605
- "main-f0622588acc207c89190.js.LICENSE.txt": "main-f0622588acc207c89190.js.LICENSE.txt",
2606
- "main-f0622588acc207c89190.js.gz": "main-f0622588acc207c89190.js.gz",
2607
- "main.css": "main-f0622588acc207c89190.css",
2608
- "main.js": "main-f0622588acc207c89190.js"
2604
+ "main-193823ff82e028dd5887.css.gz": "main-193823ff82e028dd5887.css.gz",
2605
+ "main-193823ff82e028dd5887.js.LICENSE.txt": "main-193823ff82e028dd5887.js.LICENSE.txt",
2606
+ "main-193823ff82e028dd5887.js.gz": "main-193823ff82e028dd5887.js.gz",
2607
+ "main.css": "main-193823ff82e028dd5887.css",
2608
+ "main.js": "main-193823ff82e028dd5887.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.68
4
+ version: 0.2.69
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-22 00:00:00.000000000 Z
11
+ date: 2022-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -1534,8 +1534,8 @@ files:
1534
1534
  - ui/dist/icons/zoom-money.svg.gz
1535
1535
  - ui/dist/icons/zoom-out.svg.gz
1536
1536
  - ui/dist/icons/zoom-question.svg.gz
1537
- - ui/dist/main-f0622588acc207c89190.css.gz
1538
- - ui/dist/main-f0622588acc207c89190.js.gz
1537
+ - ui/dist/main-193823ff82e028dd5887.css.gz
1538
+ - ui/dist/main-193823ff82e028dd5887.js.gz
1539
1539
  - ui/dist/manifest.json
1540
1540
  homepage:
1541
1541
  licenses: