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.



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

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.



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

def div_id
  @div_id
end

#htmlObject

Returns the value of attribute html.



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

def html
  @html
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#proxy_controllerObject

Returns the value of attribute proxy_controller.



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

def proxy_controller
  @proxy_controller
end

#state_nameObject (readonly)

Returns the value of attribute state_name.



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

def state_name
  @state_name
end

#uuidObject

Returns the value of attribute uuid.



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

def uuid
  @uuid
end

#viewObject

Returns the value of attribute view.



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

def view
  @view
end

#widget_paramsObject

Returns the value of attribute widget_params.



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

def widget_params
  @widget_params
end

Class Method Details

.installed_widgetsObject



157
158
159
# File 'lib/erp_app/widgets/base.rb', line 157

def installed_widgets
  self.locate_widgets
end

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



146
147
148
149
150
151
# File 'lib/erp_app/widgets/base.rb', line 146

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

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

.widget_nameObject



153
154
155
# File 'lib/erp_app/widgets/base.rb', line 153

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.



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

def _prefixes
  @_prefixes ||= []
end

#render(*args) ⇒ Object



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

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

#widget_result_idObject



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

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