mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
js: Allow to mark requests explicitly as autosubmits
This commit is contained in:
parent
dc7a8c8d8b
commit
aa03631eef
@ -304,6 +304,7 @@
|
|||||||
req.fail(this.onFailure);
|
req.fail(this.onFailure);
|
||||||
req.always(this.onComplete);
|
req.always(this.onComplete);
|
||||||
req.autorefresh = autorefresh;
|
req.autorefresh = autorefresh;
|
||||||
|
req.autosubmit = false;
|
||||||
req.scripted = false;
|
req.scripted = false;
|
||||||
req.method = method;
|
req.method = method;
|
||||||
req.action = action;
|
req.action = action;
|
||||||
@ -321,7 +322,7 @@
|
|||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
// The column may have not been shown before. To make the transition
|
// The column may have not been shown before. To make the transition
|
||||||
// delay working we have to wait for the column getting rendered
|
// delay working we have to wait for the column getting rendered
|
||||||
if (req.state() === 'pending') {
|
if (! req.autosubmit && req.state() === 'pending') {
|
||||||
req.$target.addClass('impact');
|
req.$target.addClass('impact');
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -827,7 +828,7 @@
|
|||||||
var a = this.icinga.utils.getUrlHelper().cloneNode(true);
|
var a = this.icinga.utils.getUrlHelper().cloneNode(true);
|
||||||
a.search = locationQuery ? '?' + locationQuery : '';
|
a.search = locationQuery ? '?' + locationQuery : '';
|
||||||
|
|
||||||
if (autoSubmit) {
|
if (req.autosubmit || autoSubmit) {
|
||||||
// Also update a form's action if it doesn't differ from the container's url
|
// Also update a form's action if it doesn't differ from the container's url
|
||||||
var $form = $(referrer.forceFocus).closest('form');
|
var $form = $(referrer.forceFocus).closest('form');
|
||||||
var formAction = $form.attr('action');
|
var formAction = $form.attr('action');
|
||||||
@ -873,7 +874,7 @@
|
|||||||
'replace',
|
'replace',
|
||||||
req.autorefresh,
|
req.autorefresh,
|
||||||
forceFocus,
|
forceFocus,
|
||||||
autoSubmit,
|
req.autosubmit || autoSubmit,
|
||||||
req.scripted
|
req.scripted
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -892,7 +893,7 @@
|
|||||||
req.action,
|
req.action,
|
||||||
req.autorefresh,
|
req.autorefresh,
|
||||||
req.forceFocus,
|
req.forceFocus,
|
||||||
autoSubmit,
|
req.autosubmit || autoSubmit,
|
||||||
req.scripted
|
req.scripted
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -928,7 +929,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! req.autorefresh) {
|
if (! req.autorefresh && ! req.autosubmit) {
|
||||||
// TODO: Hook for response/url?
|
// TODO: Hook for response/url?
|
||||||
var url = req.url;
|
var url = req.url;
|
||||||
|
|
||||||
@ -1021,9 +1022,9 @@
|
|||||||
_this.icinga.loadModule(moduleName);
|
_this.icinga.loadModule(moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(this).trigger('rendered', [req.autorefresh, req.scripted]);
|
$(this).trigger('rendered', [req.autorefresh, req.scripted, req.autosubmit]);
|
||||||
});
|
});
|
||||||
req.$target.trigger('rendered', [req.autorefresh, req.scripted]);
|
req.$target.trigger('rendered', [req.autorefresh, req.scripted, req.autosubmit]);
|
||||||
|
|
||||||
this.icinga.ui.refreshDebug();
|
this.icinga.ui.refreshDebug();
|
||||||
},
|
},
|
||||||
@ -1058,6 +1059,8 @@
|
|||||||
req.$target,
|
req.$target,
|
||||||
req.action,
|
req.action,
|
||||||
req.autorefresh,
|
req.autorefresh,
|
||||||
|
undefined,
|
||||||
|
req.autosubmit,
|
||||||
req.scripted
|
req.scripted
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -1234,7 +1237,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$container.trigger('beforerender', [content, action, autorefresh, scripted]);
|
$container.trigger('beforerender', [content, action, autorefresh, scripted, autoSubmit]);
|
||||||
|
|
||||||
var discard = false;
|
var discard = false;
|
||||||
$.each(_this.icinga.behaviors, function(name, behavior) {
|
$.each(_this.icinga.behaviors, function(name, behavior) {
|
||||||
@ -1269,7 +1272,7 @@
|
|||||||
setTimeout(this.icinga.ui.focusElement.bind(this.icinga.ui), 0, navigationAnchor, $container);
|
setTimeout(this.icinga.ui.focusElement.bind(this.icinga.ui), 0, navigationAnchor, $container);
|
||||||
} else if (! activeElementPath) {
|
} else if (! activeElementPath) {
|
||||||
// Active element was not in this container
|
// Active element was not in this container
|
||||||
if (! autorefresh && ! scripted) {
|
if (! autorefresh && ! autoSubmit && ! scripted) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (typeof $container.attr('tabindex') === 'undefined') {
|
if (typeof $container.attr('tabindex') === 'undefined') {
|
||||||
$container.attr('tabindex', -1);
|
$container.attr('tabindex', -1);
|
||||||
@ -1285,8 +1288,8 @@
|
|||||||
var $activeElement = $(activeElementPath);
|
var $activeElement = $(activeElementPath);
|
||||||
|
|
||||||
if ($activeElement.length && $activeElement.is(':visible')) {
|
if ($activeElement.length && $activeElement.is(':visible')) {
|
||||||
$activeElement[0].focus({preventScroll: autorefresh});
|
$activeElement[0].focus({preventScroll: autorefresh || autoSubmit});
|
||||||
} else if (! autorefresh && ! scripted) {
|
} else if (! autorefresh && ! autoSubmit && ! scripted) {
|
||||||
if (focusFallback) {
|
if (focusFallback) {
|
||||||
_this.icinga.ui.focusElement($(focusFallback.parent).find(focusFallback.child));
|
_this.icinga.ui.focusElement($(focusFallback.parent).find(focusFallback.child));
|
||||||
} else if (typeof $container.attr('tabindex') === 'undefined') {
|
} else if (typeof $container.attr('tabindex') === 'undefined') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user