SumOfUs/Champaign

View on GitHub
app/views/pages/_collapsing_layout_select.slim

Summary

Maintainability
Test Coverage
-# association: `:liquid_layout` or `:follow_up_liquid_layout`
-# field: `:liquid_layout_id` or `:follow_up_liquid_layout_id`
-# dom_name: CSS class extension, should be `primary` or `follow_up`
-# offer_redirect: boolean, whether to show option for follow up redirect
-# f: form builder
- offer_redirect ||= false
br
.layout-settings id="layout-settings--#{dom_name}"
  span.layout-settings__current
    - if offer_redirect && f.object.with_page? && f.object.follow_up_page.present?
      = "Redirect to \"#{f.object.follow_up_page.title}\""
    - elsif f.object.send(association).present?
      = f.object.send(association).title
    - else
      span.layout-settings__no-layout = t('pages.edit.no_layout')
  = " - "
  a data-toggle="collapse" data-target=".layout-settings--#{dom_name}" aria-expanded="false"
    = field == :follow_up_liquid_layout_id ? t('pages.edit.change_follow_up') : t('pages.edit.change_layout')
  .collapse class="layout-settings--#{dom_name}"
    = render 'layout_select', f: f, field: field, offer_redirect: offer_redirect