Skip to content

Commit e8f7a62

Browse files
authored
fix: submit line action attrs (#472)
1 parent 2005dc4 commit e8f7a62

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

src/unfold/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ def get_unfold_action(self, action: str) -> UnfoldAction:
464464
method=method,
465465
description=self._get_action_description(method, action),
466466
path=self._get_action_url(method, action),
467+
attrs=method.attrs if hasattr(method, "attrs") else None,
467468
)
468469

469470
@staticmethod

src/unfold/dataclasses.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dataclasses import dataclass
2+
from typing import Dict, Optional
23

34
from .typing import ActionFunction
45

@@ -9,3 +10,4 @@ class UnfoldAction:
910
method: ActionFunction
1011
description: str
1112
path: str
13+
attrs: Optional[Dict] = None

src/unfold/templates/admin/submit_line.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{% endif %}
1313

1414
{% for action in actions_submit_line %}
15-
<button type="submit" name="{{ action.action_name }}" class="border font-medium px-3 py-2 rounded-md text-sm text-gray-500 transition-all w-full hover:bg-gray-50 lg:w-auto dark:border-gray-700 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-900">
15+
<button type="submit" {% if not action.attrs.name %}name="{{ action.action_name }}"{% endif %} class="border font-medium px-3 py-2 rounded-md text-sm text-gray-500 transition-all w-full hover:bg-gray-50 lg:w-auto dark:border-gray-700 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-900" {% include "unfold/helpers/attrs.html" with attrs=action.attrs %}>
1616
{{ action.description }}
1717
</button>
1818
{% endfor %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% for name, value in attrs.items %}{% if value is not False %} {{ name }}{% if value is not True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}{% endfor %}

src/unfold/templates/unfold/layouts/base_simple.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
{% include "unfold/helpers/header.html" %}
1616
{% endblock %}
1717

18-
<div class="p-4 lg:p-12">
18+
{% if not is_popup %}
19+
{% spaceless %}
20+
{% block breadcrumbs %}{% endblock %}
21+
{% endspaceless %}
22+
{% endif %}
23+
24+
<div class="px-4 lg:px-12">
1925
<div id="content" class="container mx-auto {% block coltype %}colM{% endblock %}">
2026
{% block content %}
2127
{% block object-tools %}{% endblock %}

0 commit comments

Comments
 (0)