SumOfUs/Champaign

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

Summary

Maintainability
Test Coverage
.col-md-12.page-filter-form
  form action='/pages' method='get'
    - multi_select_options = { class: 'selectize-container', multiple: true }
    - label_class = 'control-label col-lg-3'
    legend Only show pages that...
    .page-filter__row
      = label_tag :content_search, 'Contain the following text: ', class: label_class
      .col-lg-3
        = text_field_tag :content_search, @search_params[:content_search], { class: 'form-control' }

      = label_tag :campaign, 'Belong to one of these campaigns:', class: label_class
      .col-lg-3
        = select_tag :campaign, options_from_collection_for_select(Campaign.all, 'id', 'name', @search_params[:campaign]), { class: 'selectize-container selectize-tag', multiple: true }
    .page-filter__row
      = label_tag :layout, 'Use one of these layouts:', class: label_class
      .col-lg-3
        = select_tag :layout, options_from_collection_for_select(LiquidLayout.all, 'id', 'title', @search_params[:layout]), multi_select_options

      = label_tag :language, 'Belong to one of these languages: ', class: label_class
      .col-lg-3
        = select_tag :language, options_from_collection_for_select(Language.all, 'id', 'name', @search_params[:language]), multi_select_options
    .page-filter__row
      = label_tag :tags, 'Contain all of these tags:', class: label_class
      .col-lg-3
        = select_tag :tags, options_from_collection_for_select(Tag.all, 'id', 'name', @search_params[:tags]), multi_select_options

      = label_tag :plugin_type, 'Contain all of these plugins:', class: label_class
      .col-lg-3
        - collection = [Plugins.registered, 'to_s', lambda { |plugin| plugin.name.demodulize }, @search_params[:plugin_type]]
        = select_tag :plugin_type, options_from_collection_for_select(*collection), multi_select_options

    .page-filter__row
      = label_tag :publish_status, 'Publish status:', class: label_class
      .col-lg-3
        = select_tag :publish_status, options_for_select(Page.publish_statuses.to_a, @search_params[:publish_status]), multi_select_options
      = label_tag :limit, 'Limit number of pages loaded:', class: label_class
      .col-lg-3
        = select_tag :limit, options_for_select([500, 1000], @search_params[:limit]), { class: 'form-control', include_blank: 'No limit' }

      .col-md-12
        = submit_tag 'Filter by these criteria', class: 'btn btn-primary page-filter__submit', id: 'search_button', name: nil
        = button_tag 'Reset filters', type: 'button',  class: 'btn btn-danger page-filter__reset', id: 'filter_reset_button'

  javascript:
    $(function () {
      window.ee.emit('search:load')
    });