Class: HomeController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- HomeController
- Defined in:
- app/controllers/home_controller.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
-
#index ⇒ Object
—————————————————————————-.
-
#options ⇒ Object
GET /home/options AJAX —————————————————————————-.
-
#redraw ⇒ Object
GET /home/redraw AJAX —————————————————————————-.
-
#timeline ⇒ Object
GET /home/timeline AJAX —————————————————————————-.
-
#timezone ⇒ Object
GET /home/timezone AJAX —————————————————————————-.
-
#toggle ⇒ Object
GET /home/toggle AJAX —————————————————————————-.
Methods inherited from ApplicationController
Instance Method Details
#index ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/home_controller.rb', line 13 def index @activities = get_activities @my_tasks = Task.visible_on_dashboard(current_user).includes(:user, :asset).by_due_at @my_opportunities = Opportunity.visible_on_dashboard(current_user).includes(:account, :user, :tags).by_closes_on.by_amount @my_accounts = Account.visible_on_dashboard(current_user).includes(:user, :tags).by_name respond_with @activities do |format| format.xls { render xls: @activities, layout: 'header' } end end |
#options ⇒ Object
GET /home/options AJAX
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/home_controller.rb', line 25 def unless params[:cancel].true? @asset = current_user.pref[:activity_asset] || "all" @action = current_user.pref[:activity_event] || "all_events" @user = current_user.pref[:activity_user] || "all_users" @duration = current_user.pref[:activity_duration] || "two_days" @all_users = User.order("first_name, last_name") end end |
#redraw ⇒ Object
GET /home/redraw AJAX
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/home_controller.rb', line 37 def redraw current_user.pref[:activity_asset] = params[:asset] if params[:asset] current_user.pref[:activity_event] = params[:event] if params[:event] current_user.pref[:activity_user] = params[:user] if params[:user] current_user.pref[:activity_duration] = params[:duration] if params[:duration] @activities = get_activities respond_with(@activities) do |format| format.js { render :index } end end |
#timeline ⇒ Object
GET /home/timeline AJAX
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/home_controller.rb', line 65 def timeline state = params[:state].to_s if %w[Collapsed Expanded].include?(state) if (model_type = params[:type].to_s).present? if %w[comment email].include?(model_type) model = model_type.camelize.constantize item = model.find(params[:id]) item.update_attribute(:state, state) end else comments, emails = params[:id].split("+") Comment.where(id: comments.split(',')).update_all(state: state) unless comments.blank? Email.where(id: emails.split(',')).update_all(state: state) unless emails.blank? end end head :ok end |
#timezone ⇒ Object
GET /home/timezone AJAX
86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/controllers/home_controller.rb', line 86 def timezone # # (new Date()).getTimezoneOffset() in JavaScript returns (UTC - localtime) in # minutes, while ActiveSupport::TimeZone expects (localtime - UTC) in seconds. # if params[:offset] session[:timezone_offset] = params[:offset].to_i * -60 ActiveSupport::TimeZone[session[:timezone_offset]] end head :ok end |
#toggle ⇒ Object
GET /home/toggle AJAX
51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/home_controller.rb', line 51 def toggle if (toggle_param = params[:id]&.to_sym) session[:toggle_states] ||= {} if session[:toggle_states][toggle_param] session[:toggle_states].delete(toggle_param) else session[:toggle_states][toggle_param] = true end end head :ok end |