Sha256: 07d1a827c71a9f85228bce6f548276e890c53bccad5bee8340868a54fa9ef7a0

Contents?: true

Size: 925 Bytes

Versions: 7

Compression:

Stored size: 925 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 :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

7 entries across 7 versions & 1 rubygems

Version Path
ad2games-ui_components-2.0.7 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.5 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.4 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.3 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.2 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.1 app/cells/modal/modal_cell.rb
ad2games-ui_components-2.0.0 app/cells/modal/modal_cell.rb