Module: UsersHelper
- Defined in:
- app/helpers/users_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
- #all_users ⇒ Object
- #language_for(user) ⇒ Object
- #sort_by_language ⇒ Object
- #user_options_for_select(users, myself) ⇒ Object
- #user_select(asset, users, myself) ⇒ Object
Instance Method Details
#all_users ⇒ Object
21 22 23 |
# File 'app/helpers/users_helper.rb', line 21 def all_users User.by_name end |
#language_for(user) ⇒ Object
8 9 10 11 12 13 |
# File 'app/helpers/users_helper.rb', line 8 def language_for(user) if user.preference[:locale] locale, language = languages.detect{ |locale, language| locale == user.preference[:locale] } end language || "English" end |
#sort_by_language ⇒ Object
15 16 17 18 19 |
# File 'app/helpers/users_helper.rb', line 15 def sort_by_language languages.sort.map do |locale, language| %Q[{ name: "#{language}", on_select: function() { #{redraw(:locale, [ locale, language ], url_for(:action => :redraw, :id => current_user))} } }] end end |
#user_options_for_select(users, myself) ⇒ Object
33 34 35 |
# File 'app/helpers/users_helper.rb', line 33 def (users, myself) (users - [myself]).map{|u| [u.full_name, u.id]}.prepend([t(:myself), myself.id]) end |
#user_select(asset, users, myself) ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/helpers/users_helper.rb', line 25 def user_select(asset, users, myself) = (users, myself) select(asset, :assigned_to, , { :include_blank => t(:unassigned) }, { :style => "width:160px", :class => 'select2' }) end |