Class: ErpApp::Widgets::Base

Inherits:
ActionController::Metal
  • Object
show all
Includes:
AbstractController, ActionController::DataStreaming, ActionController::RequestForgeryProtection, ActionController::Streaming, Callbacks, Helpers, Layouts, Logger, Rendering, Translation
Defined in:
lib/erp_app/widgets/base.rb

Constant Summary collapse

IGNORED_PARAMS =
%w{action controller uuid widget_name widget_action dynamic_form_id dynamic_form_model_id
model_name use_dynamic_form authenticity_token is_html_form commit utf8}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proxy_controller = nil, name = nil, view = nil, uuid = nil, widget_params = nil) ⇒ Base

Returns a new instance of Base.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/erp_app/widgets/base.rb', line 32

def initialize(proxy_controller=nil, name=nil, view=nil, uuid=nil, widget_params=nil)
  ErpApp::Widgets::Base.view_resolver_cache = [] if ErpApp::Widgets::Base.view_resolver_cache.nil?
  self.name = name
  self.proxy_controller = proxy_controller
  self.view = view
  self.uuid = uuid
  self.widget_params = widget_params
  add_view_paths
  store_widget_params
  merge_params
end

Instance Attribute Details

#div_idObject

Returns the value of attribute div_id.



29
30
31
# File 'lib/erp_app/widgets/base.rb', line 29

def div_id
  @div_id
end

#htmlObject

Returns the value of attribute html.



29
30
31
# File 'lib/erp_app/widgets/base.rb', line 29

def html
  @html
end

#nameObject

Returns the value of attribute name.



29
30
31
# File 'lib/erp_app/widgets/base.rb', line 29

def name
  @name
end

#proxy_controllerObject

Returns the value of attribute proxy_controller.



29
30
31
# File 'lib/erp_app/widgets/base.rb', line 29

def proxy_controller
  @proxy_controller
end

#state_nameObject (readonly)

Returns the value of attribute state_name.



28
29
30
# File 'lib/erp_app/widgets/base.rb', line 28

def state_name
  @state_name
end

#uuidObject

Returns the value of attribute uuid.



29
30
31
# File 'lib/erp_app/widgets/base.rb', line 29

def uuid
  @uuid
end

#viewObject

Returns the value of attribute view.



29
30
31
# File 'lib/erp_app/widgets/base.rb', line 29

def view
  @view
end

#widget_paramsObject

Returns the value of attribute widget_params.



29
30
31
# File 'lib/erp_app/widgets/base.rb', line 29

def widget_params
  @widget_params
end

Class Method Details

.installed_widgetsObject



138
139
140
# File 'lib/erp_app/widgets/base.rb', line 138

def installed_widgets
  self.locate_widgets
end

.render_template(view, locals = {}) ⇒ Object



126
127
128
129
130
131
132
# File 'lib/erp_app/widgets/base.rb', line 126

def render_template(view, locals={})
  widget = Rails.application.config.erp_app.widgets.find{|item| item[:name] == self.widget_name}
  paths = widget[:view_paths]

  paths.reverse!
  ActionView::Base.new(paths).render(:template => view, :locals => locals)
end

.widget_nameObject



134
135
136
# File 'lib/erp_app/widgets/base.rb', line 134

def widget_name
  File.basename(File.dirname(__FILE__))
end

Instance Method Details

#_prefixesObject

override default behavior of nesting views by controller namespace.… The prefixes used in render “foo” shortcuts.



46
47
48
# File 'lib/erp_app/widgets/base.rb', line 46

def _prefixes
  @_prefixes ||= []
end

#render(*args) ⇒ Object



54
55
56
# File 'lib/erp_app/widgets/base.rb', line 54

def render(*args)
  render_view_for(self.action_name, *args)
end

#widget_result_idObject



50
51
52
# File 'lib/erp_app/widgets/base.rb', line 50

def widget_result_id
  "#{self.uuid}_result"
end