ManageIQ/manageiq-ui-classic

View on GitHub
app/views/layouts/_edit_buttons.html.haml

Summary

Maintainability
Test Coverage
- action_url ||= "update"
- record_id ||= nil
- noreset ||= nil
- align ||= "right"

%table{:width => "100%"}
  %tr
    %td{:align => align}
      #buttons_on{:style => "display:#{@changed ? "display" : "none"};"}
        - if record_id.blank?
          = button_tag(_("Add"),
                       :class   => 'btn btn-primary',
                       :alt     => t = _("Add"),
                       :title   => t,
                       :onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url,
                                                             :button => "add")}');")
        - else
          = button_tag(_("Save"),
                       :class   => 'btn btn-primary',
                       :alt     => t = _("Save Changes"),
                       :title   => t,
                       :onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url,
                                                             :id     => record_id,
                                                             :button => "save")}');")
          - unless noreset
            = button_tag(_("Reset"),
                         :class   => 'btn btn-default',
                         :alt     => t = _("Reset Changes"),
                         :title   => t,
                         :onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url,
                                                               :id     => record_id,
                                                               :button => "reset")}');")
        = button_tag(_("Cancel"),
                     :class   => 'btn btn-default',
                     :alt     => t = _("Cancel"),
                     :title   => t,
                     :onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url,
                                                           :id     => record_id,
                                                           :button => "cancel")}');")
      #buttons_off{:style => "display:#{@changed ? "none" : "display"};"}
        - if record_id.blank?
          = button_tag(_("Add"),
                       :class   => 'btn btn-default disabled',
                       :alt     => t = _("Add"),
                       :title   => t)
        - else
          = button_tag(_("Save"), :class => "btn btn-primary disabled")
          - unless noreset
            = button_tag(_("Verify"), :class => "btn btn-primary disabled")
        = button_tag(_("Cancel"),
                     :class   => 'btn btn-default',
                     :alt     => t = _("Cancel"),
                     :title   => t,
                     :onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url,
                                                           :id     => record_id,
                                                           :button => "cancel")}');")