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, html_options = nil) ⇒ Object
- #detour? ⇒ Boolean
- #detour_to(title, options = nil, html_options = nil, &block) ⇒ Object
- #image_button_to(image_source, title, options, html_options = {}) ⇒ Object
- #image_detour_to(image_source, title, url_options, image_options = nil, link_options = nil) ⇒ Object
- #image_link_to(image_source, title, url_options, image_options = nil, link_options = nil) ⇒ Object
- #image_link_to_remote(image_source, title, link_options, image_options = nil, html_options = {}) ⇒ Object
- #origin_options ⇒ Object
-
#with_detour(options, origin = origin_options) ⇒ Object
Takes a link destination and augments it with the current page as origin.
Instance Method Details
#back_or_link_to(title, options = nil, html_options = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/simple_workflow/helper.rb', line 71 def back_or_link_to(title, = nil, = nil) if session[:detours] = {:return_from_detour => true}.update(session[:detours].last) # FIXME(uwe): Write a test to prove this line is needed. ['id'] ||= nil # EMXIF logger.debug "linked return from detour: #{options.inspect}" end link_to(title, , ) if end |
#detour? ⇒ Boolean
67 68 69 |
# File 'lib/simple_workflow/helper.rb', line 67 def detour? not session[:detours].nil? end |
#detour_to(title, options = nil, html_options = nil, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/simple_workflow/helper.rb', line 8 def detour_to(title, = nil, = nil, &block) if block = = title link_with_detour = link_to(with_detour(), , &block) else link_with_detour = link_to(title, with_detour(), ) end if link_with_detour.size > 4096 # URL maximum size overflow if block link_with_detour = link_to(, , &block) else link_with_detour = link_to(title, , ) end end link_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}_#{options[:id]}", :name => title, :onclick => "form.action='#{url_for(options)}'"}.update() end |
#image_detour_to(image_source, title, url_options, image_options = nil, link_options = nil) ⇒ Object
39 40 41 42 43 |
# File 'lib/simple_workflow/helper.rb', line 39 def image_detour_to(image_source, title, , = nil, = nil) ||= {:class => 'image-submit'} .update :alt => title, :title => title detour_to image_tag(image_source, ), , end |
#image_link_to(image_source, title, url_options, image_options = nil, link_options = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/simple_workflow/helper.rb', line 45 def image_link_to(image_source, title, , = nil, = nil) if == true = {:method => :post} elsif == false = nil end ||= {:class => 'image-submit'} .update :alt => title, :title => title link_to image_tag(image_source, ), , end |
#image_link_to_remote(image_source, title, link_options, image_options = nil, html_options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/simple_workflow/helper.rb', line 56 def image_link_to_remote(image_source, title, , = nil, = {}) if == true = {:method => :post} elsif == false = {} end ||= {:class => 'image-submit'} .update :alt => title, :title => title link_to image_tag(image_source, ), , .merge(:remote => true) end |
#origin_options ⇒ Object
35 36 37 |
# File 'lib/simple_workflow/helper.rb', line 35 def params.reject { |k, v| [:detour, :return_from_detour].include? k.to_sym } end |
#with_detour(options, origin = origin_options) ⇒ Object
Takes a link destination and augments it with the current page as origin. If the optional second argument is given, it is used as the origin. If the given origin is only an anchor, it is added to the current page.
29 30 31 32 33 |
# File 'lib/simple_workflow/helper.rb', line 29 def with_detour(, origin = ) origin.update() if origin.keys == [:anchor] url = url_for() url + (url =~ /\?/ ? '&' : '?') + origin.to_param('detour') end |