Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHSM form - use observe queue for submit #3191

Merged
merged 3 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/assets/javascripts/miq_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,14 @@ function miqAjax(url, serialize_fields, options) {
complete: true,
};

miqJqueryRequest(url, _.extend(defaultOptions, options || {}, { data: data }))
// miqAjaxButton with { observeQueue: true } will queue the request instead of sending directly
var requestFn = miqJqueryRequest;
if (options && options.observeQueue) {
delete options.observeQueue;
requestFn = miqObserveRequest;
}

return requestFn(url, _.extend(defaultOptions, options || {}, { data: data }))
.catch(function(err) {
add_flash(__('Error requesting data from server'), 'error');
console.log(err);
Expand Down
1 change: 1 addition & 0 deletions app/controllers/ops_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ def set_form_locals
record_id = @lt_map.try(:id)
elsif @sb[:active_tab] == 'settings_rhn_edit'
locals[:no_cancel] = false
locals[:observe_queue] = true
action_url = "settings_update"
record_id = @sb[:active_tab].split("settings_").last
else
Expand Down
20 changes: 9 additions & 11 deletions app/views/layouts/_auth_credentials2.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@
- if validate
.form-group
.col-md-10{:align => 'right'}
= link_to(_('Validate'),
{:action => validate_url,
:button => 'validate',
:type => prefix,
:id => record_id},
:class => 'btn btn-primary btn-xs',
:alt => labels[:title],
:title => labels[:title],
:remote => true,
"data-method" => :post,
'data-miq_sparkle_on' => true)
- url = url_for_only_path(:action => validate_url,
:button => 'validate',
:type => prefix,
:id => record_id)
= button_tag(_('Validate'),
:onclick => "miqAjaxButton('#{url}', undefined, { observeQueue: true, beforeSend: true, complete: false })",
:class => 'btn btn-primary btn-xs',
:alt => labels[:title],
:title => labels[:title])
- if validate_note
.note
%b= validate_note
Expand Down
8 changes: 5 additions & 3 deletions app/views/layouts/_x_edit_buttons.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
- export_button ||= nil
-# need to pass this as true if need to send up serialized form data when save is pressed
- serialize ||= false
-# use miqAjaxButton with observeQueue: true (waits for miq-observe inputs first)
- observe_queue ||= false


%div{:style => 'padding-top: 5px'}
Expand All @@ -47,7 +49,7 @@
:class => "btn btn-primary",
:alt => t,
:title => t,
:onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url, :button => "add")}', #{serialize});")
:onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url, :button => "add")}', #{serialize}, #{observe_queue ? '{ observeQueue: true }' : 'null'});")
- else
- if apply_button
= link_to(_("Apply"),
Expand Down Expand Up @@ -95,13 +97,13 @@
:class => "btn btn-primary",
:alt => save_text,
:title => save_text,
:onclick => "if (confirm('#{save_confirm_text}')) miqAjaxButton('#{url_for_only_path(:action => action_url, :id => record_id, :button => "save")}', #{serialize});")
:onclick => "if (confirm('#{save_confirm_text}')) miqAjaxButton('#{url_for_only_path(:action => action_url, :id => record_id, :button => "save")}', #{serialize}, #{observe_queue ? '{ observeQueue: true }' : 'null'});")
- 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")}', #{serialize});")
:onclick => "miqAjaxButton('#{url_for_only_path(:action => action_url, :id => record_id, :button => "save")}', #{serialize}, #{observe_queue ? '{ observeQueue: true }' : 'null'});")

- unless no_reset
= button_tag(_('Reset'),
Expand Down