Skip to content

Commit

Permalink
fix: inlines adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav committed Oct 17, 2022
1 parent a7db1e3 commit e9c2c15
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/unfold/static/unfold/css/styles.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/unfold/templates/admin/edit_inline/stacked.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h2 class="bg-gray-100 font-semibold mb-6 px-4 py-3 rounded-md text-gray-900 tex
<div class="border mb-6 overflow-hidden rounded-md shadow-sm text-gray-700 w-full">
{% for inline_admin_form in inline_admin_formset %}
<div class="inline-related{% if inline_admin_form.original or inline_admin_form.show_url %} has_original{% endif %}{% if forloop.last and inline_admin_formset.has_add_permission %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
<h3 class="border-b flex font-medium items-center mb-3 px-3 py-2 text-gray-400 text-sm">
<h3 class="border-b {% if not forloop.first %}border-t{% endif %} flex font-medium items-center mb-3 px-3 py-2 text-gray-400 text-sm">
<span class="mr-2">
{{ inline_admin_formset.opts.verbose_name|capfirst }}:
</span>
Expand Down
80 changes: 42 additions & 38 deletions src/unfold/templates/admin/edit_inline/tabular.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2 class="bg-gray-100 font-semibold mb-6 px-4 py-3 rounded-md text-gray-900 tex

<div>
{% if not inline_admin_formset.has_add_permission and inline_admin_formset.forms|length_is:0 %}
<p class="mb-8 text-gray-500 text-sm">
<p class="mb-6 text-gray-500 text-sm">
{% trans "No records found." %}
</p>
{% else %}
Expand Down Expand Up @@ -56,12 +56,12 @@ <h2 class="bg-gray-100 font-semibold mb-6 px-4 py-3 rounded-md text-gray-900 tex

{% if inline_admin_form.original or inline_admin_form.show_url %}
<tr>
<td class="original align-middle border-t font-normal px-3 pt-3 text-left text-sm whitespace-nowrap" colspan="10">
<td class="original" colspan="10">
{% if inline_admin_form.original or inline_admin_form.show_url %}
<p class="flex items-center leading-none text-gray-500">
<p class="align-middle flex font-normal items-center leading-none px-3 text-gray-500 text-left text-sm whitespace-nowrap">
{% if inline_admin_form.original %}
{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %}
<a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="{% if inline_admin_formset.has_change_permission %}inlinechangelink{% else %}inlineviewlink{% endif %} text-gray-500 text-xs">
<a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="{% if inline_admin_formset.has_change_permission %}inlinechangelink{% else %}inlineviewlink{% endif %} mt-3 text-gray-500 text-xs">
{{ inline_admin_form.original }}
</a>
{% endif %}
Expand All @@ -70,7 +70,7 @@ <h2 class="bg-gray-100 font-semibold mb-6 px-4 py-3 rounded-md text-gray-900 tex
{% endif %}

{% if inline_admin_form.show_url %}
<a href="{{ inline_admin_form.absolute_url }}" class="ml-1">
<a href="{{ inline_admin_form.absolute_url }}" class="ml-1 mt-3">
<i class="material-icons h-4 md-16 text-gray-400">launch</i>
</a>
{% endif %}
Expand All @@ -88,7 +88,7 @@ <h2 class="bg-gray-100 font-semibold mb-6 px-4 py-3 rounded-md text-gray-900 tex
</tr>
{% endif %}

<tr class="form-row {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}{% if forloop.last and inline_admin_formset.has_add_permission %} empty-form{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
<tr class="lg:border-b-0 form-row {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}{% if forloop.last and inline_admin_formset.has_add_permission %} empty-form{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
{% spaceless %}
{% for fieldset in inline_admin_form %}
{% for line in fieldset %}
Expand All @@ -101,43 +101,47 @@ <h2 class="bg-gray-100 font-semibold mb-6 px-4 py-3 rounded-md text-gray-900 tex
{% endfor %}
{% endspaceless %}

{% for fieldset in inline_admin_form %}
{% for line in fieldset %}
{% for field in line %}
{% if field.is_readonly or not field.field.is_hidden %}
<td{% if field.field.name %} class="field-{{ field.field.name }}{% if field.field.errors|length > 0 %} errors{% endif %}{% if inline_admin_form.original %} p-3 lg:py-3{% else %} py-3{% endif %}{% if field.is_checkbox %} align-middle{% else %} align-top{% endif %} border-b flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:w-72 lg:before:hidden font-normal px-3 text-left text-sm lg:table-cell"{% endif %} data-label="{{ field.field.label }}">
{% if field.is_readonly %}
<p class="text-gray-500 py-2">
{{ field.contents }}
</p>
{% else %}
{{ field.field }}
{% with is_last_row=forloop.last %}
{% for fieldset in inline_admin_form %}
{% for line in fieldset %}
{% with is_last_col=forloop.last %}
{% for field in line %}
{% if field.is_readonly or not field.field.is_hidden %}
<td{% if field.field.name %} class="field-{{ field.field.name }}{% if field.field.errors|length > 0 %} errors{% endif %}{% if inline_admin_form.original %} p-3 lg:py-3{% else %} py-3{% endif %}{% if field.is_checkbox %} align-middle{% else %} align-top{% endif %} {% if is_last_row and not inline_admin_formset.has_add_permission %}{% if is_last_col %}border-0 {% else %}border-b lg:border-0{% endif %}{% else %}border-b{% endif %} flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:w-72 lg:before:hidden font-normal px-3 text-left text-sm lg:table-cell"{% endif %} data-label="{{ field.field.label }}">
{% if field.is_readonly %}
<p class="bg-gray-50 border font-medium px-3 py-2 rounded-md shadow-sm text-gray-500 text-sm">
{{ field.contents }}
</p>
{% else %}
{{ field.field }}

{% if field.field.errors|length > 0 %}
<div class="mt-1 ext-sm text-red-600">
{% for error in field.field.errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
{% if field.field.errors|length > 0 %}
<div class="mt-1 ext-sm text-red-600">
{% for error in field.field.errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
{% endif %}
</td>
{% endif %}
</td>
{% endif %}
{% endfor %}
{% endwith %}
{% endfor %}
{% endfor %}
{% endfor %}

{% if inline_admin_formset.formset.can_delete and inline_admin_formset.has_delete_permission %}
<td class="
delete {% if inline_admin_form.original %}p-3 lg:py-3{% else %}py-3{% endif %} align-middle text-left font-normal px-3 text-sm text-red-600
border-b flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:w-72 lg:before:hidden font-normal px-3 text-sm lg:table-cell lg:underline lg:w-px
"
data-label="{% trans "Remove" %}">
{% if inline_admin_form.original %}
{{ inline_admin_form.deletion_field.field }}
{% endif %}
</td>
{% endif %}
{% if inline_admin_formset.formset.can_delete and inline_admin_formset.has_delete_permission %}
<td class="
delete {% if inline_admin_form.original %}p-3 lg:py-3{% else %}py-3{% endif %} align-middle text-left font-normal px-3 text-sm text-red-600
border-b flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:w-72 lg:before:hidden font-normal px-3 text-sm lg:table-cell lg:underline lg:w-px
"
data-label="{% trans "Remove" %}">
{% if inline_admin_form.original %}
{{ inline_admin_form.deletion_field.field }}
{% endif %}
</td>
{% endif %}
{% endwith %}
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% if not is_hidden %}
{% if can_add_related or can_change_related or can_delete_related or can_view_related%}
{% if can_change_related %}
<a class="related-widget-wrapper-link change-related cursor-pointer ml-4 text-gray-500 text-sm hover:text-primary-600"
<a class="related-widget-wrapper-link change-related cursor-pointer lg:ml-4 text-gray-500 text-sm hover:text-primary-600"
id="change_id_{{ name }}"
data-popup="yes"
data-href-template="{{ change_related_template_url }}?{{ url_params }}"
Expand Down
18 changes: 11 additions & 7 deletions src/unfold/templates/admin/widgets/split_datetime.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<div class="datetime flex flex-col md:flex-row">
<div class="flex flex-wrap items-center max-w-sm lg:max-w-96">
<div class="mr-2 text-gray-500 text-sm">
<div class="datetime flex flex-col max-w-2xl lg:flex-row">
<div class="flex flex-col flex-wrap">
<div class="mb-1 text-gray-500 text-sm">
{{ date_label }}
</div>

{% with widget=widget.subwidgets.0 %}
{% include widget.template_name %}
<div class="flex flex-row">
{% include widget.template_name %}
</div>
{% endwith %}
</div>

<div class="flex flex-wrap items-center max-w-sm mt-3 md:mt-0 lg:ml-14">
<div class="mr-2 text-gray-500 text-sm">
<div class="flex flex-col flex-wrap lg:ml-auto mt-3 md:mt-0">
<div class="mb-1 text-gray-500 text-sm">
{{ time_label }}
</div>

{% with widget=widget.subwidgets.1 %}
{% include widget.template_name %}
<div class="flex flex-row">
{% include widget.template_name %}
</div>
{% endwith %}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="readonly bg-gray-50 border font-medium max-w-2xl px-3 py-2 rounded-md shadow-sm text-gray-500 text-sm" {% include 'django/forms/widgets/attrs.html' %}>
<div class="readonly bg-gray-50 border font-medium max-w-2xl px-3 py-2 rounded-md shadow-sm text-gray-500 text-sm{% if summary|length > 1 %} text-ellipsis overflow-hidden whitespace-nowrap{% endif %}" {% include 'django/forms/widgets/attrs.html' %}>
{% if summary|length > 1 %}
{% for entry in summary %}
<strong class="font-semibold text-gray-900">{{ entry.label }}</strong>{% if entry.value %}: {{ entry.value }}{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ select:not([class*="bg-none"]):not([multiple]) {
}

select:after {
content: 'asdasd';
content: '';
display: block;
}

Expand Down

0 comments on commit e9c2c15

Please sign in to comment.