motor-admin 0.2.66 → 0.2.69

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 399871db5e31a27973c4c7ba3b21d168b2d0581daf211f25ecbeadaf481cdfc2
4
- data.tar.gz: fdba5bc869b246e574cc2866d88c5070f4fe21fd1b4b797929ea79578c361897
3
+ metadata.gz: ecd151cc5a37089827f85405b84aefc194a57dc95000ea8c5e9372ed5cdfc00b
4
+ data.tar.gz: 283a02208d984f0ec91201774944bbf80b0eb3b8a4c61ced9d5f585e40931982
5
5
  SHA512:
6
- metadata.gz: bd3dd275d2f88f2f11b05a15ee3efb6293abda137d88b6dc2a9c80c87344993e7a7c2f4cf1044269f71146ee487fec7e86882387a0775c60b3132ad724cfd54b
7
- data.tar.gz: 39f3e468d9b05c2ea9712997814a0867b280aa8b64e405937a8c250f7e776073c3544aac81abfd04a56b8fb2e89351cfbc52072bc60be963014a4246aad9d3d1
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
@@ -31,7 +31,7 @@ module Motor
31
31
 
32
32
  @resource = @associated_resource
33
33
  else
34
- @resource.public_send(params[:association].to_sym).create!(@associated_resource.attributes) do |resource|
34
+ @resource.public_send(params[:association].to_sym).create!(resource_params) do |resource|
35
35
  @resource = resource
36
36
  end
37
37
  end
@@ -302,6 +302,10 @@ el:
302
302
  on_collection: Κατά τη συλλογή
303
303
  association: Σύνδεση
304
304
  action_has_been_removed: Η ενέργεια αυτή έχει καταργηθεί
305
+ html: HTML
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
305
309
  i:
306
310
  locale: el
307
311
  select:
@@ -307,3 +307,7 @@ en:
307
307
  every_minute: Every minute
308
308
  every_5_minutes: Every 5 minutes
309
309
  do_not_refresh: Do not refresh
310
+ html: HTML
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
@@ -302,6 +302,10 @@ es:
302
302
  on_collection: En la colección
303
303
  association: Asociación
304
304
  action_has_been_removed: Esta acción ha sido eliminada
305
+ html: HTML
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
305
309
  i:
306
310
  locale: es
307
311
  select:
@@ -298,6 +298,10 @@ pt:
298
298
  on_collection: Na coleção
299
299
  association: Associação
300
300
  action_has_been_removed: Esta ação foi removida
301
+ html: HTML
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
301
305
  i:
302
306
  locale: pt
303
307
  select:
@@ -137,6 +137,7 @@ module Motor
137
137
  validators: fetch_validators(model, column.name),
138
138
  reference: nil,
139
139
  format: fetch_format_hash(column, model),
140
+ description: '',
140
141
  virtual: false
141
142
  }
142
143
  end
@@ -65,7 +65,8 @@ module Motor
65
65
  default_value: nil,
66
66
  reference: nil,
67
67
  format: {},
68
- validators: []
68
+ validators: [],
69
+ description: ''
69
70
  }.with_indifferent_access
70
71
 
71
72
  ACTION_DEFAULTS = {
@@ -5,7 +5,7 @@ module Motor
5
5
  RESOURCE_ATTRS = %w[display_name display_column icon custom_sql visible display_primary_key
6
6
  searchable_columns].freeze
7
7
  COLUMN_ATTRS = %w[name display_name column_type access_type default_value reference virtual format
8
- validators].freeze
8
+ validators description].freeze
9
9
  ASSOCIATION_ATTRS = %w[name display_name model_name icon visible foreign_key primary_key options virtual
10
10
  polymorphic slug].freeze
11
11
  SCOPE_ATTRS = %w[name display_name scope_type preferences visible].freeze
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.66'
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-1ebc4feb7f2b4c056ad8.css.gz": "main-1ebc4feb7f2b4c056ad8.css.gz",
2605
- "main-1ebc4feb7f2b4c056ad8.js.LICENSE.txt": "main-1ebc4feb7f2b4c056ad8.js.LICENSE.txt",
2606
- "main-1ebc4feb7f2b4c056ad8.js.gz": "main-1ebc4feb7f2b4c056ad8.js.gz",
2607
- "main.css": "main-1ebc4feb7f2b4c056ad8.css",
2608
- "main.js": "main-1ebc4feb7f2b4c056ad8.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.66
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-04-16 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-1ebc4feb7f2b4c056ad8.css.gz
1538
- - ui/dist/main-1ebc4feb7f2b4c056ad8.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:
@@ -1558,7 +1558,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1558
1558
  - !ruby/object:Gem::Version
1559
1559
  version: '0'
1560
1560
  requirements: []
1561
- rubygems_version: 3.2.3
1561
+ rubygems_version: 3.3.3
1562
1562
  signing_key:
1563
1563
  specification_version: 4
1564
1564
  summary: Low-code Admin panel and Business intelligence