ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
Test Coverage
- url = url_for_only_path(:action => 'form_instance_field_changed', :id => (@ae_inst.id || "new"))
- obs = {:interval => '.5', :url => url}.to_json
%h3
  = _('Main Info')
.form-horizontal
  .form-group
    %label.col-md-2.control-label
      = _('Fully Qualified Name')
    .col-md-8
      = h(@sb[:namespace_path])
  .form-group
    %label.col-md-2.control-label
      = _('Name')
    .col-md-8
      = text_field_tag("#{prefix}inst_name",
                        @edit[:new][:ae_inst]["name"],
                        :maxlength         => ViewHelper::MAX_NAME_LEN,
                        :class => "form-control",
                        "data-miq_observe" => obs)
      = javascript_tag(javascript_focus("#{prefix}inst_name"))
  .form-group
    %label.col-md-2.control-label
      = _('Display Name')
    .col-md-8
      = text_field_tag("#{prefix}inst_display_name",
                      @edit[:new][:ae_inst]["display_name"],
                      :maxlength         => ViewHelper::MAX_NAME_LEN,
                      :class => "form-control",
                      "data-miq_observe" => obs)
  .form-group
    %label.col-md-2.control-label
      = _('Description')
    .col-md-8
      = text_field_tag("#{prefix}inst_description",
                      @edit[:new][:ae_inst]["description"],
                      :maxlength         => ViewHelper::MAX_NAME_LEN,
                      :class => "form-control",
                      "data-miq_observe" => obs)
%hr
%h3= _('Fields')
%table.table.table-striped.table-bordered
  - state_class = state_class?(@edit[:ae_class_id])
  %thead
    %tr
      %th= _('Name')
      %th= _('Value')
      - if state_class
        %th= _('On Entry')
        %th= _('On Exit')
        %th= _('On Error')
        %th= _('Max Retries')
        %th= _('Max Time')
      %th= _('Collect')
  %tbody
    - @edit[:new][:ae_values].each_with_index do |flds, i|
      - non_state_field = @edit[:new][:ae_fields][i]["aetype"] != "state"
      %tr
        - glyphicon = @edit[:new][:ae_fields][i]["substitute"] ? "pficon pficon-ok" : "pficon pficon-close"
        %td.text-nowrap
          %i.fa-lg{:class => ae_field_fonticon(@edit[:new][:ae_fields][i]["aetype"]),
                :alt => (t = "#{_('Type:')} #{@edit[:new][:ae_fields][i]["aetype"]}"),
                :title => t}
          - if !@edit[:new][:ae_fields][i]["datatype"].blank? && @edit[:new][:ae_fields][i]["datatype"] != "string"
            %i.fa-lg{:class => ae_field_fonticon(@edit[:new][:ae_fields][i]["datatype"]),
                :alt => (t = "#{_('Data Type:')} #{@edit[:new][:ae_fields][i]["datatype"]}"),
                :title => t}

          %i.fa-lg{:class => "#{glyphicon}",
            :alt => (t = "#{_('Substitution:')} #{@edit[:new][:ae_fields][i]["substitute"]}"),
            :title => t}
           
          = h(@edit[:new][:ae_fields][i]["display_name"])
          (#{h(@edit[:new][:ae_fields][i]["name"])})
        %td
          - default_value = @edit[:new][:ae_fields][i]["default_value"]
          - if @edit[:new][:ae_fields][i]["datatype"] == "password"
            = password_field_tag("#{prefix}inst_password_value_#{i}", '',
              :placeholder       => placeholder_if_present(default_value),
              "data-miq_observe" => obs)
          - else
            = text_field_tag("#{prefix}inst_value_#{i}",
              flds["value"].blank? ? '' : flds["value"],
              :placeholder       => default_value,
              "data-miq_observe" => obs)
        - if state_class
          %td
            - default_value = @edit[:new][:ae_fields][i]["on_entry"]
            = text_field_tag("#{prefix}inst_on_entry_#{i}",
              flds["on_entry"].blank? ? '' : flds["on_entry"],
              :placeholder       => default_value,
              :disabled          => non_state_field,
              "data-miq_observe" => obs)
          %td
            - default_value = @edit[:new][:ae_fields][i]["on_exit"]
            = text_field_tag("#{prefix}inst_on_exit_#{i}",
              flds["on_exit"].blank? ? '' : flds["on_exit"],
              :placeholder       => default_value,
              :disabled          => non_state_field,
              "data-miq_observe" => obs)
          %td
            - default_value = @edit[:new][:ae_fields][i]["on_error"]
            = text_field_tag("#{prefix}inst_on_error_#{i}",
              flds["on_error"].blank? ? '' : flds["on_error"],
              :placeholder       => default_value,
              :disabled          => non_state_field,
              "data-miq_observe" => obs)
          %td
            - default_value = @edit[:new][:ae_fields][i]["max_retries"]
            = text_field_tag("#{prefix}inst_max_retries_#{i}",
              flds["max_retries"].blank? ? '' : flds["max_retries"],
              :placeholder       => default_value,
              :disabled          => non_state_field,
              "data-miq_observe" => obs)
          %td
            - default_value = @edit[:new][:ae_fields][i]["max_time"]
            = text_field_tag("#{prefix}inst_max_time_#{i}",
              flds["max_time"].blank? ? '' : flds["max_time"],
              :placeholder       => default_value,
              :disabled          => non_state_field,
              "data-miq_observe" => obs)
        %td
          - default_value = @edit[:new][:ae_fields][i]["collect"]
          = text_field_tag("#{prefix}inst_collect_#{i}",
            flds["collect"].blank? ? '' : flds["collect"],
            :placeholder       => default_value,
            :disabled          => !%w(relationship state).include?(@edit[:new][:ae_fields][i]["aetype"]),
            "data-miq_observe" => obs)