N°1192 Change "close rule" behaviour to redirect to homepage if browser doesn't let us close the window

This commit is contained in:
Molkobain
2019-11-26 14:57:06 +01:00
parent 2d86599a19
commit a382d6ad35
2 changed files with 7 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ $(function()
$.widget( 'itop.portal_form_handler', $.itop.form_handler,
{
options: {
base_url: null, // Base URL of the application
submit_url: null, // Deprecated. We kept those properties to preserve compatibility with extensions
cancel_url: null, // but you should start using xxx_rule.url as soon as possible.
submit_rule: {
@@ -359,7 +360,12 @@ $(function()
}
else
{
// 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;
}
},
submit: function(oEvent)

View File

@@ -76,6 +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'] }}",
{% 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 }}",