Skip to content

Refactoring: link-if-not-self-link breadcrumb helper template block tag #2642

@richardebeling

Description

@richardebeling

For the breadcrumbs at the top of the page, we want elements to be clickable links unless the user is already on the page that we would link to. Currently, we typically implement this with extra state passed to the template:

{% if disable_breadcrumb_course %}
<li class="breadcrumb-item">{{ course.name }}</li>
{% else %}
<li class="breadcrumb-item"><a href="{% url 'staff:course_edit' course.id %}">{{ course.name }}</a></li>
{% endif %}

{% if disable_breadcrumb_course %}
<li class="breadcrumb-item">{{ course.name }}</li>
{% else %}
<li class="breadcrumb-item"><a href="{% url 'grades:course_view' course.id %}">{{ course.name }}</a></li>
{% endif %}

{% if disable_breadcrumb_semester %}
<li class="breadcrumb-item">{{ semester.name }}</li>
{% else %}
<li class="breadcrumb-item"><a href="{% url 'staff:semester_view' semester.id %}">{{ semester.name }}</a></li>
{% endif %}

and one instance is being added in #2599 in evap/staff/templates/staff_questionnaire_base.html

This requires juggling additional state. It should be possible to build a custom django template block tag that is just passed the target URL and then selectively adds the HTML anchor only if the user isn't already on this page.

Some more context:

Metadata

Metadata

Assignees

No one assigned

    Labels

    [C] FrontendFocuses on frontend implementation[P] Nice to haveLowest priority. Some people might use this feature but it won't have a big impact.[S] SmallThis issue should require only small changes.[T] RefactoringExisting parts should become faster, more readable, or in any other way better.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions