ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
Test Coverage
#buttons_div
  %table{:width => "100%"}
    %tr
      %td{:align => "right"}
        #buttons_on{:style => session[:changed] ? "" : "display: none;"}
          - @edit[:buttons].each do |button|
            - next unless [:cancel, :continue, :submit].include?(button)
            - case button
            - when :cancel
              - button_name = _("Cancel")
              - text = _("Cancel this provisioning request")
            - when :submit
              - button_name = _("Submit")
              - text = _("Submit this provisioning request")
            - when :continue
              - button_name = _("Continue")
              - text = _("Continue this provisioning request")
            - action       = button == :continue ? 'prov_continue' : 'prov_edit'
            - button_class = button == :cancel ? 'default' : 'primary'
            - url          = url_for_only_path(:action => action, :id => (@edit[:req_id] || 'new'), :button => button)
            = button_tag(button_name,
              :class   => "btn btn-#{button_class}",
              :alt     => text,
              :title   => text,
              :onclick => "miqAjaxButton('#{url}');")

        #buttons_off{:style => session[:changed] ? "display: none;" : ""}
          - @edit[:buttons].each do |button|
            - case button
            - when :continue, :submit
              = button_tag(_("Continue"), :class => "btn btn-primary disabled")
            - when :submit
              = button_tag(_("Submit"), :class => "btn btn-primary disabled")
            - when :cancel
              - url = url_for_only_path(:action => 'prov_edit', :id => (@edit[:req_id] || 'new'), :button => button)
              = button_tag(_("Cancel"),
                :class   => "btn btn-default",
                :alt     => (t = _("Cancel this provisioning request")),
                :title   => t,
                :onclick => "miqAjaxButton('#{url}');")