Module: AdmixHelper
- Includes:
- CoreHelper
- Defined in:
- app/helpers/admix_helper.rb
Instance Method Summary collapse
- #action_destroy(obj) ⇒ Object
- #action_edit(obj) ⇒ Object
- #action_show(obj) ⇒ Object
- #admix_tab(tab_name, tab_id = nil, options = {}, &block) ⇒ Object
- #app_title ⇒ Object
- #column_actions(grid) ⇒ Object
- #grid_actions_for(obj, actions = [:show, :edit, :destroy]) {|actions| ... } ⇒ Object
- #input_label(model_name, input_name) ⇒ Object
- #link_destroy(obj, link_content = nil, classes = '') ⇒ Object
- #link_edit(obj, link_content = nil, classes = '') ⇒ Object
- #nav_items ⇒ Object
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, ={}, &block) @admix_tabs ||= [] if @admix_tabs.length == 0 [:first] = true end @admix_tabs << Admix::Tab.new(self, tab_name, tab_id, , &block) end |
#app_title ⇒ Object
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
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 |
#link_destroy(obj, link_content = nil, classes = '') ⇒ Object
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 |
#link_edit(obj, link_content = nil, classes = '') ⇒ Object
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 |
#nav_items ⇒ Object
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 = {} = lambda { |item, | item[:key] = .id item[:name] = .text item[:url] = .href item[:options] = . if .children.length > 0 subitems = [] .children.each do |c| subitems << .call({}, c) end item[:items] = subitems end item } .call(items, ActiveMenu::get('admix-nav')) items end |