Module: AdmixHelper

Includes:
CoreHelper
Defined in:
app/helpers/admix_helper.rb

Instance Method Summary collapse

Instance Method Details

#action_destroy(obj) ⇒ Object



30
31
32
# File 'app/helpers/admix_helper.rb', line 30

def action_destroy(obj)
  link_destroy(obj, image_tag('admix/cancel.png'))
end

#action_edit(obj) ⇒ Object



17
18
19
# File 'app/helpers/admix_helper.rb', line 17

def action_edit(obj)
  link_edit(obj, image_tag('admix/page_edit.png'))
end

#action_show(obj) ⇒ Object



26
27
28
# File 'app/helpers/admix_helper.rb', line 26

def action_show(obj)
  link_to(image_tag('admix/zoom.png'), resource_url(obj), class: 'btn', title:'Visualizar registro')
end

#admix_tab(tab_name, tab_id = nil, options = {}, &block) ⇒ Object



54
55
56
57
58
59
60
# File 'app/helpers/admix_helper.rb', line 54

def admix_tab(tab_name, tab_id = nil, options={}, &block)
  @admix_tabs ||= []
  if @admix_tabs.length == 0
    options[:first] = true
  end
  @admix_tabs << Admix::Tab.new(self, tab_name, tab_id, options, &block)
end

#app_titleObject



5
6
7
# File 'app/helpers/admix_helper.rb', line 5

def app_title
  Setting.app_title
end

#column_actions(grid) ⇒ Object



13
14
15
# File 'app/helpers/admix_helper.rb', line 13

def column_actions(grid)
    render partial: 'column_actions', locals: {grid: grid}
end

#grid_actions_for(obj, actions = [:show, :edit, :destroy]) {|actions| ... } ⇒ Object

Yields:

  • (actions)


39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/admix_helper.rb', line 39

def grid_actions_for(obj, actions = [:show, :edit, :destroy], &block)

  yield(actions) if block_given?

  html = ''

  actions.each do |action_name|
    html += send("action_#{action_name}", obj)
  end

  raw html

end

#input_label(model_name, input_name) ⇒ Object



9
10
11
# File 'app/helpers/admix_helper.rb', line 9

def input_label(model_name, input_name)
  I18n.t("#{model_name}.#{input_name}", scope: :"simple_form.labels", default: [:"defaults.#{input_name}"])
end


34
35
36
37
# File 'app/helpers/admix_helper.rb', line 34

def link_destroy(obj, link_content=nil, classes='')
  link_content ||= image_tag('admix/cancel.png')
  link_to(link_content, resource_url(obj), method: :delete, data: { confirm: t('admix.crud.destroy_confirm') }, class: "btn #{classes}", title:'Deletar registro')
end


21
22
23
24
# File 'app/helpers/admix_helper.rb', line 21

def link_edit(obj, link_content=nil, classes='')
  link_content ||= image_tag('admix/page_edit.png')
  link_to(link_content, edit_resource_url(obj), class: "btn #{classes}", title:'Editar registro')
end


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/helpers/admix_helper.rb', line 63

def nav_items
  items = {}

  build_menu = lambda { |item, menu|

    item[:key] = menu.id
    item[:name] = menu.text
    item[:url] = menu.href
    item[:options] = menu.options

    if menu.children.length > 0
      subitems = []
      menu.children.each do |c|
        subitems << build_menu.call({}, c)
      end
      item[:items] = subitems
    end
    
    item

  }
  build_menu.call(items, ActiveMenu::get('admix-nav'))
  items

end