module AdmixHelper include CoreHelper def app_title Setting.app_title end def input_label(model_name, input_name) I18n.t("#{model_name}.#{input_name}", scope: :"simple_form.labels", default: [:"defaults.#{input_name}"]) end def column_actions(grid) render partial: 'column_actions', locals: {grid: grid} end def action_edit(obj) link_edit(obj, image_tag('admix/page_edit.png')) end 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 def action_show(obj) link_to(image_tag('admix/zoom.png'), resource_url(obj), class: 'btn', title:'Visualizar registro') end def action_destroy(obj) link_destroy(obj, image_tag('admix/cancel.png')) end 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 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 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 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 end