Skip to content

First attempt at breadcrumbs.#2738

Open
LukasMansour wants to merge 2 commits into
e-valuation:mainfrom
LukasMansour:link-if-not-self-breadcrumbs
Open

First attempt at breadcrumbs.#2738
LukasMansour wants to merge 2 commits into
e-valuation:mainfrom
LukasMansour:link-if-not-self-breadcrumbs

Conversation

@LukasMansour

Copy link
Copy Markdown
Collaborator

First attempt at doing the link-if-not-self-breadcrumbs from issue #2642 .

Comment thread evap/staff/templatetags/staff_templatetags.py Outdated
Comment thread evap/staff/templatetags/staff_templatetags.py Outdated
Comment thread evap/staff/templates/staff_user_bulk_update.html Outdated
Comment thread evap/staff/templates/staff_semester_base.html Outdated
Comment thread evap/staff/templates/staff_infotexts.html Outdated
<li class="breadcrumb-item">{{ evaluation.course.name }}</li>
{% url 'staff:evaluation_edit' evaluation.id as eval_edit_id %}
{% create_breadcrumb eval_edit_id %}
{{ evaluation.course.name }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need this often, could we have two block tags, one breadcrumb_url that forwards all inputs for url and then uses the output as the link target, and one breadcrumb that takes the link target directly?

Code-wise, one could call the other, so it should just be one more line of code in python, but we could skip the additional line in each template to define the URL (and we don't have to think about a variable name -- eval_edit_id is not great, but coming up with a good name is also hard here).

What do you think about this? (cc @niklasmohrin)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

Some time ago, I was thinking about something more radical even, but I am not sure if it works for all cases. (probably not)

Just give the object directly to the breadcrumb helper and let the helper do

if isinstance(obj, Evaluation):
    url = reverse("staff:evaluation_view", ...)
elif isinstance(obj, Course):
    url = ...

and so on. Probably not exactly like this, but similar (we can probably use a match statement to make it a lot nicer).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be possible, however, would probably have to come with some interesting behavior for many of the edge-cases for breadcrumbs. I will look into if it is a nice solution, first intuition is no though.

@niklasmohrin niklasmohrin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about #2738 (comment) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants