AyuntamientoMadrid/participacion

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

Summary

Maintainability
Test Coverage
<%= form_for(@proposal, url: form_url) do |f| %>
  <%= render "shared/errors", resource: @proposal %>

  <%= f.hidden_field(:legislation_process_id, value: params[:process_id]) %>

  <div class="row">
    <div class="small-12 column">
      <%= f.text_field :title, maxlength: Legislation::Proposal.title_max_length %>
    </div>

    <%= f.invisible_captcha :subtitle %>

    <div class="small-12 column">
      <%= f.text_area :summary, rows: 4, maxlength: 200,
                                hint: t("proposals.form.proposal_summary_note") %>
    </div>

    <div class="small-12 column">
      <%= f.text_area :description,
                      maxlength: Legislation::Proposal.description_max_length,
                      class: "html-area" %>
    </div>

    <div class="small-12 column">
      <%= f.text_field :video_url,
                       hint: t("proposals.form.proposal_video_url_note") %>
    </div>

    <% if feature?(:allow_images) %>
      <div class="small-12 column">
        <%= render Images::NestedComponent.new(f) %>
      </div>
    <% end %>

    <div class="small-12 column">
      <%= render Documents::NestedComponent.new(f) %>
    </div>

    <% if Geozone.any? %>
      <div class="small-12 medium-6 column">
        <%= f.select :geozone_id, geozone_select_options, include_blank: t("geozones.none") %>
      </div>
    <% end %>

    <div class="small-12 column">
      <%= f.label :tag_list, t("legislation.proposals.form.tags_label") %>
      <p class="help-text" id="tag-list-help-text"><%= t("proposals.form.tags_instructions") %></p>

      <div id="category_tags" class="tags">
        <% @process.tag_list_on(:customs).each do |tag| %>
          <a class="js-add-tag-link"><%= tag %></a>
        <% end %>
      </div>

      <br>
      <%= f.text_field :tag_list, value: @proposal.tag_list.to_s,
                                  label: false,
                                  placeholder: t("proposals.form.tags_placeholder"),
                                  class: "js-tag-list",
                                  aria: { describedby: "tag-list-help-text" } %>
    </div>

    <div class="small-12 column">
      <% if @proposal.new_record? %>
        <%= render Shared::AgreeWithTermsOfServiceFieldComponent.new(f) %>
      <% end %>
    </div>

    <div class="actions small-12 column">
      <%= f.submit(class: "button", value: t("proposals.#{action_name}.form.submit_button")) %>
    </div>
  </div>
<% end %>