motor-admin 0.1.68 → 0.1.70

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: 5e112faacd3ff1806f8ac4c0520b87a649ea98d004a1745cdc1e3de7040aea92
4
- data.tar.gz: 1d5ef79ead4b16cadab43e0e970cc8a6ae0bf553fa5526a961df6a83edb4157a
3
+ metadata.gz: 02757b4dc451f8f6e177860318c61961e0136608886e8da9356c16a338acc43a
4
+ data.tar.gz: c5edccdaa00543b47a4f723d7cb41b80597bf1af9e8e93176404c357de04e874
5
5
  SHA512:
6
- metadata.gz: 59b77ef4d3546c94361644598d12d832eb5fdcf354c8edd2ce0d2918b1115b38d8011080ecd402dcf5d2c79130dc9b1daf87ec707f4ccbbf19c80ee5ff5ef595
7
- data.tar.gz: a725435fe5d93e71d8d0bde3e40429f8a1a3538b5053035338ceb08c62a0ac7936d990fcc0d08ef126d437046cd54c14e8f070a9f50fb60c8a0362eae4a3849f
6
+ metadata.gz: f90f9a091f038f7a5d5815041181d921adb990402233b1c7bda4de4cd1fa48013d4f0cb689b7d244d9f711830db184cba505aeed17e1b37227872e8eb71b6f61
7
+ data.tar.gz: a10ce5ef3e4880ca4010529c35dbed9fe440973b09239e6fbc85f7009d65f2b3f0ee87f9cf25e5a26c46550e567dd1f0d884487b8d32ba29942571250bd15ae6
@@ -5,6 +5,12 @@ module Motor
5
5
  include Motor::CurrentUserMethod
6
6
  include Motor::CurrentAbility
7
7
 
8
+ if defined?(ActionText::Content)
9
+ before_action do
10
+ ActionText::Content.renderer = Motor::ApplicationController.renderer.new(request.env)
11
+ end
12
+ end
13
+
8
14
  unless Rails.env.test?
9
15
  rescue_from StandardError do |e|
10
16
  Rails.logger.error(e)
@@ -214,3 +214,4 @@ en:
214
214
  visibility: Visibility
215
215
  visualization: Visualization
216
216
  write_only: Write-Only
217
+ richtext: Richtext
@@ -214,6 +214,7 @@ es:
214
214
  textarea: Área de texto
215
215
  unit: Unidad
216
216
  write_only: Sólo escritura
217
+ richtext: Texto enriquecido
217
218
  i:
218
219
  locale: es
219
220
  select:
@@ -22,3 +22,4 @@ require_relative './active_record_utils/active_storage_links_extension'
22
22
  require_relative './active_record_utils/active_storage_blob_patch'
23
23
  require_relative './active_record_utils/active_record_filter_patch'
24
24
  require_relative './active_record_utils/active_record_connection_column_patch'
25
+ require_relative './active_record_utils/action_text_attribute_patch'
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ if defined?(ActionText::Attribute)
4
+ ActionText::Attribute::ClassMethods.prepend(Module.new do
5
+ # rubocop:disable Naming/PredicateName
6
+ def has_rich_text(*args)
7
+ super
8
+
9
+ name = args.first
10
+
11
+ alias_method :"#{name}_body=", :"#{name}="
12
+
13
+ define_method(:"#{name}_body") do
14
+ send(name).body&.to_trix_html
15
+ end
16
+ end
17
+ # rubocop:enable Naming/PredicateName
18
+ end)
19
+ end
@@ -6,10 +6,6 @@ module Motor
6
6
  def path
7
7
  Rails.application.routes.url_helpers.rails_blob_path(self, only_path: true)
8
8
  end
9
-
10
- def url
11
- Rails.application.routes.url_helpers.url_for(self)
12
- end
13
9
  end
14
10
  end
15
11
  end
@@ -8,6 +8,11 @@ module Motor
8
8
 
9
9
  I18N_SCOPES_KEY = 'activerecord.scopes'
10
10
 
11
+ ACTION_TEXT_REFLECTION_PREFIX = 'rich_text_'
12
+ ACTION_TEXT_COLUMN_SUFFIX = '_body'
13
+ ACTION_TEXT_SCOPE_PREFIX = 'with_rich_text_'
14
+ ACTIVE_STORAGE_SCOPE_PREFIX = 'with_attached_'
15
+
11
16
  module_function
12
17
 
13
18
  def call
@@ -40,6 +45,7 @@ module Motor
40
45
  models -= [ActiveRecord::SchemaMigration] if defined?(ActiveRecord::SchemaMigration)
41
46
  models -= [ActiveRecord::InternalMetadata] if defined?(ActiveRecord::InternalMetadata)
42
47
  models -= [ActiveStorage::Blob] if defined?(ActiveStorage::Blob)
48
+ models -= [ActionText::RichText] if defined?(ActionText::RichText)
43
49
  models -= [ActiveStorage::VariantRecord] if defined?(ActiveStorage::VariantRecord)
44
50
 
45
51
  models
@@ -72,7 +78,8 @@ module Motor
72
78
  model.defined_scopes.map do |scope_name|
73
79
  scope_name = scope_name.to_s
74
80
 
75
- next if scope_name.starts_with?('with_attached')
81
+ next if scope_name.starts_with?(ACTIVE_STORAGE_SCOPE_PREFIX)
82
+ next if scope_name.starts_with?(ACTION_TEXT_SCOPE_PREFIX)
76
83
 
77
84
  {
78
85
  name: scope_name,
@@ -139,6 +146,10 @@ module Motor
139
146
  end
140
147
 
141
148
  def build_reflection_column(name, model, ref, default_attrs)
149
+ if !ref.polymorphic? && ref.klass.name == 'ActionText::RichText'
150
+ return build_action_text_column(name, model, ref)
151
+ end
152
+
142
153
  column_name = ref.belongs_to? ? ref.foreign_key.to_s : name
143
154
  is_attachment = !ref.polymorphic? && ref.klass.name == 'ActiveStorage::Attachment'
144
155
  access_type = ref.belongs_to? || is_attachment ? ColumnAccessTypes::READ_WRITE : ColumnAccessTypes::READ_ONLY
@@ -156,6 +167,22 @@ module Motor
156
167
  }
157
168
  end
158
169
 
170
+ def build_action_text_column(name, model, ref)
171
+ name = name.delete_prefix(ACTION_TEXT_REFLECTION_PREFIX)
172
+
173
+ {
174
+ name: name + ACTION_TEXT_COLUMN_SUFFIX,
175
+ display_name: model.human_attribute_name(name),
176
+ column_type: 'richtext',
177
+ access_type: BuildSchema::ColumnAccessTypes::READ_WRITE,
178
+ default_value: '',
179
+ validators: fetch_validators(model, name, ref),
180
+ format: {},
181
+ reference: nil,
182
+ virtual: true
183
+ }
184
+ end
185
+
159
186
  def build_reference(model, name, reflection)
160
187
  {
161
188
  name: name,
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.1.68'
4
+ VERSION = '0.1.70'
5
5
  end
@@ -2068,11 +2068,11 @@
2068
2068
  "mail-opened.svg": "icons/mail-opened.svg",
2069
2069
  "mail.svg": "icons/mail.svg",
2070
2070
  "mailbox.svg": "icons/mailbox.svg",
2071
- "main-9350c345bc241fd25d73.css.gz": "main-9350c345bc241fd25d73.css.gz",
2072
- "main-9350c345bc241fd25d73.js.LICENSE.txt": "main-9350c345bc241fd25d73.js.LICENSE.txt",
2073
- "main-9350c345bc241fd25d73.js.gz": "main-9350c345bc241fd25d73.js.gz",
2074
- "main.css": "main-9350c345bc241fd25d73.css",
2075
- "main.js": "main-9350c345bc241fd25d73.js",
2071
+ "main-abb83b21b8fb726b4db6.css.gz": "main-abb83b21b8fb726b4db6.css.gz",
2072
+ "main-abb83b21b8fb726b4db6.js.LICENSE.txt": "main-abb83b21b8fb726b4db6.js.LICENSE.txt",
2073
+ "main-abb83b21b8fb726b4db6.js.gz": "main-abb83b21b8fb726b4db6.js.gz",
2074
+ "main.css": "main-abb83b21b8fb726b4db6.css",
2075
+ "main.js": "main-abb83b21b8fb726b4db6.js",
2076
2076
  "man.svg": "icons/man.svg",
2077
2077
  "manual-gearbox.svg": "icons/manual-gearbox.svg",
2078
2078
  "map-2.svg": "icons/map-2.svg",
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.1.68
4
+ version: 0.1.70
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-06-25 00:00:00.000000000 Z
11
+ date: 2021-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -171,6 +171,7 @@ files:
171
171
  - lib/motor-admin.rb
172
172
  - lib/motor.rb
173
173
  - lib/motor/active_record_utils.rb
174
+ - lib/motor/active_record_utils/action_text_attribute_patch.rb
174
175
  - lib/motor/active_record_utils/active_record_connection_column_patch.rb
175
176
  - lib/motor/active_record_utils/active_record_filter_patch.rb
176
177
  - lib/motor/active_record_utils/active_storage_blob_patch.rb
@@ -1494,8 +1495,8 @@ files:
1494
1495
  - ui/dist/icons/zoom-money.svg.gz
1495
1496
  - ui/dist/icons/zoom-out.svg.gz
1496
1497
  - ui/dist/icons/zoom-question.svg.gz
1497
- - ui/dist/main-9350c345bc241fd25d73.css.gz
1498
- - ui/dist/main-9350c345bc241fd25d73.js.gz
1498
+ - ui/dist/main-abb83b21b8fb726b4db6.css.gz
1499
+ - ui/dist/main-abb83b21b8fb726b4db6.js.gz
1499
1500
  - ui/dist/manifest.json
1500
1501
  homepage:
1501
1502
  licenses: