Module: Admin::ResourcesHelper

Defined in:
app/helpers/admin/resources_helper.rb

Instance Method Summary collapse

Instance Method Details

#build_sidebarObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/admin/resources_helper.rb', line 14

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

  admin_user.application(app_name).each do |resource|
    klass = resource.constantize
    if klass.typus_options_for(:hide_from_sidebar) == false
      resources[resource] = [sidebar_add_new(klass)].compact
    end
  end

  render "helpers/admin/resources/sidebar", :resources => resources if resources.any?
end

#resource_actionsObject

TODO: This method should be moved to lib/typus/controller/actions.rb



35
36
37
# File 'app/helpers/admin/resources_helper.rb', line 35

def resource_actions
  @resource_actions ||= []
end

#resources_actionsObject

TODO: This method should be moved to lib/typus/controller/actions.rb



40
41
42
# File 'app/helpers/admin/resources_helper.rb', line 40

def resources_actions
  @resources_actions ||= []
end

#search(resource = @resource, params = params) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/admin/resources_helper.rb', line 3

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


28
29
30
31
32
# File 'app/helpers/admin/resources_helper.rb', line 28

def sidebar_add_new(klass)
  if admin_user.can?("create", klass)
    { :message => Typus::I18n.t("Add New"), :url => { :action => "new" } }
  end
end