engine/app/views/admin/custom_fields/_index.html.haml

50 lines
2.7 KiB
Plaintext
Raw Normal View History

- collection_name = "#{collection_name.singularize}_custom_fields"
- custom_fields = form.object.send(collection_name.to_sym)
- ordered_custom_fields = form.object.send(:"ordered_#{collection_name}")
- field_klass = "#{form.object.class.name}#{collection_name.classify}".gsub(/CustomField$/, 'Field').constantize
= form.foldable_inputs :name => :custom_fields, :class => 'editable-list fields' do
2010-07-21 23:56:42 +00:00
%script{ :type => 'text/x-mustache-template', :name => 'template', :'data-base-input-name' => "#{form.object.class.name.underscore}[#{collection_name}_attributes]" }
%li{ :class => "item {{behaviour_flag}} {{new_record_flag}} {{errors_flag}} {{required_flag}}" }
%span.handle
= image_tag 'admin/form/icons/drag.png'
2010-07-21 23:56:42 +00:00
{{#if_existing_record}}
%input{ :name => '{{base_name}}[id]', :value => '{{{id}}}', :type => 'hidden', :'data-field' => 'id' }
%input{ :name => '{{base_name}}[_destroy]', :value => '0', :type => 'hidden', :'data-field' => '_destroy' }
{{/if_existing_record}}
2010-07-21 23:56:42 +00:00
%input{ :name => '{{base_name}}[position]', :value => '{{{position}}}', :type => 'hidden', :'data-field' => 'position' }
2010-07-21 23:56:42 +00:00
%input{ :name => '{{base_name}}[_alias]', :value => '{{{_alias}}}', :type => 'hidden', :'data-field' => '_alias' }
2010-07-21 23:56:42 +00:00
%input{ :name => '{{base_name}}[hint]', :value => '{{{hint}}}', :type => 'hidden', :'data-field' => 'hint' }
2010-07-21 23:56:42 +00:00
%input{ :name => '{{base_name}}[text_formatting]', :value => '{{{text_formatting}}}', :type => 'hidden', :'data-field' => 'text_formatting' }
%input{ :name => '{{base_name}}[label]', :value => '{{{label}}}', :type => 'text', :'data-field' => 'label' }
2010-07-21 23:56:42 +00:00
—
2010-07-21 23:56:42 +00:00
%em {{kind_name}}
2010-07-21 23:56:42 +00:00
= select_tag '{{base_name}}[kind]', options_for_select(options_for_field_kind), :'data-field' => 'kind'
2010-07-21 23:56:42 +00:00
 
2010-07-21 23:56:42 +00:00
%input{ :name => '{{base_name}}[required]', :value => '0', :type => 'hidden', :'data-field' => 'hidden_required' }
%input{ :name => '{{base_name}}[required]', :'{{required_checked}}' => '{{required_checked}}', :value => '1', :type => 'checkbox', :'data-field' => 'required', :id => '{{base_dom_id}}_required' }
%label{ :for => "{{{base_dom_id}}}_required" }= t('.is_required')
%span.actions
= link_to image_tag('admin/form/pen.png'), '#edit-custom-field', :class => 'edit first'
= link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove', :confirm => t('admin.messages.confirm')
%button{ :class => 'button light add', :type => 'button' }
2010-07-21 23:56:42 +00:00
%span!= t('admin.buttons.new_item')
%script{ :type => 'text/javascript', :name => 'data' }
!= collection_to_js(ordered_custom_fields, :template => field_klass.new(:label => t('.default_label'), :_alias => '', :kind => 'string').to_hash)