diff --git a/datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig
index 1f0588d7f4..2be659ad15 100644
--- a/datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig
+++ b/datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig
@@ -278,7 +278,7 @@
{{ 'Page:PleaseWait'|dict_s }}
';
+
$(document).ready(function(){
{% block pPageReadyScripts %}
// Hack to enable a same modal to load content from different urls
$('body').on('hidden.bs.modal', '.modal#modal-for-all', function () {
$(this).removeData('bs.modal');
- $(this).find('.modal-content').html('{{ 'Page:PleaseWait'|dict_s }}
');
+ $(this).find('.modal-content').html(contentLoaderTemplate);
});
// Hack to enable multiple modals by making sure the .modal-open class is set to the when there is at least one modal open left
$('body').on('hidden.bs.modal', function () {
@@ -323,6 +324,16 @@
$('body').on('show.bs.modal', function () {
$(this).find('.tooltip.in').tooltip('hide');
});
+ // Display a error message on modal if the content could not be loaded.
+ // Note : As of now, we can't display a more detailled message based on the response because Bootstrap doesn't pass response data with the loaded event.
+ $('body').on('loaded.bs.modal', function (oEvent) {
+ if($(oEvent.target).find('.modal-content').html().replace(/[\n\r\t]+/g, '') === contentLoaderTemplate)
+ {
+ $(oEvent.target).find('.modal-content').html($('#modal-for-alert .modal-content').html());
+ $(oEvent.target).find('.modal-content .modal-header .modal-title').text('{{ 'Error:HTTP:500'|dict_s }}');
+ $(oEvent.target).find('.modal-content .modal-body .alert').addClass('alert-danger').text('{{ 'Error:XHR:Fail'|dict_s }}');
+ }
+ });
{% endblock %}
});