2010-06-08 00:45:49 +00:00
|
|
|
- collection_name = "#{collection_name.singularize}_custom_fields"
|
2010-06-22 13:04:40 +00:00
|
|
|
- custom_fields = form.object.send(collection_name.to_sym)
|
|
|
|
- ordered_custom_fields = form.object.send(:"ordered_#{collection_name}")
|
2011-03-04 23:29:40 +00:00
|
|
|
- field_klass = "#{form.object.class.name}#{collection_name.classify}".gsub(/CustomField$/, 'Field').constantize
|
2010-06-08 00:45:49 +00:00
|
|
|
|
2011-04-07 04:47:01 +00:00
|
|
|
= form.foldable_inputs :name => defined?(form_name) ? form_name : :custom_fields, :class => 'editable-list fields' do
|
2010-07-21 23:56:42 +00:00
|
|
|
|
2011-03-04 23:29:40 +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}}" }
|
2010-06-08 00:45:49 +00:00
|
|
|
%span.handle
|
|
|
|
= image_tag 'admin/form/icons/drag.png'
|
2010-07-21 23:56:42 +00:00
|
|
|
|
2011-03-04 23:29:40 +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
|
|
|
|
2011-03-04 23:29:40 +00:00
|
|
|
%input{ :name => '{{base_name}}[position]', :value => '{{{position}}}', :type => 'hidden', :'data-field' => 'position' }
|
2010-07-21 23:56:42 +00:00
|
|
|
|
2011-03-04 23:29:40 +00:00
|
|
|
%input{ :name => '{{base_name}}[_alias]', :value => '{{{_alias}}}', :type => 'hidden', :'data-field' => '_alias' }
|
2010-07-21 23:56:42 +00:00
|
|
|
|
2011-03-04 23:29:40 +00:00
|
|
|
%input{ :name => '{{base_name}}[hint]', :value => '{{{hint}}}', :type => 'hidden', :'data-field' => 'hint' }
|
2010-07-21 23:56:42 +00:00
|
|
|
|
2011-03-04 23:29:40 +00:00
|
|
|
%input{ :name => '{{base_name}}[text_formatting]', :value => '{{{text_formatting}}}', :type => 'hidden', :'data-field' => 'text_formatting' }
|
|
|
|
|
2011-05-19 15:44:04 +00:00
|
|
|
%input{ :name => '{{base_name}}[target]', :value => '{{{target}}}', :type => 'hidden', :'data-field' => 'target' }
|
|
|
|
|
2011-03-04 23:29:40 +00:00
|
|
|
%input{ :name => '{{base_name}}[label]', :value => '{{{label}}}', :type => 'text', :'data-field' => 'label' }
|
2010-07-21 23:56:42 +00:00
|
|
|
|
2010-06-08 00:45:49 +00:00
|
|
|
—
|
2010-07-21 23:56:42 +00:00
|
|
|
|
2011-03-04 23:29:40 +00:00
|
|
|
%em {{kind_name}}
|
2010-07-21 23:56:42 +00:00
|
|
|
|
2011-03-04 23:29:40 +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-06-08 00:45:49 +00:00
|
|
|
|
2010-07-21 23:56:42 +00:00
|
|
|
|
2011-03-04 23:29:40 +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')
|
|
|
|
|
2010-06-08 00:45:49 +00:00
|
|
|
%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')
|
2011-03-04 23:29:40 +00:00
|
|
|
|
|
|
|
%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)
|