ManageIQ/manageiq-ui-classic

View on GitHub
app/views/layouts/listnav/_show_list.html.haml

Summary

Maintainability
Test Coverage
- if @def_searches.blank? && @my_searches.blank? && !controller.respond_to?(:display_tree)
  %br
  = render :partial => 'layouts/info_msg', :locals => {:message => _("No filters defined.")}
- else
  #accordion.panel-group
    - unless @def_searches.blank?
      - if @panels["#{@view.db}_def_searches"].nil?
        - @panels["#{@view.db}_def_searches"] = true
      = miq_accordion_panel(_("Global Filters"), true, "#{@view.db}_def_searches") do
        %ul.nav.nav-pills.nav-stacked
          - @def_searches.each do |search|
            %li{:class => def_searches_active_filter?(search)}
              = link_to(search_description(search).html_safe,
                {:action => 'listnav_search_selected', :id => search.id, :button => "apply"},
                :remote       => true,
                "data-method" => :post,
                :title        => _("Apply this filter"),
                :onclick      => "return miqCheckForChanges()")
    = render :partial => "layouts/listnav/#{controller_name}_show_list_with_treeview" if controller.respond_to?(:display_tree)
    - unless @my_searches.blank?
      - if @panels["#{@view.db}_my_searches"].nil?
        - @panels["#{@view.db}_my_searches"] = true
      = miq_accordion_panel(_("My Filters"), false, "#{@view.db}_my_searches") do
        %ul.nav.nav-pills.nav-stacked
          - @my_searches.each do |search|
            %li{:class => my_searches_active_filter?(search)}
              = link_to(search_description(search).html_safe,
                {:action => 'listnav_search_selected', :id => search.id, :button => "apply"},
                :remote       => true,
                "data-method" => :post,
                :title        => _("Apply this filter"),
                :onclick      => "return miqCheckForChanges()")


  - if @edit && @edit[:expression] && @edit[:expression][:selected] && (@settings[:default_search] || (@edit[:expression][:selected][:id].to_i != settings(:default_search, @edit[@expkey][:exp_model].to_s.to_sym).to_i) || (!settings(:default_search, @edit[@expkey][:exp_model].to_s.to_sym)))
    - t = _('Set the current filter as my default')
    = link_to(_("Set Default"),
      {:action => "save_default_search", :id => @edit[:expression][:selected][:id].to_i},
      "data-miq_sparkle_on"  => true,
      "data-miq_sparkle_off" => true,
      :class                 => "btn btn-default pull-right",
      :remote                => true,
      "data-method"          => :post,
      :alt                   => t,
      :title                 => t)
  - elsif !@my_searches.blank?
    = button_tag(_("Set Default"),
      :class => "btn btn-default disabled pull-right",
      :title => _("Select a filter to set it as my default"))