Sha256: 8725cecfb79276c6bb0f0682fd399c27f699b230560b5e20237856870146691c

Contents?: true

Size: 555 Bytes

Versions: 4

Compression:

Stored size: 555 Bytes

Contents

class InlineComponent < ViewComponent::Base
  def initialize(model, attribute)
    @model = model
    @attribute = attribute
    @unsuffixed_attribute = unsuffixed(attribute)
    @frame_id = dom_id(model, "#{attribute}_inline_edit")

    super
  end

  def before_render
    return unless controller.in_modal?

    controller.instance_variable_set(:@using_modal, true)
  end

  SUFIJOS = %i[f text].freeze
  def unsuffixed(attribute)
    ret = attribute.to_s.dup

    SUFIJOS.each do |sufijo|
      ret.gsub!(/_#{sufijo}$/, '')
    end

    ret
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pg_rails-7.6.7 pg_engine/app/components/inline_edit/inline_component.rb
pg_rails-7.6.6 pg_engine/app/components/inline_edit/inline_component.rb
pg_rails-7.6.5 pg_engine/app/components/inline_edit/inline_component.rb
pg_rails-7.6.4 pg_engine/app/components/inline_edit/inline_component.rb