Module: Content::ContentViewsHelper

Defined in:
app/helpers/content/content_views_helper.rb

Instance Method Summary collapse

Instance Method Details

#next_or_cancel(path, args = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'app/helpers/content/content_views_helper.rb', line 14

def next_or_cancel path, args={}
  args[:cancel_path] ||= send("#{controller_name}_path")
  (:div, :class => "form-actions") do
    link_to(_("Cancel"), args[:cancel_path], :class => "btn") + " " +
    submit_tag( _("Next"), :class => "btn btn-primary")
  end
end

#options_for_type_selection(repo) ⇒ Object



32
33
34
35
36
37
38
# File 'app/helpers/content/content_views_helper.rb', line 32

def options_for_type_selection repo
  options = [[_('Clone (snapshot)'), 'clone']]
  options << [_('Latest'),'latest'] if repo.kind_of?(Content::Repository) && repo.publish?
  selected = 'clone' if @factory # default
  selected ||= @content_view.repository_clone_ids.include?(repo.id) ? 'clone' : 'latest' # on validation error
  options_for_select(options, selected)
end

#repositoriesObject



4
5
6
7
8
9
10
11
12
# File 'app/helpers/content/content_views_helper.rb', line 4

def repositories
  cv_repos = @content_view.repository_clones + @content_view.repository_sources

  if @content_view.new_record? && cv_repos.empty? # new form
    @factory.repositories
  else
    cv_repos # edit or new after validation failure
  end
end

#step?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
# File 'app/helpers/content/content_views_helper.rb', line 22

def step?
  if params[:type]
    'step1'
  elsif @hostgroup
    'composite'
  else
    'form'
  end
end