Просмотр исходного кода

Customer portal : Added user feedback when modal dialog loading crashes server side

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4181 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 9 лет назад
Родитель
Сommit
ebec7cae4e
1 измененных файлов с 14 добавлено и 3 удалено
  1. 14 3
      datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig

+ 14 - 3
datamodels/2.x/itop-portal-base/portal/src/views/layout.html.twig

@@ -278,7 +278,7 @@
 						<div class="alert">
 						</div>
 						<div class="text-right">
-							<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'Portal:Button:Close'|dict_s }}</button>
+							<button type="button" class="btn btn-primary" data-dismiss="modal">{{ 'Portal:Button:Close'|dict_s }}</button>
 						</div>
 					</div>
 				</div>
@@ -304,13 +304,14 @@
 				sUrl += (sUrl.split('?')[1] ? '&':'?') + sParamName + '=' + sParamValue;
 				return sUrl;
 			};
-		
+			var contentLoaderTemplate = '<div class="content_loader"><div class="icon glyphicon glyphicon-refresh"></div><div class="message">{{ 'Page:PleaseWait'|dict_s }}</div></div>';
+			
 			$(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('<div class="content_loader"><div class="icon glyphicon glyphicon-refresh"></div><div class="message">{{ 'Page:PleaseWait'|dict_s }}</div></div>');
+						$(this).find('.modal-content').html(contentLoaderTemplate);
 					});
 					// Hack to enable multiple modals by making sure the .modal-open class is set to the <body> 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 %}
 			});
 		</script>