ManageIQ/manageiq-ui-classic

View on GitHub
app/views/ops/_settings_help_menu_tab.html.haml

Summary

Maintainability
Test Coverage
- if @sb[:active_tab] == "settings_help_menu"
  - url = url_for_only_path(:action => 'help_menu_form_field_changed')

  %h3= _("Customize Help Menu")
  .alert.alert-info
    %span.pficon.pficon-info
    %strong
      = _("Any change to the help menu will take effect upon a full page reload.")
  = form_tag({:action => "settings_update_help_menu"}, :class => "form-horizontal", :method => :post) do
    %table.table.table-borderless
      %tr
        %th
          = _('Menu item label')
        %th
          = _('URL')
        %th
          = _('Open in')

      - Menu::DefaultMenu.help_menu_items.each do |item|
        %tr
          - val = @edit[:new][item.id.to_sym].try(:[], :type) || item.defaults[:type]
          %td
            = text_field_tag("#{item.id}_title", @edit[:new][item.id.to_sym].try(:[], :title),
                             :placeholder => item.defaults[:title],
                             :class => 'form-control',
                             'data-miq_observe' => {:interval => '.5', :url => url}.to_json)
          %td
            = text_field_tag("#{item.id}_href", @edit[:new][item.id.to_sym].try(:[], :href),
                             :placeholder => item.defaults[:href],
                             :class => 'form-control',
                             'data-miq_observe' => {:interval => '.5', :url => url}.to_json,
                             :disabled => val.to_s == 'modal')
          %td
            = select_tag("#{item.id}_type", options_for_select([[_("Current Window"), 'default'],
                                                                [_("New Window"), 'new_window'],
                                                                [_("About Modal"), 'modal']], val.to_s),
                         :class => 'selectpicker')

        :javascript
          miqInitSelectPicker();
          miqSelectPickerEvent("#{item.id}_type", '#{url}')
          $("##{item.id}_type").on('change', function() {
            $("##{item.id}_href").prop('disabled', $(this).val() == 'modal');
          });