ManageIQ/manageiq-ui-classic

View on GitHub
app/views/miq_ae_class/_method_form.html.haml

Summary

Maintainability
Test Coverage
- if @sb[:active_tab] == "methods"
- url = url_for_only_path(:action => 'form_method_field_changed', :id => (@ae_method.id || 'new'))
- obs = {:interval => '.5', :url => url}.to_json
  %h3
    = _('Main Info')
  .form-horizontal
    - unless @edit[:new][:location]
      .form-group
        %label.col-md-2.control-label
          = _('Type')
        .col-md-8
          = select_tag("#{prefix}method_location",
                        options_for_select([[_("<Choose>"), nil]] + available_locations_with_labels,
                        @edit[:new][:location]),
                        :class    => "selectpicker",
                        "data-miq_observe" => {:url => url}.to_json)
          :javascript
            miqInitSelectPicker();
            miqSelectPickerEvent("#{prefix}method_location", "#{url}", {beforeSend: true})
    - else
      .form-group
        %label.col-md-2.control-label
          = _('Type')
        .col-md-8
          %p.form-control-static
            = location_fancy_name(@edit[:new][:location])
      .form-group
        %label.col-md-2.control-label
          = _('Fully Qualified Name')
        .col-md-8
          %p.form-control-static
            = h(@sb[:namespace_path])
      .form-group
        %label.col-md-2.control-label
          = _('Name')
        .col-md-8
          = text_field_tag("#{prefix}method_name",
                          @edit[:new][:name],
                          :maxlength         => ViewHelper::MAX_NAME_LEN,
                          :class => "form-control",
                          "data-miq_observe" => obs)
      .form-group
        %label.col-md-2.control-label
          = _('Display Name')
        .col-md-8
          = text_field_tag("#{prefix}method_display_name",
                          @edit[:new][:display_name],
                          :maxlength         => ViewHelper::MAX_NAME_LEN,
                          :class => "form-control",
                          "data-miq_observe" => obs)

      - if @ae_method.created_on
        .form-group
          %label.col-md-2.control-label
            = _("Created On")
          .col-md-8
            = h(format_timezone(@ae_method.created_on, Time.zone, "gtl"))
      - if @edit[:new][:location] == 'inline'
        = render :partial => "embedded_methods"
      - if @edit[:new][:location] == 'expression'
        = render :partial => "expression", :locals => {:prefix => prefix, :url => url}
      - elsif @edit[:new][:location] # buildin or inline
        %hr
        %h3= @edit[:new][:location] == 'builtin' ? _('Builtin name') : _("Data")
        = render :partial => "method_data", :locals => {:field_name => "#{prefix}method"}
        %hr
    - if @edit[:new][:location] == 'expression'
      .div
        = render :partial => 'layouts/exp_editor'

    - if @edit[:new][:location]
      %h3= _("Input Parameters")
      %table.table.table-bordered.table-striped
        %thead
          %tr
            %th
              - icon = @sb[:squash_state] ? "down" : "up"
              - url2 = url_for_only_path(:action => 'expand_toggle', :id => "exp_collapse")
              %button.btn.btn-default{:title => (@sb[:squash_state] ? _("Show Input Parameters") : _("Hide Input Parameters")),
                      "data-miq_sparkle_on" => true,
                      :remote               => true,
                      "data-method"         => :post,
                      :id                   => 'exp_collapse_img',
                      'data-click_url'      => {:url => url2}.to_json}
                %i{:class => "fa fa-angle-#{icon} fa-lg"}

      %div{:id => 'inputs_div', :style => @sb[:squash_state] ? "display: none;" : ""}
        = render :partial => "inputs"