Module: SimpleWorkflow::Helper
- Included in:
- ActionController::Base, ApplicationHelper
- Defined in:
- lib/simple_workflow/helper.rb
Instance Method Summary collapse
- #back_or_link_to(title, options = nil) ⇒ Object
- #detour? ⇒ Boolean
- #detour_to(title, options, html_options = nil) ⇒ Object
- #image_button_to(image_source, title, options, html_options = {}) ⇒ Object
- #image_detour_to(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
- #image_link_to(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
- #image_link_to_remote(image_source, title, link_options, image_options = nil, post = false) ⇒ Object
- #with_detour(options) ⇒ Object
Instance Method Details
#back_or_link_to(title, options = nil) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/simple_workflow/helper.rb', line 52 def back_or_link_to(title, = nil) if session[:detours] = {:return_from_detour => true}.update(session[:detours].last) [:id] ||= nil logger.debug "linked return from detour: #{.inspect}" end link_to(title, ) if end |
#detour? ⇒ Boolean
48 49 50 |
# File 'lib/simple_workflow/helper.rb', line 48 def detour? not session[:detours].nil? end |
#detour_to(title, options, html_options = nil) ⇒ Object
8 9 10 |
# File 'lib/simple_workflow/helper.rb', line 8 def detour_to(title, , = nil) link_to title, with_detour(), end |
#image_button_to(image_source, title, options, html_options = {}) ⇒ Object
2 3 4 5 6 |
# File 'lib/simple_workflow/helper.rb', line 2 def (image_source, title, , = {}) image_submit_tag image_source, {:class => 'image-submit', :alt => title, :title => title, :id => "#{title}_#{[:id]}", :name => title, :onclick => "form.action='#{url_for()}'"}.update() end |
#image_detour_to(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
29 30 31 32 33 |
# File 'lib/simple_workflow/helper.rb', line 29 def image_detour_to(image_source, title, , = nil, post = false) ||= {:class => 'image-submit'} .update :alt => title, :title => title detour_to image_tag(image_source, ), , post ? {:method => :post} : nil end |
#image_link_to(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
35 36 37 38 39 |
# File 'lib/simple_workflow/helper.rb', line 35 def image_link_to(image_source, title, , = nil, post = false) ||= {:class => 'image-submit'} .update :alt => title, :title => title link_to image_tag(image_source, ), , post ? {:method => :post} : nil end |
#image_link_to_remote(image_source, title, link_options, image_options = nil, post = false) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/simple_workflow/helper.rb', line 41 def image_link_to_remote(image_source, title, , = nil, post = false) ||= {:class => 'image-submit'} .update :alt => title, :title => title with_params = .delete(:with) link_to_remote image_tag(image_source, ), :url => , :with => with_params, :html => post ? {:method => :post} : {} end |
#with_detour(options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/simple_workflow/helper.rb', line 12 def with_detour() = {:detour => params.reject { |k, v| [:detour, :return_from_detour].include? k.to_sym }} if .is_a? String return + ( =~ /\?/ ? '&' : '?') + [:detour].map{|k,v| "detour[#{k}]=#{v}"}.join('&') else .update() if [:layout] == false if params[:action] !~ /_no_layout$/ [:detour].update({:action => params[:action] + '_no_layout'}) end elsif params[:action] =~ /_no_layout$/ [:detour].update({:action => params[:action][0..-11]}) end end end |