call4paperz/call4paperz

View on GitHub
app/views/proposals/_form.html.erb

Summary

Maintainability
Test Coverage
<%= form_for([@event, @proposal]) do |f| %>
  <% if @proposal.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@proposal.errors.count, "error") %> prohibited this proposal from being saved:</h2>
      <ul>
        <% @proposal.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %> <small class="vermelho">*</small><br/>
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <p class="count_hint" id="name_hint"></p>
  </div>
  <div class="field">
    <%= f.label :description %> <small class="vermelho">*</small> <br/>
    <%= f.text_area :description %>
  </div>
  <div class="field">
    <p class="count_hint" id="description_hint"></p>
  </div>

  <div class="actions">
    <% if @proposal.new_record? %>
      <%= image_submit_tag 'create_event_button.png' %>
    <% else %>
      <%= image_submit_tag 'save.png' %>
    <% end %>
  </div>
<% end %>

<%= content_for :js do %>
  <script>
  var descriptionKeycount = new HandleKeycount();
  var nameKeycount = new HandleKeycount();
  var simplemde = new SimpleMDE({ element: $("#proposal_description")[0], spellChecker: false });

  descriptionKeycount.init(400, $('#description_hint'), $('#proposal_description'));
  nameKeycount.init(150, $('#name_hint'), $('#proposal_name'));

  $(document).ready(function() {
    var validator = $("#new_proposal").validate({
      rules: {
        'proposal[name]': {required: true, maxlength: 150} ,
        'proposal[description]': { required: true, maxlength: 400 }
      }
    });
  });
  </script>
<% end %>