Guest User

Untitled

a guest
Oct 20th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. <% form_for @puppetclass do |f| %>
  2. <%= f.error_messages %>
  3. <p>
  4. <%= f.label :name, nil, :class => "span-3" %>
  5. <%= f.text_field :name, :class => "last" %>
  6. </p>
  7.  
  8. <% field_set_tag("Puppet Environments") do %>
  9. <%= authorized_edit_habtm @puppetclass, Environment %>
  10. <% end -%>
  11.  
  12. <% field_set_tag("Host Groups") do %>
  13. <%= authorized_edit_habtm @puppetclass, Hostgroup %>
  14. <% end -%>
  15. <% unless @puppetclass.new_record? -%>
  16. <p>
  17. Currently used by <%= @puppetclass.hosts.count %> hosts
  18. </p>
  19. <% end -%>
  20.  
  21. <div>
  22. <% f.fields_for :lookup_keys do |builder| -%>
  23. <%= render 'lookup_keys/fields', :f => builder %>
  24. <% end -%>
  25. </div>
  26. <br>
  27. <%= authorized_for(params[:controller], params[:action]) ? link_to_add_fields("Add a new key", f, :lookup_keys, "lookup_keys/fields") : "Add a value" %>
  28.  
  29. <br>
  30. <p><%= f.submit "Submit" %></p>
  31. <% end %>
  32.  
  33.  
  34.  
  35.  
  36.  
  37. lookup_keys/_fields.html.erb
  38.  
  39. <%= f.error_messages if controller_name == "lookup_keys" %>
  40. <table class="puppet-classes-table fields">
  41. <tr>
  42. <th>Key</th>
  43. <th>Description</th>
  44. <th>Default Value</th>
  45. <th>Validator Type</th>
  46. <th>Validatior Rule</th>
  47. <th>Order</th>
  48. <th></th>
  49. </tr>
  50. <tr>
  51. <td> <%= f.text_field :key, :class => "span-2" %> </td>
  52. <td> <%= f.text_field :description, :class => "span-5" %> </td>
  53. <td> <%= f.text_field :default_value, :class => "span-3" %> </td>
  54. <td> <%= f.select :validator_type, options_for_select(LookupKey::VALIDATION_TYPES, f.object.validator_type), {:include_blank => "string"} %> </td>
  55. <td> <%= f.text_field :validator_rule, :class => "span-3" %> </td>
  56. <td> <%= f.text_area :path, :size => "5x2", :value => f.object.path %> </td>
  57. <%= f.hidden_field :updated_at, :value => Time.now %>
  58. <td>
  59. <%= remove_value_link(f) %>
  60. <%= add_value_link(f) %>
  61. </td>
  62. </tr>
  63. <% f.fields_for :lookup_values do |builder| -%>
  64. <%= render 'lookup_keys/value', :f => builder %>
  65. <% end -%>
  66. </table>
  67.  
  68. module LookupKeysHelper
  69. def add_value_link f
  70. link = "<span class='ui-icon ui-icon-plus' title='add new value'></span>"
  71. authorized_for(params[:controller], params[:action]) ? link_to_add_fields(link, f, :lookup_values, "lookup_keys/value") : link
  72. end
  73.  
  74. def remove_value_link f
  75. link_to_remove_fields("remove", f) if authorized_for(params[:controller], params[:action]) unless controller_name == "lookup_keys"
  76. end
  77. end
Add Comment
Please, Sign In to add comment