Skip to content

Commit 7802d59

Browse files
authored
feat: unified details actions with tabs (#492)
1 parent 47a1181 commit 7802d59

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

src/unfold/templates/admin/change_form.html

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,6 @@
6262
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}{% if form_url %}action="{{ form_url }}" {% endif %}method="post" id="{{ opts.model_name }}_form" novalidate>
6363
{% csrf_token %}
6464

65-
{% if actions_detail %}
66-
<div class="bg-gray-50 flex justify-end mb-4 p-3 rounded-md dark:bg-gray-800">
67-
{% block actions %}
68-
{% for action in actions_detail %}
69-
<a href="{{ action.path }}" class="bg-white text-gray-500 border cursor-pointer flex font-medium items-center px-3 py-2 mr-3 rounded-md shadow-sm text-sm dark:bg-gray-900 dark:border dark:border-gray-700 dark:text-gray-400"
70-
{% for attr_name, attr_value in action.attrs.items %}
71-
{{ attr_name }}="{{ attr_value }}"
72-
{% endfor %}
73-
>
74-
{{ action.title }}
75-
</a>
76-
{% endfor %}
77-
{% endblock %}
78-
</div>
79-
{% endif %}
80-
8165
{% block form_top %}{% endblock %}
8266

8367
<div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<li class="border-b flex-grow text-center md:border-b-0 md:border-r last:border-0 dark:border-gray-800">
2-
<a href="{{ link }}" class="block px-4 py-2 text-gray-500 text-left whitespace-nowrap hover:text-gray-700 dark:text-gray-400 hover:dark:text-gray-200"{% if blank %} target="_blank"{% endif %}>
2+
<a href="{{ link }}" class="block px-4 py-2 text-gray-500 text-left whitespace-nowrap hover:text-gray-700 dark:text-gray-400 hover:dark:text-gray-200"{% if blank %} target="_blank"{% endif %} {% include "unfold/helpers/attrs.html" with attrs=action.attrs %}>
33
{{ title }}
44
</a>
55
</li>

src/unfold/templates/unfold/helpers/tab_list.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% if not is_popup %}
2-
{% if tab_list or actions_list or actions_items or nav_global %}
2+
{% if tab_list or actions_list or actions_detail or actions_items or nav_global %}
33
<div class="flex items-start flex-col mb-4 text-gray-500 text-sm w-full md:border-b dark:md:border-gray-800 md:border-l-0 md:flex-row md:items-center md:justify-end dark:text-gray-400">
44
{% if tab_list %}
55
<ul class="border rounded-md flex flex-col w-full md:flex-row md:border-b-0 md:border-t-0 md:border-l-0 md:border-r-0 dark:border-gray-800">
@@ -15,12 +15,16 @@
1515
</ul>
1616
{% endif %}
1717

18-
{% if actions_list or actions_items or nav_global %}
18+
{% if actions_list or actions_detail or actions_items or nav_global %}
1919
<ul class="border flex flex-col mb-4 mt-2 rounded-md shadow-sm md:flex-row md:mb-2 md:mt-0 dark:border-gray-800 max-md:w-full">
2020
{% for action in actions_list %}
2121
{% include "unfold/helpers/tab_action.html" with title=action.title link=action.path %}
2222
{% endfor %}
2323

24+
{% for action in actions_detail %}
25+
{% include "unfold/helpers/tab_action.html" with title=action.title link=action.path %}
26+
{% endfor %}
27+
2428
{% if actions_items %}
2529
{{ actions_items }}
2630
{% endif %}

src/unfold/templatetags/unfold.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def tab_list(context, opts) -> str:
2626
context={
2727
"tab_list": tabs,
2828
"nav_global": context.get("nav_global"),
29+
"actions_detail": context.get("actions_detail"),
2930
"actions_list": context.get("actions_list"),
3031
"actions_items": context.get("actions_items"),
3132
"is_popup": context.get("is_popup"),

0 commit comments

Comments
 (0)