ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
Test Coverage
- save_text ||= _("Save Changes")
- save_confirm_text ||= nil
- ajax_buttons ||= false
- serialize ||= false
- action_url ||= "update"
.row.pull-right
  .col-md-12.col-lg-12
    #buttons_on{:style => "display:#{@changed ? 'block' : 'none'}"}
      - if ajax_buttons
        - if serialize
          = button_tag(_('Save'),
            :class   => 'btn btn-primary',
            :alt     => save_text,
            :title   => save_text,
            :onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url, :id => record_id, :button => 'save')}', true);")
        - else
          = button_tag(_('Save'),
            :class   => 'btn btn-primary',
            :alt     => save_text,
            :title   => save_text,
            :onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url, :button => 'save')}');")
      - else
        - if save_confirm_text
          = button_tag(_("Save"),
            :id      => "save",
            :class   => "btn btn-primary",
            :name    => "save",
            :alt     => save_text,
            :title   => save_text,
            :type    => "submit",
            :confirm => save_confirm_text)
        - else
          = button_tag(_("Save"),
            :id      => "save",
            :class   => "btn btn-primary",
            :name    => "save",
            :alt     => save_text,
            :title   => save_text,
            :type    => "submit")

      - if ajax_buttons
        = button_tag(_('Reset'),
          :class   => 'btn btn-default',
          :alt     => t = _("Reset Changes"),
          :title   => t,
          :onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url, :button => 'reset')}');")
      - else
        = button_tag(_('Reset'),
          :id      => "reset",
          :class   => "btn btn-default",
          :name    => "reset",
          :alt     => t = _("Reset Changes"),
          :title   => t,
          :type    => "submit")
        - unless @layout == "configuration" || @layout == "ops" || @layout == "chargeback" || @layout == "miq_ae_class"
          = button_tag(t = _("Cancel"),
            :id      => "cancel",
            :class   => "btn btn-default",
            :name    => "cancel",
            :alt     => t,
            :title   => t,
            :type    => "submit")

    #buttons_off{:style => "display: #{@changed ? 'none' : 'block'}"}
      = button_tag(_("Save"),  :class => "btn btn-primary disabled", :type => 'button')
      = button_tag(_("Reset"), :class => "btn btn-default disabled", :type => 'button')

      - unless  @layout == "configuration" || @layout == "ops" || @layout == "chargeback" || @layout == "miq_ae_class"
        = button_tag(t = _("Cancel"),
          :id      => "cancel",
          :class   => "btn btn-default",
          :name    => "cancel",
          :alt     => t,
          :title   => t,
          :type    => "submit")