-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for inline forms for action buttons
- Loading branch information
Wiktor Latanowicz
committed
Nov 18, 2022
1 parent
a616d37
commit a7ad92a
Showing
9 changed files
with
212 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
django_object_actions/static/django_object_actions/css/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ul.object-tools.django-object-actions { | ||
margin-top: 0; | ||
padding-top: 16px; | ||
position: relative; | ||
top: -24px; | ||
} |
61 changes: 48 additions & 13 deletions
61
django_object_actions/templates/django_object_actions/change_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,56 @@ | ||
{% extends "admin/change_form.html" %} | ||
{% load add_preserved_filters from admin_urls %} | ||
{% load static %} | ||
|
||
{% block extrastyle %} | ||
{{ block.super }} | ||
<link rel="stylesheet" href="{% static 'django_object_actions/css/style.css' %}"> | ||
{% endblock %} | ||
|
||
{% block object-tools-items %} | ||
{% for tool in objectactions %} | ||
<li class="objectaction-item" data-tool-name="{{ tool.name }}"> | ||
{% url tools_view_name pk=object_id tool=tool.name as action_url %} | ||
<form name="{{ tool.name }}__form" method="post" action="{% add_preserved_filters action_url %}"> | ||
{% csrf_token %} | ||
<a href="javascript:window.document.forms['{{ tool.name }}__form'].submit()" title="{{ tool.standard_attrs.title }}" | ||
{% for k, v in tool.custom_attrs.items %} | ||
{{ k }}="{{ v }}" | ||
{% endfor %} | ||
class="{{ tool.standard_attrs.class }}"> | ||
{{ tool.label|capfirst }} | ||
</a> | ||
</form> | ||
</li> | ||
{% if not tool.form %} | ||
<li class="objectaction-item" data-tool-name="{{ tool.name }}"> | ||
{% url tools_view_name pk=object_id tool=tool.name as action_url %} | ||
<form name="{{ tool.name }}__form" method="post" action="{% add_preserved_filters action_url %}"> | ||
{% csrf_token %} | ||
<a href="javascript:window.document.forms['{{ tool.name }}__form'].submit()" title="{{ tool.standard_attrs.title }}" | ||
{% for k, v in tool.custom_attrs.items %} | ||
{{ k }}="{{ v }}" | ||
{% endfor %} | ||
class="{{ tool.standard_attrs.class }}"> | ||
{{ tool.label|capfirst }} | ||
</a> | ||
</form> | ||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block object-tools %} | ||
{{ block.super }} | ||
{% for tool in objectactions %} | ||
{% if tool.form %} | ||
{% url tools_view_name pk=object_id tool=tool.name as action_url %} | ||
<div class="clear"> | ||
<form name="{{ tool.name }}__form" method="post" action="{% add_preserved_filters action_url %}"> | ||
{% csrf_token %} | ||
<ul class="object-tools django-object-actions"> | ||
{{ tool.form.as_ul }} | ||
<li class="objectaction-item" data-tool-name="{{ tool.name }}"> | ||
<a href="javascript:window.document.forms['{{ tool.name }}__form'].submit()" title="{{ tool.standard_attrs.title }}" | ||
{% for k, v in tool.custom_attrs.items %} | ||
{{ k }}="{{ v }}" | ||
{% endfor %} | ||
class="{{ tool.standard_attrs.class }}"> | ||
{{ tool.label|capfirst }} | ||
</a> | ||
</li> | ||
</ul> | ||
</form> | ||
</div> | ||
{% endif %} | ||
{% endfor %} | ||
<div class="clear"></div> | ||
{% endblock %} |
61 changes: 48 additions & 13 deletions
61
django_object_actions/templates/django_object_actions/change_list.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,56 @@ | ||
{% extends "admin/change_list.html" %} | ||
{% load add_preserved_filters from admin_urls %} | ||
{% load static %} | ||
|
||
{% block extrastyle %} | ||
{{ block.super }} | ||
<link rel="stylesheet" href="{% static 'django_object_actions/css/style.css' %}"> | ||
{% endblock %} | ||
|
||
{% block object-tools-items %} | ||
{% for tool in objectactions %} | ||
<li class="objectaction-item" data-tool-name="{{ tool.name }}"> | ||
{% url tools_view_name tool=tool.name as action_url %} | ||
<form name="{{ tool.name }}__form" method="post" action="{% add_preserved_filters action_url %}"> | ||
{% csrf_token %} | ||
<a href="javascript:window.document.forms['{{ tool.name }}__form'].submit()" title="{{ tool.standard_attrs.title }}" | ||
{% for k, v in tool.custom_attrs.items %} | ||
{{ k }}="{{ v }}" | ||
{% endfor %} | ||
class="{{ tool.standard_attrs.class }}"> | ||
{{ tool.label|capfirst }} | ||
</a> | ||
</form> | ||
</li> | ||
{% if not tool.form %} | ||
<li class="objectaction-item" data-tool-name="{{ tool.name }}"> | ||
{% url tools_view_name tool=tool.name as action_url %} | ||
<form name="{{ tool.name }}__form" method="post" action="{% add_preserved_filters action_url %}"> | ||
{% csrf_token %} | ||
<a href="javascript:window.document.forms['{{ tool.name }}__form'].submit()" title="{{ tool.standard_attrs.title }}" | ||
{% for k, v in tool.custom_attrs.items %} | ||
{{ k }}="{{ v }}" | ||
{% endfor %} | ||
class="{{ tool.standard_attrs.class }}"> | ||
{{ tool.label|capfirst }} | ||
</a> | ||
</form> | ||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block object-tools %} | ||
{{ block.super }} | ||
{% for tool in objectactions %} | ||
{% if tool.form %} | ||
{% url tools_view_name tool=tool.name as action_url %} | ||
<div class="clear"> | ||
<form name="{{ tool.name }}__form" method="post" action="{% add_preserved_filters action_url %}"> | ||
{% csrf_token %} | ||
<ul class="object-tools django-object-actions"> | ||
{{ tool.form.as_ul }} | ||
<li class="objectaction-item" data-tool-name="{{ tool.name }}"> | ||
<a href="javascript:window.document.forms['{{ tool.name }}__form'].submit()" title="{{ tool.standard_attrs.title }}" | ||
{% for k, v in tool.custom_attrs.items %} | ||
{{ k }}="{{ v }}" | ||
{% endfor %} | ||
class="{{ tool.standard_attrs.class }}"> | ||
{{ tool.label|capfirst }} | ||
</a> | ||
</li> | ||
</ul> | ||
</form> | ||
</div> | ||
{% endif %} | ||
{% endfor %} | ||
<div class="clear"></div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters