You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html.erb 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <%= custom_field_title @custom_field %>
  2. <% if @custom_field.enumerations.any? %>
  3. <%= form_tag custom_field_enumerations_path(@custom_field), :method => 'put' do %>
  4. <div class="box">
  5. <ul id="custom_field_enumerations" class="flat">
  6. <% @custom_field.enumerations.each_with_index do |value, position| %>
  7. <li>
  8. <span class="sort-handle"></span>
  9. <%= hidden_field_tag "custom_field_enumerations[#{value.id}][position]", position, :class => 'position' %>
  10. <%= text_field_tag "custom_field_enumerations[#{value.id}][name]", value.name, :size => 40 %>
  11. <%= hidden_field_tag "custom_field_enumerations[#{value.id}][active]", 0 %>
  12. <label>
  13. <%= check_box_tag "custom_field_enumerations[#{value.id}][active]", 1, value.active? %>
  14. <%= l(:field_active) %>
  15. </label>
  16. <%= delete_link custom_field_enumeration_path(@custom_field, value) %>
  17. </li>
  18. <% end %>
  19. </ul>
  20. </div>
  21. <p>
  22. <%= submit_tag(l(:button_save)) %> |
  23. <%= link_to l(:button_back), edit_custom_field_path(@custom_field) %>
  24. </p>
  25. <% end %>
  26. <% end %>
  27. <p><%= l(:label_enumeration_new) %></p>
  28. <%= form_tag custom_field_enumerations_path(@custom_field), :method => 'post', :remote => true do %>
  29. <p><%= text_field_tag 'custom_field_enumeration[name]', '', :size => 40 %>
  30. <%= submit_tag(l(:button_add)) %></p>
  31. <% end %>
  32. <%= javascript_tag do %>
  33. $(function() {
  34. $("#custom_field_enumerations").sortable({
  35. handle: ".sort-handle",
  36. update: function(event, ui) {
  37. $("#custom_field_enumerations li").each(function(){
  38. $(this).find("input.position").val($(this).index()+1);
  39. });
  40. }
  41. });
  42. });
  43. <% end %>