diff --git a/datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js b/datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js index 3d6cf596e4..a30186a5fc 100644 --- a/datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js +++ b/datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js @@ -426,12 +426,19 @@ $(function() } else { - // Try to close the window - window.close(); + + if(window.history.length === 1) { + // Not a modal, but there is no other history. + // Try to close the window. + window.close(); - // In some browser (eg. Firefox 70), window won't close if it has NOT been open by JS. In that case, we try to redirect to homepage as a fallback. - var sHomepageUrl = (this.options.base_url !== null) ? this.options.base_url : $('#sidebar .menu .brick_menu_item:first a').attr('href') - window.location.href = sHomepageUrl; + // In some browser (eg. Firefox 70), window won't close if it has NOT been open by JS. In that case, we try to redirect to homepage as a fallback. + var sHomepageUrl = (this.options.base_url !== null) ? this.options.base_url : $('#sidebar .menu .brick_menu_item:first a').attr('href') + window.location.href = sHomepageUrl; + } else { + window.history.back(-1); + } + } }, submit: function(oEvent) diff --git a/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig index edd26d5a0f..736161cc9d 100644 --- a/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig +++ b/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig @@ -76,7 +76,7 @@ field_set: oFieldSet_{{ sFormIdSanitized }}, submit_btn_selector: $('#{{ sFormId }}').parent().find('.form_btn_submit, .form_btn_transition'), cancel_btn_selector: $('#{{ sFormId }}').parent().find('.form_btn_cancel'), - base_url: "{{ app['combodo.absolute_url'] }}", + base_url: "{{ app['combodo.portal.base.absolute_url'] }}", {% if form.submit_rule is not null %}submit_rule: {{ form.submit_rule|json_encode|raw }}{% endif %}, {% if form.cancel_rule is not null %}cancel_rule: {{ form.cancel_rule|json_encode|raw }}{% endif %}, endpoint: "{{ form.renderer.GetEndpoint()|raw }}",