ikuseiGmbH/smart-village-app-cms

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

Summary

Maintainability
Test Coverage
<%= fields_for :deadline, deadline do |f| %>
  <%= hidden_field_tag "deadline[id]", f.object.id if f.object.id.present? %>
  <%= hidden_field_tag "deadline[generic_type]", deadline.generic_type %>
  <%= hidden_field_tag "deadline[publication_date]", deadline.publication_date.try(:to_date) || Time.now.to_date %>

  <div class="row">
    <div class="col">
      <%= render(
            partial: "shared/partials/categories_form",
            locals: {
              record: deadline,
              record_type: "deadline",
              form: f,
              force_visibility: true
              tag_filter: "generic_item_deadline"
          }) %>
    </div>
  </div>

  <hr />

  <div class="row">
    <div class="col">
      <div class="form-group">
        <label for="description">Titel *</label>
        <%= f.text_field :title, required: true, class: "form-control" %>
      </div>
    </div>
  </div>

  <% list_of_content_blocks = deadline.content_blocks.presence || [OpenStruct.new] %>
  <div class="row">
    <div class="col">
      <div class="form-group">
        <label for="description">Beschreibung</label>
        <% list_of_content_blocks.each_with_index do |content_block, index| %>
          <%= f.fields_for "content_blocks[#{index}]", content_block do |fcb| %>
            <%= fcb.text_area :body, class: "form-control html-editor html-editor-text", rows: 10 %>
          <% end %>
        <% end %>
      </div>
    </div>
  </div>

  <hr />

  <div class="row">
    <div class="col">
      <h3 class="d-sm-flex align-items-center justify-content-between my-4">
        Termine
      </h3>
    </div>
  </div>

  <%= render(
        partial: "shared/partials/dates_form",
        locals: {
          record: deadline,
          form: f,
          fields: ["date_start"],
          requireds: [],
          labels: { date_start: "Termin" },
          with_removal: true
      }) %>

  <%= link_to "#", class: "btn btn-sm btn-secondary", id: "nested-add-dates" do %>
    <i class="fas fa-plus text-white mr-2"></i>
    Termin hinzufügen
  <% end %>

  <hr />

  <div class="row">
    <div class="col">
      <h3 class="d-sm-flex align-items-center justify-content-between my-4">
        Dateien
      </h3>
    </div>
  </div>

  <%= render partial: "shared/partials/media_contents_form", locals: { record: deadline, form: f } %>

  <hr />

  <%= render partial: "shared/partials/push_notifications_form", locals: { record: deadline, form: f } %>

  <hr />

  <div class="row justify-content-center pb-4">
    <%= f.submit "Speichern", class: "btn btn-primary btn--big" %>
  </div>
<% end %>