SumOfUs/Champaign

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

Summary

Maintainability
Test Coverage
-# field: `:liquid_layout_id` or `:follow_up_liquid_layout_id`
-# f: form builder
-# offer_redirect: boolean, whether to offer a redirect
- offer_redirect ||= false
.radio-group.btn-group-vertical.layout-settings__button-group role="group"
  - LiquidLayout.campaigner_friendly.sort_by(&:title).each do |ll|
    - layout_select_classes = construct_layout_select_class(ll, f.object, field)
    = f.label field, value: ll.id, class: "btn btn-default radio-group__option #{layout_select_classes}"
      = f.radio_button field, ll.id, class: 'hidden-irrelevant'
      span.layout-settings__title= ll.title
      span.layout-settings__description= ll.description
  - if offer_redirect
    - active_class = (f.object.follow_up_plan.to_sym == :with_page) ? 'active' : ''
    = f.label :follow_up_plan, value: :with_page, class: "btn btn-default radio-group__option #{active_class}"
      = f.radio_button :follow_up_plan, :with_page, class: 'hidden-irrelevant'
      = f.radio_button :follow_up_plan, :with_liquid, class: 'hidden-irrelevant'
      span.layout-settings__title Redirect to another page
      span.layout-settings__description
        = f.select :follow_up_page_id, options_from_collection_for_select(Page.all, 'id', 'title', f.object.follow_up_page_id), {}, {class: 'selectize-container--clear-on-open', multiple: false}
.checkbox
  = check_box_tag specify_layout_types(field), 'Show all', false, {class: 'layout-type-checkbox'}
  = label_tag specify_layout_types(field) do
    | Show all layouts