account_helper.rb
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module AccountHelper
  include GetText
  def button_to_step(type, step, current_step, html_options = {})
    if current_step == step
      the_class = 'active'
      if html_options.has_key?(:class)
        html_options[:class] << " #{the_class}"
      else
        html_options[:class] = the_class
      end
    end
    if step == 1
      url = '#'
    else
      url = send('url_step_' + step.to_s)
    end
    button(type, step.to_s, url, html_options)
  end
  def button_to_step_without_text(type, step, html_options = {})
    url = 'url_step_' + step
    button_without_text(type, step, send(url), html_options)
  end
  def button_to_previous_step(step, html_options = {})
    step = step - 1
    if step > 1
      button_to_step_without_text(:left, step.to_s, html_options)
    end
  end
  def button_to_next_step(step, html_options = {})
    step = step + 1
    if step < 4
      button_to_step_without_text(:forward, step.to_s, html_options)
    end
  end
  def url_step_1
    options = {:controller => 'account', :action => 'signup', :wizard => true}
    Noosfero.url_options.merge(options)
  end
  def url_step_2
    options = {:controller => 'search', :action => 'assets', :asset => 'communities', :wizard => true}
    Noosfero.url_options.merge(options)
  end
  def url_step_3
    options = {:controller => 'friends', :action => 'invite', :profile => user.identifier, :wizard => true}
    Noosfero.url_options.merge(options)
  end
end