mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
modal.js: Use a modal toggle's container as redirect target by default
Not the container's base target. The redirect target may still be overridden by `data-base-target` on the `form` or by the response using `X-Icinga-Container`.
This commit is contained in:
parent
257a7070a1
commit
51992f414e
@ -40,7 +40,7 @@
|
|||||||
var $a = $(event.currentTarget);
|
var $a = $(event.currentTarget);
|
||||||
var url = $a.attr('href');
|
var url = $a.attr('href');
|
||||||
var $modal = _this.$ghost.clone();
|
var $modal = _this.$ghost.clone();
|
||||||
var $urlTarget = _this.icinga.loader.getLinkTargetFor($a, false);
|
var $redirectTarget = $a.closest('.container');
|
||||||
|
|
||||||
_this.modalOpener = event.currentTarget;
|
_this.modalOpener = event.currentTarget;
|
||||||
|
|
||||||
@ -50,8 +50,8 @@
|
|||||||
// Add showCompact, we don't want controls in a modal
|
// Add showCompact, we don't want controls in a modal
|
||||||
url = _this.icinga.utils.addUrlFlag(url, 'showCompact');
|
url = _this.icinga.utils.addUrlFlag(url, 'showCompact');
|
||||||
|
|
||||||
// Set the toggle's base target on the modal to use it as redirect target
|
// Set the toggle's container to use it as redirect target
|
||||||
$modal.data('redirectTarget', $urlTarget);
|
$modal.data('redirectTarget', $redirectTarget);
|
||||||
|
|
||||||
// Final preparations, the id is required so that it's not `display:none` anymore
|
// Final preparations, the id is required so that it's not `display:none` anymore
|
||||||
$modal.attr('id', 'modal');
|
$modal.attr('id', 'modal');
|
||||||
@ -68,7 +68,7 @@
|
|||||||
if (req.status >= 500) {
|
if (req.status >= 500) {
|
||||||
// Yes, that's done twice (by us and by the base fail handler),
|
// Yes, that's done twice (by us and by the base fail handler),
|
||||||
// but `renderContentToContainer` does too many useful things..
|
// but `renderContentToContainer` does too many useful things..
|
||||||
_this.icinga.loader.renderContentToContainer(req.responseText, $urlTarget, req.action);
|
_this.icinga.loader.renderContentToContainer(req.responseText, $redirectTarget, req.action);
|
||||||
} else if (req.status > 0) {
|
} else if (req.status > 0) {
|
||||||
var msg = $(req.responseText).find('.error-message').text();
|
var msg = $(req.responseText).find('.error-message').text();
|
||||||
if (msg && msg !== errorThrown) {
|
if (msg && msg !== errorThrown) {
|
||||||
@ -115,7 +115,6 @@
|
|||||||
|
|
||||||
var req = _this.icinga.loader.submitForm($form, $autoSubmittedBy, $button);
|
var req = _this.icinga.loader.submitForm($form, $autoSubmittedBy, $button);
|
||||||
req.addToHistory = false;
|
req.addToHistory = false;
|
||||||
req.$redirectTarget = $modal.data('redirectTarget');
|
|
||||||
req.done(function (data, textStatus, req) {
|
req.done(function (data, textStatus, req) {
|
||||||
var title = req.getResponseHeader('X-Icinga-Title');
|
var title = req.getResponseHeader('X-Icinga-Title');
|
||||||
if (!! title) {
|
if (!! title) {
|
||||||
@ -129,6 +128,10 @@
|
|||||||
delete $modal[0].dataset.noIcingaAjax;
|
delete $modal[0].dataset.noIcingaAjax;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (! ('baseTarget' in $form[0].dataset)) {
|
||||||
|
req.$redirectTarget = $modal.data('redirectTarget');
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof $autoSubmittedBy === 'undefined') {
|
if (typeof $autoSubmittedBy === 'undefined') {
|
||||||
// otherwise the form is submitted several times by clicking the "Submit" button several times
|
// otherwise the form is submitted several times by clicking the "Submit" button several times
|
||||||
$form.find('input[type=submit],button[type=submit],button:not([type])').prop('disabled', true);
|
$form.find('input[type=submit],button[type=submit],button:not([type])').prop('disabled', true);
|
||||||
|
@ -732,6 +732,12 @@
|
|||||||
oldNotifications = $('#notifications li').detach();
|
oldNotifications = $('#notifications li').detach();
|
||||||
this.icinga.ui.layout1col();
|
this.icinga.ui.layout1col();
|
||||||
newBody = true;
|
newBody = true;
|
||||||
|
} else if ($newTarget.attr('id') === 'col2') {
|
||||||
|
if (_this.icinga.ui.isOneColLayout()) {
|
||||||
|
_this.icinga.ui.layout2col();
|
||||||
|
} else if (target === '_next') {
|
||||||
|
_this.icinga.ui.moveToLeft();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user