From be7053850ff3c2b144904e25aed54e0f92521355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= Date: Mon, 21 Oct 2019 14:38:29 +0200 Subject: [PATCH] cell: display error message on ajax call failure (#29124) --- combo/apps/dashboard/templates/combo/dashboardcell.html | 1 + combo/public/static/js/combo.public.js | 6 +++++- combo/public/templates/combo/placeholder.html | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/combo/apps/dashboard/templates/combo/dashboardcell.html b/combo/apps/dashboard/templates/combo/dashboardcell.html index 729f6c7d..daf76666 100644 --- a/combo/apps/dashboard/templates/combo/dashboardcell.html +++ b/combo/apps/dashboard/templates/combo/dashboardcell.html @@ -5,6 +5,7 @@
{% render_cell cell %}
diff --git a/combo/public/static/js/combo.public.js b/combo/public/static/js/combo.public.js index d26c6fc3..0ba0b76f 100644 --- a/combo/public/static/js/combo.public.js +++ b/combo/public/static/js/combo.public.js @@ -28,7 +28,11 @@ function combo_load_cell(elem) { $(document).trigger('combo:cell-loaded', $elem); }, error: function(error) { - $elem.find('.loading').addClass('error-loading'); + var msg = $(elem).data('ajax-cell-error-message'); + $elem + .find('.loading') + .addClass('error-loading') + .html('' + msg + ''); window.console && console.log(':(', error); } }); diff --git a/combo/public/templates/combo/placeholder.html b/combo/public/templates/combo/placeholder.html index 695dbdca..dfa97e31 100644 --- a/combo/public/templates/combo/placeholder.html +++ b/combo/public/templates/combo/placeholder.html @@ -8,6 +8,7 @@ {% if cell.slug and cell.use_slug_as_id %}id="{{ cell.slug }}"{% endif %} data-ajax-cell-url="{{ site_base }}{% url 'combo-public-ajax-page-cell' page_pk=cell.page.id cell_reference=cell.get_reference %}" data-ajax-cell-loading-message="{{ cell.loading_message }}" + data-ajax-cell-error-message="{% trans "Loading error" %}" {% if cell.ajax_refresh %}data-ajax-cell-refresh="{{ cell.ajax_refresh }}"{% endif %} {% if request.extra_context_data %}data-extra-context="{{ request.extra_context_data|signed|urlencode }}"{% endif %} >
{% render_cell cell %}