ManageIQ/manageiq-ui-classic

View on GitHub
app/views/miq_request/_request_dialog_details.html.haml

Summary

Maintainability
Test Coverage
.form-group{:id => "field_#{field.id}_tr", :style => field.visible ? 'display:block' : 'display:none'}
  %label.control-label.col-md-2{:title => field.description}
    = _(field.label)
  .col-md-8{:title => field.description}
    - case field.type
    - when 'DialogFieldTextBox', 'DialogFieldTextAreaBox'
      - if field.protected?
        ********
      - else
        = h(field.value)

    - when 'DialogFieldCheckBox'
      = check_box_tag(field.name, "1", field.checked?, {:disabled => true})

    - when 'DialogFieldDateControl'
      = h(field.value)

    - when 'DialogFieldDateTimeControl'
      - date_val, time_val = field.value.split(" ")
      - hour_val, minute_val = time_val.split(":")
      = date_val
       at 
      = "#{hour_val.rjust(2, '0')}:#{minute_val.rjust(2, '0')}"
       
      = session[:user_tz]

    - when "DialogFieldRadioButton"
      = h(field.values.detect { |k, _v| k == wf.value(field.name) }.try(:last) || wf.value(field.name))

    - when "DialogFieldDropDownList"
      = h(field.value.blank? ? _("<None>") : field.value.to_s.gsub("\x1F", ", "))

    - when 'DialogFieldTagControl'
      - value = wf.value(field.name) || '' # it returns in format Clasification::id
      - classifications = value.split(',').map do |c|
        - classification = Classification.find_by(id: c.split('::').second)
        - classification.description if classification
      - if classifications.empty?
        = h('')
      -else
        = h(classifications.join(', '))