module ErpApp::Widgets::Railties::ActionView::Helpers::WidgetHelper
Public Instance Methods
build_widget_url(action, id=nil, params={})
click to toggle source
# File lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb, line 28 def build_widget_url(action, id=nil, params={}) url = if id "/erp_app/widgets/#{@name}/#{action}/#{@uuid}/#{id}" else "/erp_app/widgets/#{@name}/#{action}/#{@uuid}" end if params url = "#{url}?" params.each do |k, v| url += "#{k.to_s}=#{v.to_s}&" end url = url[0...url.length - 1] end url end
get_widget_action()
click to toggle source
# File lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb, line 54 def get_widget_action params[:widget_action] || 'index' end
include_widgets()
click to toggle source
# File lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb, line 50 def include_widgets raw ErpApp::Widgets::JavascriptLoader.glob_javascript end
render_widget(name, opts={})
click to toggle source
# File lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb, line 8 def render_widget(name, opts={}) action = opts[:action] || :index params = opts[:params].nil? ? {} : opts[:params] uuid = Digest::SHA1.hexdigest(Time.now.to_s + rand(10000).to_s) #render widget widget_obj = "::Widgets::#{name.to_s.camelize}::Base".constantize.new(self.controller, name.to_s, action.to_s, uuid, params, nil) result = widget_obj.process(action.to_s) html = "<div id=\"#{uuid}\" class='compass_ae-widget'>" html << result html << "</div>" html << "<script type='text/javascript'>" html << "Compass.ErpApp.Widgets.LoadedWidgets.push({id:'#{uuid}',name:'#{name.to_s}',action:'#{action.to_s}',params:#{params.to_json}});" html << "</script>" raw html end
set_widget_params(widget_params={})
click to toggle source
# File lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb, line 58 def set_widget_params(widget_params={}) widget_params.merge!(params.symbolize_keys) widget_params end
widget_result_id()
click to toggle source
# File lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb, line 46 def widget_result_id "#{@uuid}_result" end