engine/app/views/admin/pages/_editable_elements.html.haml

35 lines
1.9 KiB
Plaintext

- grouped_editable_elements = @page.editable_elements_grouped_by_blocks
= semantic_fields_for(@page) do |f|
- unless grouped_editable_elements.empty?
#editable-elements
.nav
- grouped_editable_elements.keys.each_with_index do |name, index|
= link_to content_tag(:span, name.try(:humanize) || t('admin.pages.form.default_block')), "#block-#{index}", :id => "block-nav-#{index}", :class => "#{'on' if index == 0}"
.clear
.wrapper
%ul{ :id => "blocks" }
- grouped_editable_elements.keys.each_with_index do |name, index|
- elements = grouped_editable_elements[name]
%li{ :id => "block-#{index}", :class => 'block', :style => "display: #{index == 0 ? 'block' : 'none' }" }
%fieldset.inputs
%ol
- elements.each_with_index do |el, index|
= f.fields_for 'editable_elements', el, :child_index => el._index do |g|
- case el
- when EditableLongText
= g.input :content, :label => el.slug.humanize, :hint => el.hint, :as => :text, :input_html => { :class => 'html' }
- when EditableShortText
= g.input :content, :label => el.slug.humanize, :hint => el.hint
- when EditableFile
= g.custom_input :source, :label => el.slug.humanize, :hint => el.hint, :css => 'file' do
= g.file_field :source
- if el.source?
%p.remove
%strong
= link_to File.basename(el.source.url), el.source.url
%span
 / 
!= t('admin.pages.form.delete_file')
= g.check_box :remove_source