Module: Alchemy::Admin::PagesHelper

Includes:
BaseHelper
Defined in:
app/helpers/alchemy/admin/pages_helper.rb

Instance Method Summary collapse

Methods included from BaseHelper

#_t, #page_or_find, #parse_sitemap_name, #render_flash_notice, #render_icon, #render_message, #shorten, #warning

Instance Method Details

#combined_page_status(page) ⇒ Object

Returns the translated explanation of the page´s status.



43
44
45
46
47
48
49
# File 'app/helpers/alchemy/admin/pages_helper.rb', line 43

def combined_page_status(page)
  page.status.map do |state, value|
    next if state == :locked
    val = (:span, '', class: page.send(state) ? "page_status #{state}" : "page_status not_#{state}")
    val += page.status_title(state)
  end.delete_if(&:blank?).join("<br>").html_safe
end

#page_layout_label(page) ⇒ Object

Renders a label for page’s page layout

If the page layout description of the page is missing, it displays a warning.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/helpers/alchemy/admin/pages_helper.rb', line 55

def page_layout_label(page)
  if page.persisted? && page.layout_description.blank?
    [
      (:span, '',
        class: 'inline warning icon',
        title: _t(:page_layout_description_missing)
      ),
      _t(:page_type)
    ].join('&nbsp;').html_safe
  else
    _t(:page_type)
  end
end

#preview_sizes_for_selectObject

Returns options tags for the screen sizes select in page edit view.



29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/alchemy/admin/pages_helper.rb', line 29

def preview_sizes_for_select
  options_for_select([
    'auto',
    [_t('240', :scope => 'preview_sizes'), 240],
    [_t('320', :scope => 'preview_sizes'), 320],
    [_t('480', :scope => 'preview_sizes'), 480],
    [_t('768', :scope => 'preview_sizes'), 768],
    [_t('1024', :scope => 'preview_sizes'), 1024],
    [_t('1280', :scope => 'preview_sizes'), 1280]
  ])
end

Used for rendering the folder link in Admin::Pages#index sitemap.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/alchemy/admin/pages_helper.rb', line 8

def sitemap_folder_link(page)
  if page.folded?(current_alchemy_user.id)
    css_class = 'folded'
    title = _t('Show childpages')
  else
    css_class = 'collapsed'
    title = _t('Hide childpages')
  end
  link_to(
    '',
    alchemy.fold_admin_page_path(page),
    remote: true,
    method: :post,
    class: "page_folder #{css_class} spinner",
    title: title,
    id: "fold_button_#{page.id}"
  )
end