ManageIQ/manageiq-ui-classic

View on GitHub
app/views/catalog/_form_basic_info.html.haml

Summary

Maintainability
Test Coverage
- url = form_field_change_url(@edit)

%h3= _('Basic Information')
.catalogs_form#basic_info_div
  = hidden_div_if(@edit && @edit[:ae_tree_select] != true, :id => "ae_tree_select_div") do
    = render(:partial => 'layouts/ae_tree_select')
  .form-horizontal
    .form-group
      %label.col-md-2.control-label
        = _('Name')
      .col-md-10.no-padding
        .col-md-3
          = text_field_tag("name",
                           @edit[:new][:name].to_s,
                           :maxlength         => 40,
                           :class             => "form-control",
                           "data-miq_observe" => {:interval => '.5', :url => url}.to_json)
            
    = javascript_tag(javascript_focus('name'))
    .form-group
      %label.col-md-2.control-label
        = _('Description')
      .col-md-9.no-padding
        .col-md-12
          = text_field_tag("description",
                            @edit[:new][:description],
                            :maxlength         => 60,
                            :class             => "form-control long_text",
                            "data-miq_observe" => {:interval => '.5', :url => url}.to_json)
    .form-group
      %label.col-md-2.control-label
        = _('Display in Catalog')
      .col-md-10.no-padding
        .col-md-3
          = check_box_tag("display", "1", @edit[:new][:display],
                            "data-miq_observe_checkbox" => {:url => url}.to_json)
    .form-group
      %label.col-md-2.control-label
        = _('Catalog')
      .col-md-10
        - catalog_id = @edit[:new][:catalog_id]
        = select_tag('catalog_id',
                     options_for_select(([["<#{_('Unassigned')}>", nil]]) + @available_catalogs, catalog_id),
                     "data-miq_sparkle_on" => true,
                     :class                => "selectpicker")
        :javascript
          miqInitSelectPicker();
          miqSelectPickerEvent('catalog_id', '#{url}')
    .form-group
      %label.col-md-2.control-label
        = _('Dialog')
      .col-md-10
        %p.form-control-static
          - available_dialogs = @edit[:new][:available_dialogs].invert.to_a.sort_by { |a| a.first.downcase }
          - options = [["<#{_('No Dialog')}>", nil]] + available_dialogs
          = select_tag('dialog_id',
                        options_for_select(options, @edit[:new][:dialog_id]),
                        "data-miq_sparkle_on" => true,
                        :class                => "selectpicker")
          :javascript
            miqSelectPickerEvent('dialog_id', '#{url}')
    - unless @edit[:new][:service_type] == "composite"
      .form-group
        %label.col-md-2.control-label
          = _('Zone')
        .col-md-10
          %p.form-control-static
            = select_tag('zone_id',
                          options_for_select([[_("<Choose>"), nil]] + @zones, @edit[:new][:zone_id]),
                          "data-miq_sparkle_on" => true,
                          :class                => "selectpicker")
            :javascript
              miqSelectPickerEvent('zone_id', '#{url}')
    /Add a new selector for the currencies
    .form-group
      %label.col-md-2.control-label
        = _('Select currency')
      .col-md-10
        %p.form-control-static
          - currency = Array(Currency.currencies_for_select)
          = select_tag("currency",
            options_for_select([[_("<Choose>"), nil]] + currency, @edit[:new][:currency]),
            "data-live-search" => "true",
            "class"            => "selectpicker")
          :javascript
            miqInitSelectPicker();
            miqSelectPickerEvent("currency", "#{url}");

    .form-group
      %label.col-md-2.control-label
        %span#price_span
          = @edit[:new][:code_currency]
      .col-md-8.no-padding
        .col-md-10
          = text_field_tag("price",
                           @edit[:new][:price].to_s,
                           :maxlength         => 40,
                           :class             => "form-control",
                           "data-miq_observe" => {:interval => '.5', :url => url}.to_json)

    - if @edit[:new][:st_prov_type] == "generic"
      .form-group
        %label.col-md-2.control-label
          = _('Subtype')
        .col-md-10
          %p.form-control-static
            - if @record.try(:id)
              = h(_(ServiceTemplate::GENERIC_ITEM_SUBTYPES[@edit[:new][:generic_subtype]]))
            - else
              - available_subtypes = ServiceTemplate::GENERIC_ITEM_SUBTYPES.map { |k, v| [_(v), k]} .sort_by { |a| a.first.downcase }
              = select_tag('generic_subtype',
                            options_for_select(available_subtypes, @edit[:new][:generic_subtype]),
                            "data-miq_sparkle_on" => true,
                            :class                => "selectpicker")
              :javascript
                miqSelectPickerEvent('generic_subtype', '#{url}')
    - if @edit[:new][:st_prov_type] == "generic_orchestration"
      - opts = [["<#{_('Choose')}>", nil]] + @edit[:new][:available_templates]
      .form-group
        %label.col-md-2.control-label
          = _('Orchestration Template')
        .col-md-10
          = select_tag('template_id',
                        options_for_select(opts, @edit[:new][:template_id]),
                        "data-miq_sparkle_on" => true,
                        :class                => "selectpicker")
          :javascript
            miqSelectPickerEvent('template_id', '#{url}')
      - if @edit[:new][:template_id]
      - opts = [["<#{_('Choose')}>", nil]] + @edit[:new][:available_managers]
        .form-group
          %label.col-md-2.control-label
            = _('Provider')
          .col-md-10
            = select_tag('manager_id',
                         options_for_select(opts, @edit[:new][:manager_id]),
                         "data-miq_sparkle_on" => true,
                         :class               => "selectpicker")
            :javascript
              miqSelectPickerEvent('manager_id', '#{url}')
    - elsif %w(generic_ansible_tower generic_awx generic_container_template).include?(@edit[:new][:st_prov_type])
      - opts = [["<#{_('Choose')}>", nil]] + @edit[:new][:available_managers]
      .form-group
        %label.col-md-2.control-label
          = _('Provider')
        .col-md-10
          = select_tag('manager_id',
                       options_for_select(opts, @edit[:new][:manager_id]),
                       "data-miq_sparkle_on" => true,
                       :class                => "selectpicker")
          :javascript
            miqSelectPickerEvent('manager_id', '#{url}')
      - if @edit[:new][:manager_id]
        .form-group
          %label.col-md-2.control-label
            = @edit[:new][:st_prov_type] == "generic_ansible_tower" || @edit[:new][:st_prov_type] == "generic_awx" ? _('Ansible Template') : _('Container Template')
          .col-md-10
            - if @edit[:new][:st_prov_type] == "generic_ansible_tower" || @edit[:new][:st_prov_type] == "generic_awx"
              = select_tag('template_id',
                            grouped_options_for_select(@edit[:new][:available_templates], @edit[:new][:template_id]),
                            "data-miq_sparkle_on" => true,
                            :class                => "selectpicker")
            - else
              = select_tag('template_id',
                       options_for_select(@edit[:new][:available_templates], @edit[:new][:template_id]),
                       "data-miq_sparkle_on" => true,
                       :class                => "selectpicker")
            :javascript
              miqSelectPickerEvent('template_id', '#{url}')

    .form-group
      %label.col-md-2.control-label{:title => _("Provisioning Entry Point (NameSpace/Class/Instance)")}
        = _('Provisioning Entry Point')
      .col-md-10.no-padding
        = render(:partial => "entry_point_selector", :locals => {:type => :provision_entry_point_type, :url => url})
        .col-md-9#provision_entry_point
          = render(:partial => "provision_entry_point")      

    - unless %w[generic_container_template generic_ovf_template].include?(@edit[:new][:st_prov_type])
      .form-group
        %label.col-md-2.control-label{:title => _("Reconfigure Entry Point (NameSpace/Class/Instance)")}
          = _('Reconfigure Entry Point')
        .col-md-10.no-padding
          = render(:partial => "entry_point_selector", :locals => {:type => :reconfigure_entry_point_type, :url => url})
          .col-md-9#reconfigure_entry_point
            = render(:partial => "reconfigure_entry_point")

      .form-group
        %label.col-md-2.control-label{:title => _("Retirement Entry Point (NameSpace/Class/Instance)")}
          = _('Retirement Entry Point')
        .col-md-10.no-padding
          = render(:partial => "entry_point_selector", :locals => {:type => :retire_entry_point_type, :url => url})
          .col-md-9#retire_entry_point
            = render(:partial => "retire_entry_point")

    - if role_allows?(:feature => 'rbac_tenant_view')
      = render(:partial => "tenants_tree_show")
  - if @edit[:new][:st_prov_type] == "generic_ovf_template"
    = render(:partial => "form_ovf_template_options")
  - if @edit[:new][:st_prov_type] == "cisco_intersight"
    = render(:partial => "form_server_profile_template_options")