Module: ResourcesHelper

Defined in:
app/helpers/resources_helper.rb

Instance Method Summary collapse

Instance Method Details

#model_config(resource_class) ⇒ Object



46
47
48
# File 'app/helpers/resources_helper.rb', line 46

def model_config(resource_class)
  Basepack::Utils.model_config(resource_class)
end

#model_name_pluralize(model_class) ⇒ Object



5
6
7
8
9
10
# File 'app/helpers/resources_helper.rb', line 5

def model_name_pluralize(model_class)
  model_class.model_name.human(
    :count => 'other',
    :default => model_class.model_name.human.pluralize
  )
end

#title(title_type = nil, title_subject = nil, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/resources_helper.rb', line 12

def title(title_type = nil, title_subject = nil, options = {})
  title2 = title_subject
  title1 = Array.wrap(title_type).map do |type|
    case type
    when ActiveRecord::Base
      title2 = type.to_label if title_subject.nil?
      type.class.model_name.human
    when Class
      if type.respond_to? :model_name
        model_name_pluralize(type)
      else
        type.name
      end
    else
      type.to_s
    end
  end.join(' / ')

  content_for :page_title do
    haml_tag :small, html_escape(title1)
    haml_concat html_escape(title2) if title2
    if Basepack::Settings.help.title and options[:help] != false
      haml_tag "small.help" do
        haml_tag :a, href: help_path(options[:help] || title1.parameterize), title: "Nápověda" do
          haml_tag "i.icon-question-sign"
        end
      end
    end
  end
  content_for :title do
    html_escape("#{title1} #{title2} | #{t(:web_name)}")
  end
end