EagerELK/ditty

View on GitHub
views/partials/search.haml

Summary

Maintainability
Test Coverage
- if self.class.const_defined?(:SEARCHABLE) && SEARCHABLE.count.positive? || self.class.const_defined?(:FILTERS) && FILTERS.count.positive?
  = form_tag(base_path, form_verb: :get, attributes: { class: '' }) do
    - if self.class.const_defined?(:SEARCHABLE) && SEARCHABLE.count.positive?
      .form-group
        .input-group
          %input.form-control{ name: 'q', type: 'text', placeholder: 'Search...', value: params[:q] }
          .input-group-btn
            %button.btn.btn-primary{ type: 'submit' }
              %span.fa.fa-search
          - if self.class.const_defined?(:FILTERS) && FILTERS.count.positive?
            .input-group-btn
              %button.btn.btn-secondary{ type: 'button', :'data-toggle' => 'collapse', :'data-target' => '#filter-form', :'aria-expanded' => 'false', :'aria-controls' => '#filter-form'}
                %span.fa.fa-arrow-down

    - if self.class.const_defined?(:FILTERS) && FILTERS.count.positive?
      #filter-form{ class: self.class.const_defined?(:SEARCHABLE) && SEARCHABLE.count.positive? ? 'collapse' : '' }
        .card.card-default.mb-2
          .card-body
            .row
              - FILTERS.each do |filter|
                = filter_control(filter, filters: FILTERS.count)
              - unless self.class.const_defined?(:SEARCHABLE) && SEARCHABLE.count.positive?
                .form-group
                  %label
                  %button.form-control.btn.btn-secondary{ type: 'submit'} Go