Sha256: 12b659c6dffcabe960115038073a8f17b09683259b579bd40020300cca9053da

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

module Admin::Resources::ListHelper

  def list_actions
    resources_actions_for_current_role.map do |body, url, options|
      path = params.dup.merge!(url).compact.cleanup
      link_to Typus::I18n.t(body), path, options
    end.compact.join(" / ").html_safe
  end

  def resources_actions_for_current_role
    resources_actions.reject do |body, url, options|
      admin_user.cannot?(url[:action], @resource.name)
    end
  end

  def build_actions(&block)
    render "helpers/admin/resources/actions", :block => block
  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

  def scopes
    @resource.typus_defaults_for(:scopes).reject { |s| !@resource.respond_to?(s) }
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
typus-3.1.9 app/helpers/admin/resources/list_helper.rb
typus-3.1.8 app/helpers/admin/resources/list_helper.rb
typus-3.1.7 app/helpers/admin/resources/list_helper.rb
typus-3.1.6 app/helpers/admin/resources/list_helper.rb
typus-3.1.5 app/helpers/admin/resources/list_helper.rb
typus-3.1.4 app/helpers/admin/resources/list_helper.rb
typus-3.1.3 app/helpers/admin/resources/list_helper.rb
typus-3.1.2 app/helpers/admin/resources/list_helper.rb
typus-3.1.1 app/helpers/admin/resources/list_helper.rb
typus-3.1.0 app/helpers/admin/resources/list_helper.rb
typus-3.1.0.rc19 app/helpers/admin/resources/list_helper.rb