Sha256: b61f7ededc14d02d7cb321ad24480569a5553c8b69a1e66eafaf6c5cc561c90b

Contents?: true

Size: 931 Bytes

Versions: 2

Compression:

Stored size: 931 Bytes

Contents

module Admin

  module ListHelper

    def resources_actions
      @resources_actions ||= []
    end

    def list_actions
      resources_actions.map do |body, url, options|
        if admin_user.can?(url[:action], @resource.name)
          path = params.dup.merge!(url).compact.cleanup
          link_to Typus::I18n.t(body), path, options
        end
      end.join(" / ").html_safe
    end

    #--
    # If partial `list` exists we will use it. This partial will have available
    # the `@items` so we can do whatever we want there. Notice that pagination
    # is still available.
    #++
    def build_list(model, fields, items, resource = @resource.to_resource, link_options = {}, association = nil, association_name = nil)
      render "admin/#{resource}/list", :items => items
    rescue ActionView::MissingTemplate
      build_table(model, fields, items, link_options, association, association_name)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typus-3.0.8 app/helpers/admin/list_helper.rb
typus-3.0.7 app/helpers/admin/list_helper.rb