noesya/osuny

View on GitHub
app/views/admin/communication/websites/pages/_form.html.erb

Summary

Maintainability
Test Coverage
<%
url = page.new_record?  ? admin_communication_website_pages_path
                        : admin_communication_website_page_path(page)
%>
<%= simple_form_for page, url: url, as: :communication_website_page do |f| %>
  <%= f.simple_fields_for :localizations, l10n do |lf| %>
    <%= f.error_notification %>
    <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

    <%= lf.hidden_field :language_id, value: current_language.id %>

    <div class="row">
      <div class="col-md-8">
        <%= osuny_panel t('content') do %>
          <%= lf.input :title, input_html: { data: { translatable: true } } %>
          <%= lf.input :breadcrumb_title, input_html: { data: { translatable: true } } %>
          <%= render 'admin/application/summary/form', f: lf, about: l10n %>
          <%= lf.input :header_text, as: :string, input_html: { data: { translatable: true } } %>
          <%= lf.input :header_cta, input_html: { data: { 'conditional': true }, id: 'header_cta' } %>
          <div class="d-none"
              data-conditional-source="header_cta"
              data-conditional-value="true"
              >
            <%= lf.input :header_cta_label %>
            <%= lf.input :header_cta_url %>
          </div>
          <%= lf.input :text, as: :summernote if strip_tags(l10n.text).present? %>
        <% end %>
        <%= render 'admin/application/meta_description/form', f: lf, about: l10n %>
      </div>
      <div class="col-md-4">
        <%= osuny_panel t('metadata') do %>
          <%= lf.input :published if page.draftable? %>
          <%= render  "admin/application/slug/form",
                      f: lf,
                      source: '#communication_website_page_localizations_attributes_0_title' unless page.is_home? %>
          <%= f.association :parent,
                            collection: osuny_collection_tree(
                              @website.pages.root,
                              except: page,
                              localized: true
                            ),
                            include_blank: false unless page.is_home? %>
          <%= f.input :bodyclass if can?(:edit, @website) %>
          <%= f.input :full_width if page.editable_width? %>
        <% end %>
        <%= render 'admin/application/featured_image/edit', f: lf, about: @l10n %>
        <%= render 'admin/application/shared_image/edit', f: lf, about: @l10n %>
      </div>
    </div>

    <% content_for :action_bar_left do %>
      <%= render 'admin/application/l10n/libre_translate_button', l10n: @l10n %>
    <% end %>

    <% content_for :action_bar_right do %>
      <%= submit f %>
    <% end %>
  <% end %>
<% end %>