Module: GuaraViewsHelper

Defined in:
app/helpers/guara_views_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_boolean(value) ⇒ Object



3
4
5
# File 'app/helpers/guara_views_helper.rb', line 3

def format_boolean(value)
  value ? t("commons.yes"):t("commons.no")
end

#inline_list(list, field = nil) ⇒ Object



33
34
35
36
# File 'app/helpers/guara_views_helper.rb', line 33

def inline_list(list, field=nil)
  field = "name" if field.nil?
  list.all.collect {|item| (item.send field.to_sym).to_s }.join ", "
end

#inline_namedlist(list) ⇒ Object



29
30
31
# File 'app/helpers/guara_views_helper.rb', line 29

def inline_namedlist(list)
   list.all.collect {|item| "#{item.name}" }.join ", "
end


7
8
9
10
11
12
13
14
15
# File 'app/helpers/guara_views_helper.rb', line 7

def link_to_add_fields(name, f, association)
  new_object = f.object.send(association).klass.new
  id = new_object.object_id
  fields = f.semantic_fields_for(association, new_object, child_index: id) do |builder|
    #render(association.to_s + "/" + association.to_s.singularize + "_fields", f: builder)
    yield builder
  end
  link_to(t("helpers.forms.#{name}"), '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
end

#nbsp(value) ⇒ Object



17
18
19
20
21
22
23
# File 'app/helpers/guara_views_helper.rb', line 17

def nbsp(value)
  if value.nil? || ((value.kind_of? String) &&  value.empty?)
    raw " "
  else
    value
  end
end

#show_label_tag(label) ⇒ Object



25
26
27
# File 'app/helpers/guara_views_helper.rb', line 25

def show_label_tag(label)
  label_tag label, label+":", :class => "strong"
end