Module: HomeHelper

Defined in:
app/helpers/home_helper.rb

Overview

Copyright © 2008-2013 Michael Dvorkin and contributors.

Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php


Instance Method Summary collapse

Instance Method Details

#activity_title(activity) ⇒ Object

Activity title for RSS/ATOM feeds.




43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/helpers/home_helper.rb', line 43

def activity_title(activity)
  user    = activity.user.try(:full_name) || ''
  action  = t('action_' + activity.event)
  type    = t('subject_' + activity.item_type.downcase)
  subject = if item = activity.item
              if item.respond_to?(:full_name)
                item.full_name
              elsif item.respond_to?(:name)
                item.name
              end
  end
  t(:activity_text, user: user, action: action, type: type, subject: subject,
                    default: "#{user} #{action} #{type} #{subject}")
end

#show_hidden_entities_message(count, entity, limit = 10) ⇒ Object

Displays ‘not showing’ message for a given count, entity and limit



59
60
61
62
63
64
65
66
67
# File 'app/helpers/home_helper.rb', line 59

def show_hidden_entities_message(count, entity, limit = 10)
  if count > limit
    hidden_count = count - 10
    entity_string = I18n.t("#{hidden_count == 1 ? entity : entity.pluralize}_small")
    (:p) do
      t(:not_showing_hidden_entities, entity: entity_string, count: hidden_count)
    end
  end
end

#sort_by_assetsObject



9
10
11
12
13
# File 'app/helpers/home_helper.rb', line 9

def sort_by_assets
  Version::ASSETS.map do |asset|
    %[{ name: "#{t(asset.singularize)}", on_select: function() { #{redraw(:asset, [asset, t(asset.singularize).downcase], url_for(action: :redraw))} } }]
  end
end

#sort_by_durationObject




23
24
25
26
27
# File 'app/helpers/home_helper.rb', line 23

def sort_by_duration
  Version::DURATION.map do |duration|
    %[{ name: "#{t(duration)}", on_select: function() { #{redraw(:duration, [duration, t(duration).downcase], url_for(action: :redraw))} } }]
  end
end

#sort_by_eventsObject




16
17
18
19
20
# File 'app/helpers/home_helper.rb', line 16

def sort_by_events
  Version::EVENTS.map do |event|
    %[{ name: "#{t(event + '_past_participle')}", on_select: function() { #{redraw(:event, [event, t(event + '_past_participle').downcase], url_for(action: :redraw))} } }]
  end
end

#sort_by_usersObject




30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/home_helper.rb', line 30

def sort_by_users
  users = [["all_users", t(:option_all_users)]] + @all_users.map do |user|
    escaped = sanitize(user.full_name)
    [escaped, escaped]
  end

  users.map do |key, value|
    %[{ name: "#{value}", on_select: function() { #{redraw(:user, [key, (value == t(:option_all_users) ? value.downcase : value)], url_for(action: :redraw))} } }]
  end
end