phlexi-form 0.5.11 → 0.6.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 +4 -4
 - data/lib/phlexi/form/builder.rb +4 -15
 - data/lib/phlexi/form/components/belongs_to.rb +29 -0
 - data/lib/phlexi/form/components/has_many.rb +25 -0
 - data/lib/phlexi/form/theme.rb +13 -1
 - data/lib/phlexi/form/version.rb +1 -1
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c4a60a1f57783798bdb7523881bb11d92d3ca510665067574a666483655c8a91
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 16983ac5171e487ff70230521df510f8082d2318d06f7d7255856725d181f753
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8489ad9a6c3d95c3856a624f51ecb95b16817ffd241d862135e515aa3acb7512efe7d5e2a17bff2c0e868192f514d412e80dd8ac880015643794394b21c663bc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4d8438bc927ee57a075853a0da83640714a4d4fc2df05f03ea4f39e07652fe0d90827bf4974a4ca0a7012c05b16e2a35d54ef0d4379eb461e45942e0e8e8261e
         
     | 
    
        data/lib/phlexi/form/builder.rb
    CHANGED
    
    | 
         @@ -161,15 +161,8 @@ module Phlexi 
     | 
|
| 
       161 
161 
     | 
    
         
             
                    create_component(Components::Select, :select, **, &)
         
     | 
| 
       162 
162 
     | 
    
         
             
                  end
         
     | 
| 
       163 
163 
     | 
    
         | 
| 
       164 
     | 
    
         
            -
                  def belongs_to_tag( 
     | 
| 
       165 
     | 
    
         
            -
                     
     | 
| 
       166 
     | 
    
         
            -
                      options[:input_param] = if association_reflection.respond_to?(:options) && association_reflection.options[:foreign_key]
         
     | 
| 
       167 
     | 
    
         
            -
                        association_reflection.options[:foreign_key]
         
     | 
| 
       168 
     | 
    
         
            -
                      else
         
     | 
| 
       169 
     | 
    
         
            -
                        :"#{association_reflection.name}_id"
         
     | 
| 
       170 
     | 
    
         
            -
                      end
         
     | 
| 
       171 
     | 
    
         
            -
                    }
         
     | 
| 
       172 
     | 
    
         
            -
                    select_tag(**options, &)
         
     | 
| 
      
 164 
     | 
    
         
            +
                  def belongs_to_tag(**, &)
         
     | 
| 
      
 165 
     | 
    
         
            +
                    create_component(Components::BelongsTo, :belongs_to, **, &)
         
     | 
| 
       173 
166 
     | 
    
         
             
                  end
         
     | 
| 
       174 
167 
     | 
    
         | 
| 
       175 
168 
     | 
    
         
             
                  def polymorphic_belongs_to_tag(**, &)
         
     | 
| 
         @@ -182,12 +175,8 @@ module Phlexi 
     | 
|
| 
       182 
175 
     | 
    
         
             
                    raise NotImplementedError, "has_one associations are NOT supported"
         
     | 
| 
       183 
176 
     | 
    
         
             
                  end
         
     | 
| 
       184 
177 
     | 
    
         | 
| 
       185 
     | 
    
         
            -
                  def has_many_tag( 
     | 
| 
       186 
     | 
    
         
            -
                     
     | 
| 
       187 
     | 
    
         
            -
                      options[:input_param] = :"#{association_reflection.name.to_s.singularize}_ids"
         
     | 
| 
       188 
     | 
    
         
            -
                    }
         
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
       190 
     | 
    
         
            -
                    select_tag(**options, &)
         
     | 
| 
      
 178 
     | 
    
         
            +
                  def has_many_tag(**, &)
         
     | 
| 
      
 179 
     | 
    
         
            +
                    create_component(Components::HasMany, :has_many, **, &)
         
     | 
| 
       191 
180 
     | 
    
         
             
                  end
         
     | 
| 
       192 
181 
     | 
    
         
             
                  alias_method :has_and_belongs_to_many_tag, :has_many_tag
         
     | 
| 
       193 
182 
     | 
    
         | 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Phlexi
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Form
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Components
         
     | 
| 
      
 6 
     | 
    
         
            +
                  class BelongsTo < Select
         
     | 
| 
      
 7 
     | 
    
         
            +
                    protected
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    delegate :association_reflection, to: :field
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    def build_attributes
         
     | 
| 
      
 12 
     | 
    
         
            +
                      super
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                      build_belongs_to_attributes
         
     | 
| 
      
 15 
     | 
    
         
            +
                    end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    def build_belongs_to_attributes
         
     | 
| 
      
 18 
     | 
    
         
            +
                      attributes.fetch(:input_param) do
         
     | 
| 
      
 19 
     | 
    
         
            +
                        attributes[:input_param] = if association_reflection.respond_to?(:options) && association_reflection.options[:foreign_key]
         
     | 
| 
      
 20 
     | 
    
         
            +
                          association_reflection.options[:foreign_key]
         
     | 
| 
      
 21 
     | 
    
         
            +
                        else
         
     | 
| 
      
 22 
     | 
    
         
            +
                          :"#{association_reflection.name}_id"
         
     | 
| 
      
 23 
     | 
    
         
            +
                        end
         
     | 
| 
      
 24 
     | 
    
         
            +
                      end
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Phlexi
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Form
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Components
         
     | 
| 
      
 6 
     | 
    
         
            +
                  class HasMany < Select
         
     | 
| 
      
 7 
     | 
    
         
            +
                    protected
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    delegate :association_reflection, to: :field
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    def build_attributes
         
     | 
| 
      
 12 
     | 
    
         
            +
                      super
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                      build_has_many_attributes
         
     | 
| 
      
 15 
     | 
    
         
            +
                    end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    def build_has_many_attributes
         
     | 
| 
      
 18 
     | 
    
         
            +
                      attributes.fetch(:input_param) {
         
     | 
| 
      
 19 
     | 
    
         
            +
                        attributes[:input_param] = :"#{association_reflection.name.to_s.singularize}_ids"
         
     | 
| 
      
 20 
     | 
    
         
            +
                      }
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/phlexi/form/theme.rb
    CHANGED
    
    | 
         @@ -130,7 +130,19 @@ module Phlexi 
     | 
|
| 
       130 
130 
     | 
    
         
             
                      file: :input,
         
     | 
| 
       131 
131 
     | 
    
         
             
                      valid_file: :valid_input,
         
     | 
| 
       132 
132 
     | 
    
         
             
                      invalid_file: :invalid_input,
         
     | 
| 
       133 
     | 
    
         
            -
                      neutral_file: :neutral_input
         
     | 
| 
      
 133 
     | 
    
         
            +
                      neutral_file: :neutral_input,
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                      # BelongsTo
         
     | 
| 
      
 136 
     | 
    
         
            +
                      belongs_to: :select,
         
     | 
| 
      
 137 
     | 
    
         
            +
                      valid_belongs_to: :valid_select,
         
     | 
| 
      
 138 
     | 
    
         
            +
                      invalid_belongs_to: :invalid_select,
         
     | 
| 
      
 139 
     | 
    
         
            +
                      neutral_belongs_to: :neutral_select,
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
                      # HasMany
         
     | 
| 
      
 142 
     | 
    
         
            +
                      has_many: :select,
         
     | 
| 
      
 143 
     | 
    
         
            +
                      valid_has_many: :valid_select,
         
     | 
| 
      
 144 
     | 
    
         
            +
                      invalid_has_many: :invalid_select,
         
     | 
| 
      
 145 
     | 
    
         
            +
                      neutral_has_many: :neutral_select
         
     | 
| 
       134 
146 
     | 
    
         | 
| 
       135 
147 
     | 
    
         
             
                    }.freeze
         
     | 
| 
       136 
148 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/phlexi/form/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: phlexi-form
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Stefan Froelich
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2024- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-12-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: phlex
         
     | 
| 
         @@ -207,6 +207,7 @@ files: 
     | 
|
| 
       207 
207 
     | 
    
         
             
            - lib/phlexi/form/builder.rb
         
     | 
| 
       208 
208 
     | 
    
         
             
            - lib/phlexi/form/choices_mapper.rb
         
     | 
| 
       209 
209 
     | 
    
         
             
            - lib/phlexi/form/components/base.rb
         
     | 
| 
      
 210 
     | 
    
         
            +
            - lib/phlexi/form/components/belongs_to.rb
         
     | 
| 
       210 
211 
     | 
    
         
             
            - lib/phlexi/form/components/checkbox.rb
         
     | 
| 
       211 
212 
     | 
    
         
             
            - lib/phlexi/form/components/collection_checkboxes.rb
         
     | 
| 
       212 
213 
     | 
    
         
             
            - lib/phlexi/form/components/collection_radio_buttons.rb
         
     | 
| 
         @@ -220,6 +221,7 @@ files: 
     | 
|
| 
       220 
221 
     | 
    
         
             
            - lib/phlexi/form/components/file_input.rb
         
     | 
| 
       221 
222 
     | 
    
         
             
            - lib/phlexi/form/components/form_errors.rb
         
     | 
| 
       222 
223 
     | 
    
         
             
            - lib/phlexi/form/components/full_error.rb
         
     | 
| 
      
 224 
     | 
    
         
            +
            - lib/phlexi/form/components/has_many.rb
         
     | 
| 
       223 
225 
     | 
    
         
             
            - lib/phlexi/form/components/hint.rb
         
     | 
| 
       224 
226 
     | 
    
         
             
            - lib/phlexi/form/components/input.rb
         
     | 
| 
       225 
227 
     | 
    
         
             
            - lib/phlexi/form/components/input_array.rb
         
     |