Module: Alchemy::Admin::EssencesHelper

Includes:
ContentsHelper, EssencesHelper
Included in:
ElementsHelper
Defined in:
app/helpers/alchemy/admin/essences_helper.rb

Instance Method Summary collapse

Methods included from ContentsHelper

#content_label, #render_content_name

Methods included from BaseHelper

#alchemy_body_class, #alchemy_datepicker, #button_with_confirm, #clipboard_select_tag_options, #current_alchemy_user_name, #delete_button, #hint_with_tooltip, #js_filter_field, #link_to_confirm_dialog, #link_to_dialog, #link_url_regexp, #max_image_count, #merge_params, #merge_params_only, #merge_params_without, #new_asset_path_with_session_information, #page_layout_missing_warning, #render_alchemy_title, #render_hint_for, #sites_for_select, #toolbar, #toolbar_button, #translations_for_select

Methods included from NavigationHelper

#alchemy_main_navigation_entry, #entry_active?, #main_navigation_css_classes, #navigate_module, #sorted_alchemy_modules, #url_for_module, #url_for_module_sub_navigation

Methods included from BaseHelper

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

Methods included from EssencesHelper

#render_essence, #render_essence_view, #render_essence_view_by_name

Instance Method Details

#edit_picture_dialog_size(content, options = {}) ⇒ Object

Size value for edit picture dialog



75
76
77
78
79
80
81
# File 'app/helpers/alchemy/admin/essences_helper.rb', line 75

def edit_picture_dialog_size(content, options = {})
  if content.settings_value(:caption_as_textarea, options)
    content.settings_value(:sizes, options) ? '380x320' : '380x300'
  else
    content.settings_value(:sizes, options) ? '380x290' : '380x255'
  end
end

#essence_picture_thumbnail(content, options = {}) ⇒ Object

Renders a thumbnail for given EssencePicture content with correct cropping and size



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/helpers/alchemy/admin/essences_helper.rb', line 60

def essence_picture_thumbnail(content, options = {})
  picture = content.ingredient
  essence = content.essence

  return if picture.nil?

  image_tag(
    essence.thumbnail_url(options),
    alt: picture.name,
    class: 'img_paddingtop',
    title: Alchemy.t(:image_name) + ": #{picture.name}"
  )
end

#pages_for_select(pages = nil, selected = nil, prompt = "Choose page", page_attribute = :id) ⇒ Object

Returns all public pages from current language as an option tags string suitable or the Rails select_tag helper.



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

def pages_for_select(pages = nil, selected = nil, prompt = "Choose page", page_attribute = :id)
  values = [[Alchemy.t(prompt), ""]]
  pages ||= begin
    nested = true
    Language.current.pages.published.order(:lft)
  end
  values += pages_attributes_for_select(pages, page_attribute, nested)
  options_for_select(values, selected.to_s)
end

#render_essence_editor(content, options = {}, html_options = {}) ⇒ Object

Renders the Content editor partial from the given Content. For options see -> render_essence



9
10
11
# File 'app/helpers/alchemy/admin/essences_helper.rb', line 9

def render_essence_editor(content, options = {}, html_options = {})
  render_essence(content, :editor, {for_editor: options}, html_options)
end

#render_essence_editor_by_name(element, name, options = {}, html_options = {}) ⇒ Object

Renders the Content editor partial found in views/contents/ for the content with name inside the passed Element. For options see -> render_essence

Content creation on the fly:

If you update the elements.yml file after creating an element this helper displays a error message with an option to create the content.



20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/alchemy/admin/essences_helper.rb', line 20

def render_essence_editor_by_name(element, name, options = {}, html_options = {})
  if element.blank?
    return warning('Element is nil', Alchemy.t(:no_element_given))
  end
  content = element.content_by_name(name)
  if content.nil?
    render_missing_content(element, name, options)
  else
    render_essence_editor(content, options, html_options)
  end
end

#render_missing_content(element, name, options) ⇒ Object

Renders the missing content partial



55
56
57
# File 'app/helpers/alchemy/admin/essences_helper.rb', line 55

def render_missing_content(element, name, options)
  render 'alchemy/admin/contents/missing', {element: element, name: name, options: options}
end