Class: ErpApp::WidgetProxyController

Inherits:
ApplicationController show all
Defined in:
app/controllers/erp_app/widget_proxy_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#performed_redirectObject

Returns the value of attribute performed_redirect.



4
5
6
# File 'app/controllers/erp_app/widget_proxy_controller.rb', line 4

def performed_redirect
  @performed_redirect
end

Instance Method Details

#clearObject



33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/erp_app/widget_proxy_controller.rb', line 33

def clear
  unless params[:uuids].blank?
    params[:uuids].split(',').each do |uuid|
      if session[:widgets] and session[:widgets][uuid]
        session[:widgets].delete(uuid)
      end
    end
  end

  render json: {success: true}
end

#indexObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/erp_app/widget_proxy_controller.rb', line 8

def index
  @widget_name = params[:widget_name]
  @widget_action = params[:widget_action]
  @uuid = params[:uuid]

  #get widget params
  widget_params = nil
  widget_params = JSON.parse(params[:widget_params]) unless params[:widget_params].blank?

  widget_obj = "::Widgets::#{@widget_name.camelize}::Base".constantize.new(self, @widget_name, @widget_action, @uuid, widget_params)

  result = widget_obj.process(@widget_action)

  #if there was no result just return
  return if result.nil?

  if result.is_a?(Hash)
    if !result[:send_file] and !result[:send_data] and !result[:redirect_to]
      render result
    end
  else
    render :inline => result
  end
end