Sha256: c8463f1276ef1d1d175942e4e5ead7dd663b985075b8ca61b17aae8926044aaa

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

basket[:list_input_options] << "text area"
basket[:list_input_options] << "text field"

format :html do
  def input_type
    voo.input_type.present? ? voo.input_type : input_type_from_rule
  end

  def input_type_from_rule
    card.rule(:input_type)&.gsub(/[\[\]]/, "")&.tr(" ", "_")
  end

  def input_method input_type
    "#{input_type}_input"
  end

  # core view of card is input
  def input_defined_by_card
    with_card input_type do |input_card|
      nest input_card, view: :core
    end
  end

  # move somewhere more accessible?
  def with_card mark
    card = Card[mark]
    yield card if card
  rescue Card::Error::CodenameNotFound
    nil
  end

  view :input, unknown: true, cache: :never do
    try(input_method(input_type)) ||
      input_defined_by_card ||
      send(input_method(default_input_type))
  end

  def default_input_type
    :rich_text
  end

  def rich_text_input
    send "#{Cardio.config.rich_text_editor || :text_area}_editor_input"
  end

  def text_area_input
    text_area :content, rows: 5, class: "d0-card-content",
                        "data-card-type-code": card.type_code
  end

  def text_field_input
    text_field :content, class: classy("d0-card-content")
  end

  def hidden_input
    hidden_field :content, class: classy("d0-card-content")
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
card-mod-edit-0.15.6 set/all/editor.rb
card-mod-edit-0.15.5 set/all/editor.rb
card-mod-edit-0.15.4 set/all/editor.rb
card-mod-edit-0.15.3 set/all/editor.rb
card-mod-edit-0.15.2.pre1 set/all/editor.rb
card-mod-edit-0.15.1.1 set/all/editor.rb
card-mod-edit-0.15.1 set/all/editor.rb
card-mod-edit-0.15.0 set/all/editor.rb