Sha256: f4198d8d2fef3f82597e39bff803d4622f1567646e61b74dfd50394d86fd01e7

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

module Admin::ResourcesHelper

  def search(resource = @resource, params = params)
    if (typus_search = resource.typus_defaults_for(:search)) && typus_search.any?

      hidden_filters = params.dup
      rejections = %w(controller action locale utf8 sort_order order_by search page)
      hidden_filters.delete_if { |k, v| rejections.include?(k) }

      render "helpers/admin/resources/search", :hidden_filters => hidden_filters
    end
  end

  def build_sidebar
    resources = ActiveSupport::OrderedHash.new
    app_name = @resource.typus_application

    admin_user.application(app_name) { |a,b| a.typus_constantize.model_name.human <=> b.typus_constantize.model_name.human }.each do |resource|
      klass = resource.typus_constantize
      resources[resource] = [ link_to_unless_current(Typus::I18n.t("All #{klass.model_name.human.pluralize}"), :action => "index") ]
      resources[resource] << link_to_unless_current(Typus::I18n.t("Add New"), :action => "new") if admin_user.can?("create", klass)
    end

    render "helpers/admin/resources/sidebar", :resources => resources
  end

  # TODO: This method should be moved to `lib/typus/controller/actions.rb`
  def resource_actions
    @resource_actions ||= []
  end

  # TODO: This method should be moved to `lib/typus/controller/actions.rb`
  def resources_actions
    @resources_actions ||= []
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
typus-3.1.0.rc11 app/helpers/admin/resources_helper.rb
typus-3.1.0.rc10 app/helpers/admin/resources_helper.rb
typus-3.1.0.rc9 app/helpers/admin/resources_helper.rb