Sha256: d2a57a60240004b73e2b06e5c8c5af238c5e58fff3cb1c24bcec84e59827f9a1

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

module ForestAdminDatasourceToolkit
  module Components
    module Actions
      module ActionLayoutElement
        class BaseLayoutElement
          attr_reader :type, :component

          def initialize(component:, **_kwargs)
            @type = FieldType::LAYOUT
            @component = component
          end

          def to_h
            result = {}
            instance_variables.each do |attribute|
              result[attribute.to_s.delete('@').camelize(:lower).to_sym] = instance_variable_get(attribute)
            end

            result
          end
        end

        class InputElement < BaseLayoutElement
          attr_reader :field_id

          def initialize(field_id:, **options)
            super(component: 'Separator', **options)
            @field_id = field_id
          end
        end

        class HtmlBlockElement < BaseLayoutElement
          attr_reader :content

          def initialize(content:, **options)
            super(component: 'HtmlBlock', **options)
            @content = content
          end
        end

        class SeparatorElement < BaseLayoutElement
          def initialize(**options)
            super(component: 'Separator', **options)
          end
        end

        class RowElement < BaseLayoutElement
          attr_accessor :fields

          def initialize(fields:, **options)
            super(component: 'Row', **options)
            @fields = fields
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
forest_admin_datasource_toolkit-1.0.0.pre.beta.71 lib/forest_admin_datasource_toolkit/components/actions/action_layout_element.rb
forest_admin_datasource_toolkit-1.0.0.pre.beta.70 lib/forest_admin_datasource_toolkit/components/actions/action_layout_element.rb
forest_admin_datasource_toolkit-1.0.0.pre.beta.69 lib/forest_admin_datasource_toolkit/components/actions/action_layout_element.rb