Module: ErpApp::Widgets::Railties::ActionView::Helpers::WidgetHelper
- Defined in:
- lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb
Instance Method Summary collapse
- #build_widget_url(action, id = nil, params = {}) ⇒ Object
- #get_widget_action ⇒ Object
- #include_widgets ⇒ Object
- #render_widget(name, opts = {}) ⇒ Object
- #set_widget_params(widget_params = {}) ⇒ Object
- #widget_result_id ⇒ Object
Instance Method Details
#build_widget_url(action, id = nil, params = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb', line 28 def (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 ⇒ Object
54 55 56 |
# File 'lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb', line 54 def params[:widget_action] || 'index' end |
#include_widgets ⇒ Object
50 51 52 |
# File 'lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb', line 50 def raw ErpApp::Widgets::JavascriptLoader.glob_javascript end |
#render_widget(name, opts = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb', line 8 def (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 = "::Widgets::#{name.to_s.camelize}::Base".constantize.new(self.controller, name.to_s, action.to_s, uuid, params, nil) result = .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 = {}) ⇒ Object
58 59 60 61 |
# File 'lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb', line 58 def (={}) .merge!(params.symbolize_keys) end |
#widget_result_id ⇒ Object
46 47 48 |
# File 'lib/erp_app/widgets/railties/action_view/helpers/widget_helper.rb', line 46 def "#{@uuid}_result" end |