Module: Card::Set::All::Formgroup::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb

Instance Method Summary collapse

Instance Method Details

#formgroup(title, opts = {}, &block) ⇒ Object

a formgroup has a label (with helptext) and an input



23
24
25
26
27
28
29
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 23

def formgroup title, opts={}, &block
  input = opts[:input]
  wrap_with :div, formgroup_div_args(opts[:class]) do
    [formgroup_label(input, title, opts[:help]),
     editor_wrap(input, &block)]
  end
end

#formgroup_div_args(html_class) ⇒ Object



42
43
44
45
46
47
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 42

def formgroup_div_args html_class
  div_args = { class: ["form-group", html_class].compact.join(" ") }
  div_args["data-card-id"] = card.id if card.real?
  div_args.merge!(formgroup_div_cardname_args) if card.name.present?
  div_args
end

#formgroup_div_cardname_argsObject



49
50
51
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 49

def formgroup_div_cardname_args
  { "data-card-name" => h(card.name), "data-card-link-name" => h(card.name.url_key) }
end

#formgroup_help(text = nil) ⇒ Object



53
54
55
56
57
58
59
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 53

def formgroup_help text=nil
  return unless voo&.show?(:help) && text != false

  class_up "help-text", "help-block"
  formgroup_voo_help text
  _render_help
end

#formgroup_label(input, title, help) ⇒ Object



31
32
33
34
35
36
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 31

def formgroup_label input, title, help
  parts = [formgroup_title(title), formgroup_help(help)].compact
  return unless parts.present?

  form.label (input || :content), raw(parts.join("\n"))
end

#formgroup_title(title) ⇒ Object



38
39
40
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 38

def formgroup_title title
  title if voo&.show?(:title) && title.present?
end

#formgroup_voo_help(text) ⇒ Object



61
62
63
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 61

def formgroup_voo_help text
  voo.help = text if voo && text.present? && text.to_s != "true"
end

#read_field_configsObject



16
17
18
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 16

def read_field_configs
  edit_field_configs
end

#view: read_formObject



9
10
11
12
13
14
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 9

view :read_form do
  read_field_configs.map do |field, args|
    args[:view] = :read_formgroup
    nest field, args
  end
end

#view: read_formgroupObject



20
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/formgroup.rb', line 20

view :read_formgroup, template: :haml, unknown: true, wrap: :slot