tramway-core 4.0.1.2 → 4.1.1

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: 1e06c110cd0f30a7243f4e279aa171da53cc31f6491b42499c46773e8246f530
4
- data.tar.gz: 478b5ace1fb571aea1c844affeee3d33f0871d31958f0c02b0740d7c3d01b313
3
+ metadata.gz: ac7eeed94de14add119fbc165ccb751d66434804820b453d0291c032d5a60fa1
4
+ data.tar.gz: d94cc5ae90bc4b0d8f39be2f95ac03b3cfa63ff45ad656edcb33001681d50218
5
5
  SHA512:
6
- metadata.gz: dac7d047d46554fc5223d73773fc9b89320fbad418f9198f7bdda46fcac62fa0f01c5aee54b348ab729855f602a698df07e152a7d23113da1dbc8fd778af824c
7
- data.tar.gz: 8ab86f5111052e9fc2db73ba09a0fdf910fcef1ee1b6610a026edf3502cf44c4d394b790982a16434c9020dd57d108d9ad61cbe130855279ddf51420c2618cea
6
+ metadata.gz: 32f49b4b39499903f3a9b3f27d2f3310df8ceb1694e1112d5e31a91c88ce7d61660ed64fc4174abb06cad1f48a42ae043ad0157024fb6b6d113bb604a0619105
7
+ data.tar.gz: 8bc142f5f9d0f9cd9a8d724ca5656091010defbd578279a05be929da1eca2452324d508266c25981e0fa395dd31fcb0c418ce503b2d30994a6f0b7fb99c842f3
@@ -35,6 +35,7 @@ class Tramway::Core::ApplicationForm
35
35
  class << self
36
36
  include Tramway::Core::ApplicationForms::AssociationClassHelpers
37
37
  include Tramway::Core::ApplicationForms::ConstantClassActions
38
+ include Tramway::Core::ApplicationForms::Frontend
38
39
 
39
40
  delegate :defined_enums, to: :model_class
40
41
 
@@ -14,14 +14,16 @@ module Tramway::Core::ApplicationForms::AssociationObjectHelpers
14
14
 
15
15
  def define_polymorphic_association(association, _class_name)
16
16
  self.class.send(:define_method, "#{association}=") do |value|
17
- association_class = value.split('_')[0..-2].join('_').camelize
18
- association_class = association_class.constantize if association_class.is_a? String
19
- if association_class.nil?
20
- Tramway::Error.raise_error :tramway, :core, :application_form, :initialize, :polymorphic_class_is_nil,
21
- association_name: association
22
- else
23
- model.send "#{association}=", association_class.find(value.split('_')[-1])
24
- send "#{association}_type=", association_class.to_s
17
+ if value.present?
18
+ association_class = value.split('_')[0..-2].join('_').camelize
19
+ association_class = association_class.constantize if association_class.is_a? String
20
+ if association_class.nil?
21
+ Tramway::Error.raise_error :tramway, :core, :application_form, :initialize, :polymorphic_class_is_nil,
22
+ association_name: association
23
+ else
24
+ model.send "#{association}=", association_class.find(value.split('_')[-1])
25
+ send "#{association}_type=", association_class.to_s
26
+ end
25
27
  end
26
28
  end
27
29
  end
@@ -0,0 +1,9 @@
1
+ module Tramway::Core::ApplicationForms::Frontend
2
+ def react_component(on = false)
3
+ @react_component = on
4
+ end
5
+
6
+ def is_react_component?
7
+ @react_component ||= false
8
+ end
9
+ end
@@ -15,7 +15,9 @@ module Tramway::Core::Inputs::PolymorphicAssociationsHelper
15
15
  if form_object.send(property).present?
16
16
  "#{form_object.send(property).class.to_s.underscore}_#{form_object.send(property).id}"
17
17
  else
18
- "#{value[:type]&.underscore}_#{value[:id]}"
18
+ if value[:type].present? && value[:id].present?
19
+ "#{value[:type]&.underscore}_#{value[:id]}"
20
+ end
19
21
  end
20
22
  end
21
23
 
@@ -15,6 +15,7 @@ module Tramway::Core::InputsHelper
15
15
  build_input_attributes(object: object, property: property, options: options,
16
16
  value: build_value_for_association(form_object, property, value),
17
17
  collection: build_collection_for_association(form_object, property),
18
+ include_blank: true,
18
19
  selected: form_object.model.send("#{property}_id") || value)
19
20
  end
20
21
 
@@ -25,6 +26,7 @@ module Tramway::Core::InputsHelper
25
26
  collection: build_collection_for_polymorphic_association(form_object, property),
26
27
  options: options.merge(
27
28
  as: :select,
29
+ include_blank: true,
28
30
  label_method: ->(obj) { "#{obj.class.model_name.human} | #{obj.name}" },
29
31
  value_method: lambda { |obj|
30
32
  "#{obj.class.to_s.underscore.sub(/_decorator$/, '')}_#{obj.id}"
@@ -43,7 +43,7 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
43
43
  end
44
44
 
45
45
  def search_by(*attributes, **associations)
46
- pg_search_scope :full_text_search, against: attributes, associated_against: associations
46
+ pg_search_scope :full_text_search, against: attributes, associated_against: associations, using: [:tsearch, :trigram]
47
47
  end
48
48
 
49
49
  def uploader(attribute_name, uploader_name, **options)
@@ -20,6 +20,8 @@
20
20
  = form.association property, **association_params(**input_params).merge(as: :hidden)
21
21
  - when :polymorphic_association
22
22
  = form.input property, **polymorphic_association_params(**input_params.merge(value: value))
23
+ - when :react_component
24
+ = react_component "#{property.camelize}Input", value: value
23
25
  - else
24
26
  - options = input_params[:options] || {}
25
27
  = form.input property, **simple_params(**input_params.merge(type: type)).merge(options)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '4.0.1.2'
5
+ VERSION = '4.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1.2
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-10 00:00:00.000000000 Z
12
+ date: 2022-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: audited
@@ -326,6 +326,7 @@ files:
326
326
  - app/forms/tramway/core/application_forms/association_object_helpers.rb
327
327
  - app/forms/tramway/core/application_forms/constant_class_actions.rb
328
328
  - app/forms/tramway/core/application_forms/constant_object_actions.rb
329
+ - app/forms/tramway/core/application_forms/frontend.rb
329
330
  - app/forms/tramway/core/application_forms/object_helpers.rb
330
331
  - app/forms/tramway/core/application_forms/properties_object_helper.rb
331
332
  - app/forms/tramway/core/application_forms/submit_helper.rb