ManageIQ/manageiq-ui-classic

View on GitHub
app/views/miq_policy_rsop/_rsop_form.html.haml

Summary

Maintainability
Test Coverage
- url = url_for_only_path(:action => 'rsop_option_changed')
- observe = {:url => url}.to_json
#rsop_form_div

  %h3= _("Event Selection")
  %form
    .form-group
      %label.control-label
        = _("Type")
      = select_tag('event_typ',
        options_for_select([["<#{_('Choose')}>", nil]] + @rsop_events, @sb[:rsop][:event]),
        :class => "selectpicker form-control")

      :javascript
        miqInitSelectPicker();
        miqSelectPickerEvent("event_typ", "#{url}");

    - unless @sb[:rsop][:event].nil?
      .form-group
        %label.control-label
          = _("Event")
        = select_tag('event_value',
          options_for_select([["<#{_('Choose')}>", nil]] + @rsop_event_sets, @sb[:rsop][:event_value]),
          :class => "selectpicker form-control")
        :javascript
          miqSelectPickerEvent("event_value", "#{url}");

    %h3= _("VM Selection")
    .form-group
      %label.control-label
      = select_tag('filter_typ',
        options_for_select([["<#{_('Choose')}>", nil],
          [_("By Cloud/Infrastructure Providers"), "ems"],
          [_("By Clusters"), "cluster"],
          [_("By Host"), "host"],
          [_("Single VM/Instance"), "vm"]], @sb[:rsop][:filter]),
          :class => "selectpicker form-control")
      :javascript
        miqSelectPickerEvent("filter_typ", "#{url}");

    .form-group
      - if @sb[:rsop][:filter] == "host"

        = select_tag('filter_value',
          options_for_select([["<#{_('Choose')}>", nil]] + Array(@sb[:rsop][:hosts].invert).sort, @sb[:rsop][:filter_value]),
          :class => "selectpicker form-control")
      - elsif @sb[:rsop][:filter] == "cluster"

        = select_tag('filter_value',
          options_for_select([["<#{_('Choose')}>", nil]] + Array(@sb[:rsop][:clusters].invert).sort, @sb[:rsop][:filter_value]),
          :class => "selectpicker form-control")
      - elsif @sb[:rsop][:filter] == "ems"

        = select_tag('filter_value',
          options_for_select([["<#{_('Choose')}>", nil]] + Array(@sb[:rsop][:emss].invert).sort, @sb[:rsop][:filter_value]),
          :class => "selectpicker form-control")
      - elsif @sb[:rsop][:filter] == "vm"
        = select_tag('filter_value',
          options_for_select([["<#{_('Choose')}>", nil]] + Array(@sb[:rsop][:vms].invert).sort, @sb[:rsop][:filter_value]),
          :class => "selectpicker form-control")
      :javascript
        miqSelectPickerEvent("filter_value", "#{url}");