ManageIQ/manageiq-ui-classic

View on GitHub
app/views/layouts/_adv_search_footer.html.haml

Summary

Maintainability
Test Coverage
- mode ||= "search"
- force ||= false

#adv_search_footer
  - if force || (show_adv_search? && @edit && @edit[@expkey].present?)
    - report_expressions = MiqReport.get_expressions_by_model(@edit[@expkey][:exp_model])

    - if mode == "search"
      - if @edit[@expkey].available_adv_searches.blank? && report_expressions.blank?
        = button_tag(_("Load"),
                     :class => "btn btn-primary disabled pull-left",
                     :alt   => t = _("No saved filters or report filters are available to load"),
                     :title => t)
      - else
        = button_tag(_('Load'),
                     :class   => "btn btn-primary pull-left",
                     :alt     => t = _("Load a filter"),
                     :title   => t,
                     :onclick => "miqAjax('#{url_for_only_path(:action => 'adv_search_button', :button => "load")}');")
      - if @edit[@expkey][:exp_table].flatten.first == "???"
        = button_tag(_("Apply"),
                     :class => "btn btn-primary disabled",
                     :alt   => t = _("No filter available"),
                     :title => t)
      - else
        = button_tag(_('Apply'),
                     :class   => "btn btn-primary",
                     :alt     => t = _("Apply the current filter"),
                     :title   => t,
                     :onclick => "miqAjaxButton('#{url_for_only_path(:action => 'adv_search_button', :button => "apply")}');$('#advsearchModal').modal('hide');")
      - if @edit[@expkey][:selected] && @edit[@expkey][:selected][:typ] != "default" && @edit[@expkey][:selected][:id] != 0
        - if role_allows?(:feature => 'add_global_filter') || @edit[@expkey][:selected][:typ] == "user"
          - actual_filter = @edit[@expkey][:selected][:description]
          - confirm_msg = _("Delete the %{model} filter named %{filter}?") % {:model  => ui_lookup(:model => @edit[@expkey][:exp_model]),
                                                                              :filter => actual_filter}
          - t = _("Delete the filter named %{filter_name}") % {:filter_name => actual_filter}
          = link_to('Delete',
                    url_for_only_path(:action => 'adv_search_button',
                                      :button => "delete"),
                    :alt           => t,
                    :class         => "btn btn-danger",
                    'data-confirm' => confirm_msg,
                    "data-method"  => :post,
                    :remote        => true,
                    :title         => t)
      - if @edit[@expkey][:exp_table].flatten.first == "???"
        = button_tag(_("Save"),
                     :class => "btn btn-primary disabled",
                     :alt   => t = _("No filter available"),
                     :title => t)
      - else
        = button_tag(_('Save'),
                     :class   => "btn btn-primary",
                     :alt     => t = _("Save the current filter"),
                     :title   => t,
                     :onclick => "miqAjax('#{url_for_only_path(:action => 'adv_search_button', :button => "save")}');")
      - if @edit[@expkey][:exp_table].flatten.first == "???"
        = button_tag(_("Reset"),
                     :class => "btn btn-default disabled",
                     :alt   => t = _("No filter available"),
                     :title => t)
      - else
        = button_tag(_('Reset'),
                     :class   => "btn btn-default",
                     :alt     => t = _("Reset the filter"),
                     :title   => t,
                     :onclick => "miqAjax('#{url_for_only_path(:action => 'adv_search_button', :button => "reset")}');")
    - elsif mode == "load"
      - if @edit[@expkey][:exp_chosen_report].nil? && @edit[@expkey][:exp_chosen_search].nil?
        = button_tag(_("Load"),
                     :class => "btn btn-primary disabled pull-left",
                     :alt   => t = _("Choose a saved filter or report filter to load"),
                     :title => t)
      - else
        = button_tag(_('Load'),
                     :class   => "btn btn-primary pull-left",
                     :alt     => t = _("Load the filter shown above"),
                     :title   => t,
                     :onclick => "miqAjax('#{url_for_only_path(:action => 'adv_search_button', :button => "loadit")}');")
      = button_tag(_('Cancel'),
                     :class   => "btn btn-primary",
                     :alt     => t = _("Cancel the load"),
                     :title   => t,
                     :onclick => "miqAjax('#{url_for_only_path(:action => 'adv_search_button', :button => "cancel")}');")
    - elsif mode == "save"
      = button_tag(_('Save'),
                     :class   => "btn btn-primary",
                     :alt     => t = _("Save the current search"),
                     :title   => t,
                     :onclick => "miqAjax('#{url_for_only_path(:action => 'adv_search_button', :button => "saveit")}');")
      = button_tag(_('Cancel'),
                     :class   => "btn btn-default",
                     :alt     => t = _("Cancel the save"),
                     :title   => t,
                     :onclick => "miqAjax('#{url_for_only_path(:action => 'adv_search_button', :button => "cancel")}');")