Created
October 3, 2016 11:16
-
-
Save serg2801/1c91e676fd65ade3565103f8eb3fdf94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @prototype_properties.sort_by{ |prop| -prop[:id] }.each do |prop| %> | |
$("a.spree_add_fields").click(); | |
$(".product_property.fields:first input[type=text]:first").val("<%= prop.name %>"); | |
$input = $(".product_property.fields:first input[type=text]:eq(1)"); | |
$parentBlock = $input.parent(); | |
$objectClass = $input.attr('class'); | |
$objectName = $input.attr('name'); | |
$objectId = $input.attr('id'); | |
console.log($objectClass); | |
console.log($(".product_property.fields:first input[type=text]:eq(1)").parent()); | |
$parentBlock.remove(); | |
<% case prop.type_property %> | |
<% when 'Text Field' %> | |
$parentBlock.append("<%= j render(:partial => 'spree/admin/product_properties/filds/text_field', :locals => { :f => false, object_class: $objectClass.to_s, object_name: $objectNameto.to_s, object_id: $objectId.to_s }) %>"); | |
<% when 'Text Area' %> | |
$parentBlock.append("<%= j render(:partial => 'spree/admin/product_properties/filds/text_area', :locals => { :f => false, object_class: $objectClass.to_s, object_name: $objectNameto.to_s, object_id: $objectId.to_s }) %>"); | |
<% when 'Dropdown' %> | |
$parentBlock.append("<%= j render(:partial => 'spree/admin/product_properties/filds/dropdown', :locals => { :f => false, object_class: $objectClass.to_s, object_name: $objectNameto.to_s, object_id: $objectId.to_s }) %>"); | |
<% when 'Date' %> | |
console.log($parentBlock); | |
console.log($objectClass); | |
$parentBlock.append("<%= j render(:partial => 'spree/admin/product_properties/filds/date', :locals => { :f => false, object_class: 'dfsdf', object_name: $objectNameto.to_s, object_id: $objectId.to_s }) %>"); | |
<% when 'Yes/No' %> | |
// $parentBlock.append("<%#= j render(:partial => 'spree/admin/product_properties/filds/yes_no', :locals => { :f => false, :class => $objectClass, :name => $objectName, :id => $objectId }) %>"); | |
<% when 'Multiple Select' %> | |
$parentBlock.append("<%#= j render(:partial => 'spree/admin/product_properties/filds/multiple_select', :locals => { :f => false, :class => $objectClass, :name => $objectName, :id => $objectId }) %>"); | |
<% when 'Price' %> | |
$parentBlock.append("<%#= j render(:partial => 'spree/admin/product_properties/filds/price', :locals => { :f => false, :class => $objectClass, :name => $objectName, :id => $objectId }) %>"); | |
<% else %> | |
$parentBlock.append("<%#= j render(:partial => 'spree/admin/product_properties/filds/text_field', :locals => { :f => false, :class => $objectClass, :name => $objectName, :id => $objectId }) %>"); | |
<% end %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment