From 2b3f1eaaf098f80db748eff20296ffc13f14a274 Mon Sep 17 00:00:00 2001 From: jbostoen <6421683+jbostoen@users.noreply.github.com> Date: Mon, 16 Jan 2023 19:40:29 +0100 Subject: [PATCH 1/4] * Fix for 'cancel' button in portal --- .../portal/public/js/portal_form_handler.js | 22 ++++++++++++++----- .../bricks/object/mode_create.html.twig | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) 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..07846a8b6a 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,24 @@ $(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 }}", From fc841aac1f032ea3dfdc0f77392998b9725018ad Mon Sep 17 00:00:00 2001 From: jbostoen <6421683+jbostoen@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:20:55 +0100 Subject: [PATCH 2/4] Update datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js Co-authored-by: Molkobain --- .../itop-portal-base/portal/public/js/portal_form_handler.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 07846a8b6a..3f7ea5af52 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 @@ -427,8 +427,7 @@ $(function() else { - if(window.history.length == 1) { - + if(window.history.length === 1) { // Not a modal, but there is no other history. // Try to close the window. window.close(); From 79f588668463a2b099e51e0f5bc67a195d762445 Mon Sep 17 00:00:00 2001 From: jbostoen <6421683+jbostoen@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:21:03 +0100 Subject: [PATCH 3/4] Update datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js Co-authored-by: Molkobain --- .../2.x/itop-portal-base/portal/public/js/portal_form_handler.js | 1 - 1 file changed, 1 deletion(-) 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 3f7ea5af52..b443b7dddd 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 @@ -440,7 +440,6 @@ $(function() else { window.history.back(-1); - } } From f15d3fb9d6d57f222b4fcf1568d4ecfa6c224eca Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 17 Jan 2023 19:37:05 +0100 Subject: [PATCH 4/4] Update datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js --- .../itop-portal-base/portal/public/js/portal_form_handler.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 b443b7dddd..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 @@ -435,10 +435,7 @@ $(function() // 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 { - + } else { window.history.back(-1); }