Module: Rad::Face::CiViewHelper

Defined in:
lib/face/ci_view_helper.rb

Instance Method Summary collapse

Instance Method Details

#attachments_tag(name, value = [], options = {}) ⇒ Object

Attachments



31
32
33
34
# File 'lib/face/ci_view_helper.rb', line 31

def attachments_tag name, value = [], options = {}
  value = value.collect{|h| h.to_openobject}
  render '/face/attachments_tag', object: options.merge(name: name, value: value).to_openobject
end

#cancel_button(text = t(:cancel)) ⇒ Object



9
10
11
# File 'lib/face/ci_view_helper.rb', line 9

def cancel_button text = t(:cancel)
  link_to text, :back, class: 'm_redirect_back_or_close_dialog'
end

#ok_button(text = t(:ok)) ⇒ Object

Form Buttons



5
6
7
# File 'lib/face/ci_view_helper.rb', line 5

def ok_button text = t(:ok)
  submit_tag text, class: 'm_submit_form_or_ajax_form'
end

#tag_cloud(tags, classes, &block) ⇒ Object

Custom



16
17
18
19
20
21
22
23
24
25
# File 'lib/face/ci_view_helper.rb', line 16

def tag_cloud tags, classes, &block
  return if tags.empty?

  max_count = tags.sort{|a, b| a.count <=> b.count}.last.count.to_f

  tags.sort{|a, b| a.name <=> b.name}.each do |tag|
    index = ((tag.count / max_count) * (classes.size - 1)).round
    block.call tag, classes[index]
  end
end