general: allow cells to override "loading..." message (#21853)

This commit is contained in:
Frédéric Péters 2018-02-22 14:25:56 +01:00
parent cb0b80f9bb
commit c4f9dde66e
6 changed files with 13 additions and 3 deletions

View File

@ -3,7 +3,7 @@
{% with cell=tile.cell %}
<div class="cell {{ cell.css_class_names }} {% if cell.slug %}{{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="{% trans "Loading..." %}"
data-ajax-cell-loading-message="{{ cell.loading_message }}"
{% if cell.ajax_refresh %}
data-ajax-cell-refresh="{{ cell.ajax_refresh }}"
{% endif %}><div>{% render_cell cell %}</div></div>

View File

@ -496,6 +496,7 @@ class Items(CellBase):
user_dependant = True
template_name = 'lingo/combo/items.html'
loading_message = _('Loading invoices...')
class Meta:
abstract = True

View File

@ -111,6 +111,7 @@ class Notification(models.Model):
class NotificationsCell(CellBase):
user_dependant = True
ajax_refresh = 120
loading_message = _('Loading notifications...')
class Meta:
verbose_name = _('User Notifications')

View File

@ -356,6 +356,9 @@ class CellBase(models.Model):
# get_badge(self, context); set to None so cell types can be skipped easily
get_badge = None
# message displayed when the cell is loaded asynchronously
loading_message = _('Loading...')
# modify_global_context(self, context, request=None)
# Apply changes to the template context that must visible to all cells in the page
modify_global_context = None
@ -1126,6 +1129,11 @@ class ConfigJsonCell(JsonCellBase):
def template_name(self):
return 'combo/json/%s.html' % self.key
@property
def loading_message(self):
return settings.JSON_CELL_TYPES[self.key].get('loading-message',
CellBase.loading_message)
def get_default_form_class(self):
formdef = settings.JSON_CELL_TYPES[self.key].get('form')
if not formdef:

View File

@ -1,4 +1,4 @@
{% load i18n %}
<div class="loading" data-ajax-cell-must-load="true">
<span class="loading-message">{% trans 'Loading...' %}</span>
<span class="loading-message">{{ cell.loading_message }}</span>
</div>

View File

@ -4,7 +4,7 @@
<div class="cell {{ cell.css_class_names }} {% if cell.slug %}{{cell.slug}}{% endif %} {% if cell|shown_because_admin:request %}shown-because-admin{% endif %}"
{% if cell.slug %}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="{% trans "Loading..." %}"
data-ajax-cell-loading-message="{{ cell.loading_message }}"
{% if cell.ajax_refresh %}
data-ajax-cell-refresh="{{ cell.ajax_refresh }}"
{% endif %}><div>{% render_cell cell %}</div></div>