Skip to content

Commit

Permalink
Upgrade and create new admin elements #4380
Browse files Browse the repository at this point in the history
  • Loading branch information
joemull authored and MartinPaulEve committed Dec 3, 2024
1 parent 3e28b4d commit eff5f49
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 9 deletions.
29 changes: 29 additions & 0 deletions src/templates/admin/core/large_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends "admin/core/base.html" %}

{% block title %}
{% block contextual_title %}{% endblock contextual_title %}
- {% include "admin/elements/contextual_site_name.html" %}
{% endblock title %}

{% block title-section %}
{{ block.super }}
{% endblock title-section %}

{% block breadcrumbs %}
{{ block.super }}
{% endblock breadcrumbs %}

{% block body %}
<div class="grid place-content-center">
<div class="max-w-56">
<form method="POST">
{% csrf_token %}
{% include "admin/elements/forms/accessible_messages.html" %}
<div class="card padding-block-2 padding-inline-2">
{% block form_content %}
{% endblock form_content %}
</div>
</form>
</div>
</div>
{% endblock body %}
28 changes: 28 additions & 0 deletions src/templates/admin/core/small_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends "admin/core/base.html" %}

{% block title %}
{% block contextual_title %}{% endblock contextual_title %}
- {% include "admin/elements/contextual_site_name.html" %}
{% endblock title %}

{% block title-section %}
{{ block.super }}
{% endblock title-section %}

{% block breadcrumbs %}
{{ block.super }}
{% endblock breadcrumbs %}

{% block body %}
<div class="grid place-content-center">
<div class="max-w-24">
<form method="POST">
{% csrf_token %}
<div class="card padding-block-2 padding-inline-2">
{% block form_content %}
{% endblock form_content %}
</div>
</form>
</div>
</div>
{% endblock body %}
7 changes: 7 additions & 0 deletions src/templates/admin/elements/contextual_site_name.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% if request.journal %}
{{ journal.name }}
{% elif request.repository %}
{{ request.repository.name }}
{% else %}
{{ request.press.name }}
{% endif %}
19 changes: 19 additions & 0 deletions src/templates/admin/elements/forms/accessible_messages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% comment %}
Note that messages only display through this element if they are not acti
{% endcomment %}
{% for message in messages %}
<div class="card">
<div class="bs-callout bs-callout-{{ message.tags }}">
{{ message }}
</div>
</div>
{% endfor %}
{% if form.non_field_errors %}
<p>
<span class="fa fa-warning"></span>
{% trans 'Problems processing the form' %}
</p>
<ul>
{{ form.non_field_errors }}
</ul>
{% endif %}
1 change: 1 addition & 0 deletions src/templates/admin/elements/forms/denotes_required.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<small aria-hidden="true">* denotes required field</small>
30 changes: 21 additions & 9 deletions src/templates/admin/elements/forms/field.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}

<label for="{{ field.id_for_label }}">
<strong>{{ field.label }}</strong>
<div>
<label for="{{ field.id_for_label }}">
<strong>
{{ field.label }}
{% if field.field.required %}
<span aria-hidden="true">*</span>
{% endif %}
</strong>
{% if languages|length > 1 and field.name in edit_form.translatable_field_names %}
<small class="green">[{% trans 'translatable' %}]</small>
<small class="green">[{% trans 'translatable' %}]</small>
{% endif %}
</label>
{{ field }}
<p class="help-text">{{ field.help_text|safe }}</p>
{% for error in field.errors %}
<small{% if field.errors %} class="error"{% endif %}>{{ error|escape }}</small>
{% endfor %}
</label>
{% for error in field.errors %}
<div {% if field.errors %}class="error"{% endif %}>
<span class="fa fa-warning"></span>
{{ error|escape }}
</div>
{% endfor %}
{{ field }}
{% if field.help_text %}
<p class="help-text">{{ field.help_text|safe }}</p>
{% endif %}
</div>
1 change: 1 addition & 0 deletions src/templates/common/elements/orcid_registration.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<a
href="{{ settings.ORCID_URL }}?client_id={{ settings.ORCID_CLIENT_ID }}&response_type=code&scope=/authenticate&redirect_uri={% orcid_redirect_uri 'register' %}"
class="{{ button_classes|default:"orcid-button" }}">
<img alt="ORCID logo" src="{% static 'common/img/icons/orcid.gif' %}">
{% trans "Register with ORCiD" %}
</a>
{% endif %}
Expand Down

0 comments on commit eff5f49

Please sign in to comment.