From 987eeb9def967ee166960ecf38589be66bdf02a5 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Thu, 14 Jul 2022 14:49:03 +0200 Subject: [PATCH] Style LearningUnit in Wagtail --- client/tailwind.config.js | 2 +- server/vbv_lernwelt/learnpath/models.py | 17 ++++ .../templates/wagtailadmin/pages/index.html | 29 ++++-- .../wagtailadmin/pages/listing/_list.html | 96 +++++++++++++++++++ .../pages/listing/_list_explore.html | 8 ++ .../pages/listing/_page_title_explore.html | 41 ++++++++ 6 files changed, 185 insertions(+), 8 deletions(-) create mode 100644 server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_list.html create mode 100644 server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_list_explore.html create mode 100644 server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_page_title_explore.html diff --git a/client/tailwind.config.js b/client/tailwind.config.js index bd222674..5994b410 100644 --- a/client/tailwind.config.js +++ b/client/tailwind.config.js @@ -4,7 +4,7 @@ module.exports = { content: [ './index.html', './src/**/*.{vue,js,ts,jsx,tsx}', - // '../server/vbv_lernwelt/**/*.{html,js}', + // '../server/vbv_lernwelt/**/*.{html,js,py}', ], theme: { fontFamily: { diff --git a/server/vbv_lernwelt/learnpath/models.py b/server/vbv_lernwelt/learnpath/models.py index f2d8344b..14fb1f64 100644 --- a/server/vbv_lernwelt/learnpath/models.py +++ b/server/vbv_lernwelt/learnpath/models.py @@ -150,6 +150,13 @@ class LearningSequence(Page): def get_admin_display_title(self): return f'{self.icon} {self.draft_title}' + def get_admin_display_title_html(self): + return f''' + + <{self.icon} style="height: 32px; width: 32px;"> + {self.draft_title} + ''' + def full_clean(self, *args, **kwargs): super(LearningSequence, self).full_clean(*args, **kwargs) @@ -168,6 +175,9 @@ class LearningUnit(Page): def get_serializer_class(cls): return get_it_serializer_class(cls, field_names=['id', 'title', 'slug', 'type', 'translation_key', 'children']) + def get_admin_display_title_html(self): + return f'{self.draft_title}' + class LearningUnitQuestion(Page): parent_page_types = ['learnpath.LearningUnit'] @@ -220,6 +230,13 @@ class LearningContent(Page): return display_title + def get_admin_display_title_html(self): + return f''' + + + {self.get_admin_display_title()} + ''' + class Meta: verbose_name = "Learning Content" diff --git a/server/vbv_lernwelt/templates/wagtailadmin/pages/index.html b/server/vbv_lernwelt/templates/wagtailadmin/pages/index.html index 337de9c8..02a8b599 100644 --- a/server/vbv_lernwelt/templates/wagtailadmin/pages/index.html +++ b/server/vbv_lernwelt/templates/wagtailadmin/pages/index.html @@ -2,13 +2,28 @@ {% load wagtailadmin_tags i18n %} {% block extra_js %} - {{ block.super }} + {{ block.super }} - + + {% endblock %} diff --git a/server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_list.html b/server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_list.html new file mode 100644 index 00000000..54b82326 --- /dev/null +++ b/server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_list.html @@ -0,0 +1,96 @@ +{% load i18n %} +{% load l10n %} +{% load wagtailadmin_tags %} + + {% if show_ordering_column or show_bulk_actions %} + + {% endif %} + + {% if show_parent %} + + {% endif %} + + + + + + {% block pre_parent_page_headers %} + {% endblock %} + + {% if parent_page %} + {% page_permissions parent_page as parent_page_perms %} + + + + + + + + {% endif %} + + {% block post_parent_page_headers %} + {% endblock %} + + + {% if pages %} + {% trans "Select page" as checkbox_aria_label %} + {% for page in pages %} + {% page_permissions page as page_perms %} + + {% if show_ordering_column %} + + {% elif show_bulk_actions %} + {% include "wagtailadmin/bulk_actions/listing_checkbox_cell.html" with obj_type="page" obj=page aria_labelledby_prefix="page_" aria_labelledby=page.pk|unlocalize aria_labelledby_suffix="_title" %} + {% endif %} + + {% if show_parent %} + + {% endif %} + + + + {% block page_navigation %} + {% endblock %} + + {% endfor %} + {% else %} + {% block no_results %}{% endblock %} + {% endif %} + +
+ {% block parent_page_title %} + {% endblock %} + {% if parent_page.latest_revision_created_at %} +
+ {% blocktrans trimmed with time_period=parent_page.latest_revision_created_at|timesince %}{{ time_period }} + ago{% endblocktrans %}
{% endif %}
+ {% if not parent_page.is_root %} + {{ parent_page.content_type.model_class.get_verbose_name }} + {% endif %} + + {% if not parent_page.is_root %} + {% include "wagtailadmin/shared/page_status_tag.html" with page=parent_page %} + {% endif %} +
{% if orderable and ordering == "ord" %} +
{% trans 'Drag' %}
{% endif %}
+ {{ page.type }} + {% block page_title %} + {% endblock %} + + {% block page_parent_page_title %} + {% with page.get_parent as parent %} + {% if parent %} + {{ parent.specific_deferred.get_admin_display_title }} + {% endif %} + {% endwith %} + {% endblock %} + {% if page.latest_revision_created_at %} +
+ {% blocktrans trimmed with time_period=page.latest_revision_created_at|timesince %}{{ time_period }} + ago{% endblocktrans %}
{% endif %}
{{ page.content_type.model_class.get_verbose_name }} + {% include "wagtailadmin/shared/page_status_tag.html" with page=page %} +
diff --git a/server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_list_explore.html b/server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_list_explore.html new file mode 100644 index 00000000..fd4de9f5 --- /dev/null +++ b/server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_list_explore.html @@ -0,0 +1,8 @@ +{% extends "wagtailadmin/pages/listing/_list_explore.html" %} + +{% load i18n wagtailadmin_tags %} + + +{% block page_title %} + {% include "wagtailadmin/pages/listing/_page_title_explore.html" %} +{% endblock %} diff --git a/server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_page_title_explore.html b/server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_page_title_explore.html new file mode 100644 index 00000000..0b266118 --- /dev/null +++ b/server/vbv_lernwelt/templates/wagtailadmin/pages/listing/_page_title_explore.html @@ -0,0 +1,41 @@ +{% load i18n wagtailadmin_tags %} + +{# The title field for a page in the page listing, when in 'explore' mode #} + +
+ {% if page.is_site_root %} + {% if perms.wagtailcore.add_site or perms.wagtailcore.change_site or perms.wagtailcore.delete_site %} + + {% endif %} + {% endif %} + + {% if page_perms.can_edit %} + + {% if page.get_admin_display_title_html %} + {% autoescape off %}{{ page.get_admin_display_title_html }}{% endautoescape %} + {% else %} + {{ page.get_admin_display_title }} + {% endif %} + + + + + {% else %} + {{ page.get_admin_display_title }} + {% endif %} + + {% if show_locale_labels %} + {{ page.locale.get_display_name }} + {% endif %} + + {% block pages_listing_title_extra %}{% endblock pages_listing_title_extra %} + + {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=page %} + {% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=page %} +
+ +