Sha256: fe093138c7cd712365d3466c2223d6e70aff7eed4a538dec5f594585e9676c75

Contents?: true

Size: 1011 Bytes

Versions: 8

Compression:

Stored size: 1011 Bytes

Contents

# frozen_string_literal: true
class ModalCell < UiComponents::Cell
  attribute :id, mandatory: true, description: 'The HTML id attribute.'
  attribute :content, mandatory: true, description: "The modal's content."
  attribute :extra_class, description: 'Any extra class on the .modal-dialog element'
  attribute :title, description: 'A title.'
  attribute :buttons, description: 'An array of button types. ' \
                                   'Valid types are `:close` and `:submit`.'

  private

  def buttons
    return unless @buttons
    @buttons.map do |button|
      case button
      when :close then close_button
      when :submit then submit_button
      else raise "'#{button}' button not implemented"
      end
    end.join
  end

  def close_button
    content_tag('button', class: 'btn btn-default', data: { dismiss: 'modal' }) do
      I18n.t('ui_components.modal.close')
    end
  end

  def submit_button
    submit_tag(I18n.t('ui_components.modal.save'), class: 'btn btn-primary')
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ad2games-ui_components-2.3.0 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.1.0 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.14 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.12 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.11 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.10 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.9 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.8 app/cells/modal/modal_cell.rb