Skip to content

Commit

Permalink
Reformat templates (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
aminalaee authored Dec 13, 2023
1 parent 751329c commit fadf4d6
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 160 deletions.
2 changes: 1 addition & 1 deletion sqladmin/statics/css/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.table thead th {
text-transform: none;
}
}
22 changes: 12 additions & 10 deletions sqladmin/templates/_macros.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{% macro menu_category(menu, request) %}
{% if menu.is_visible(request) and menu.is_accessible(request) %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle {% if menu.is_active(request) %}active{% endif %}" data-bs-toggle="dropdown" href="#">
<a class="nav-link dropdown-toggle {% if menu.is_active(request) %}active{% endif %}" data-bs-toggle="dropdown"
href="#">
<span class="nav-link-icon d-md-none d-lg-inline-block">
{% if menu.icon %}<i class="{{ menu.icon }}"></i>{% endif %}
</span>
Expand All @@ -11,7 +12,8 @@
<div class="dropdown-menu-columns">
<div class="dropdown-menu-column">
{% for sub_menu in menu.children %}
<a class="nav-link ps-lg-3 {% if sub_menu.is_active(request) %}active{% endif %}" href="{{ sub_menu.url(request) }}">
<a class="nav-link ps-lg-3 {% if sub_menu.is_active(request) %}active{% endif %}"
href="{{ sub_menu.url(request) }}">
<span class="nav-link-icon d-md-none d-lg-inline-block">
{% if sub_menu.icon %}<i class="{{ sub_menu.icon }}"></i>{% endif %}
</span>
Expand Down Expand Up @@ -40,12 +42,12 @@

{% macro display_menu(menu, request) %}
<div class="navbar-nav">
{% for item in menu.items %}
{% if item.type_ == "View" %}
{{ menu_item(item, request) }}
{% elif item.type_ == "Category" %}
{{ menu_category(item, request) }}
{% endif %}
{% endfor %}
{% for item in menu.items %}
{% if item.type_ == "View" %}
{{ menu_item(item, request) }}
{% elif item.type_ == "Category" %}
{{ menu_category(item, request) }}
{% endif %}
{% endfor %}
</div>
{% endmacro %}
{% endmacro %}
61 changes: 32 additions & 29 deletions sqladmin/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/tabler.min.css') }}">
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/fontawesome.min.css') }}">
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/select2.min.css') }}">
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/flatpickr.min.css') }}">
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/main.css') }}">
{% block head %}

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/tabler.min.css') }}">
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/fontawesome.min.css') }}">
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/select2.min.css') }}">
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/flatpickr.min.css') }}">
<link rel="stylesheet" href="{{ url_for('admin:statics', path='css/main.css') }}">
{% block head %}
{% endblock %}
<title>{{ admin.title }}</title>
</head>

<body>
{% block body %}
<main>
{% block main %}
{% endblock %}
<title>{{ admin.title }}</title>
</head>
<body>
{% block body %}
<main>
{% block main %}
{% endblock %}
</main>
{% endblock %}
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/jquery.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/tabler.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/popper.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/bootstrap.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/select2.full.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/flatpickr.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/main.js') }}"></script>
{% block tail %}
{% endblock %}
</body>
</html>
</main>
{% endblock %}
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/jquery.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/tabler.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/popper.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/bootstrap.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/select2.full.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/flatpickr.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('admin:statics', path='js/main.js') }}"></script>
{% block tail %}
{% endblock %}
</body>

</html>
2 changes: 1 addition & 1 deletion sqladmin/templates/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ <h3 class="card-title">New {{ model_view.name }}</h3>
</div>
</div>
</div>
{% endblock %}
{% endblock %}
28 changes: 17 additions & 11 deletions sqladmin/templates/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<div class="card-header">
<h3 class="card-title">
{% for pk in model_view.pk_columns -%}
{{ pk.name }}
{%- if not loop.last %};{% endif -%}
{{ pk.name }}
{%- if not loop.last %};{% endif -%}
{% endfor %}: {{ get_object_identifier(model) }}</h3>
</div>
<div class="card-body border-bottom py-3">
Expand All @@ -27,12 +27,13 @@ <h3 class="card-title">
{% if name in model_view._relation_names %}
{% if is_list( value ) %}
<td>
{% for elem, formatted_elem in zip(value, formatted_value) %}
<a href="{{ model_view._build_url_for('admin:details', request, elem) }}">({{ formatted_elem }})</a>
{% endfor %}
{% for elem, formatted_elem in zip(value, formatted_value) %}
<a href="{{ model_view._build_url_for('admin:details', request, elem) }}">({{ formatted_elem }})</a>
{% endfor %}
</td>
{% else %}
<td><a href="{{ model_view._url_for_details_with_prop(request, model, name) }}">{{ formatted_value }}</a></td>
<td><a href="{{ model_view._url_for_details_with_prop(request, model, name) }}">{{ formatted_value }}</a>
</td>
{% endif %}
{% else %}
<td>{{ formatted_value }}</td>
Expand All @@ -51,7 +52,9 @@ <h3 class="card-title">
</div>
{% if model_view.can_delete %}
<div class="col-md-1">
<a href="#" data-name="{{ model_view.name }}" data-pk="{{ get_object_identifier(model) }}" data-url="{{ model_view._url_for_delete(request, model) }}" data-bs-toggle="modal" data-bs-target="#modal-delete" class="btn btn-danger">
<a href="#" data-name="{{ model_view.name }}" data-pk="{{ get_object_identifier(model) }}"
data-url="{{ model_view._url_for_delete(request, model) }}" data-bs-toggle="modal"
data-bs-target="#modal-delete" class="btn btn-danger">
Delete
</a>
</div>
Expand All @@ -66,11 +69,13 @@ <h3 class="card-title">
{% for custom_action,label in model_view._custom_actions_in_detail.items() %}
<div class="col-md-1">
{% if custom_action in model_view._custom_actions_confirmation %}
<a href="#" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#modal-confirmation-{{ custom_action }}">
<a href="#" class="btn btn-secondary" data-bs-toggle="modal"
data-bs-target="#modal-confirmation-{{ custom_action }}">
{{ label }}
</a>
{% else %}
<a href="{{ model_view._url_for_action(request, custom_action) }}?pks={{ get_object_identifier(model) }}" class="btn btn-secondary">
<a href="{{ model_view._url_for_action(request, custom_action) }}?pks={{ get_object_identifier(model) }}"
class="btn btn-secondary">
{{ label }}
</a>
{% endif %}
Expand All @@ -87,10 +92,11 @@ <h3 class="card-title">

{% for custom_action in model_view._custom_actions_in_detail %}
{% if custom_action in model_view._custom_actions_confirmation %}
{% with confirmation_message = model_view._custom_actions_confirmation[custom_action], custom_action=custom_action, url=model_view._url_for_action(request, custom_action) + '?pks=' + (get_object_identifier(model) | string) %}
{% with confirmation_message = model_view._custom_actions_confirmation[custom_action], custom_action=custom_action,
url=model_view._url_for_action(request, custom_action) + '?pks=' + (get_object_identifier(model) | string) %}
{% include 'modals/details_action_confirmation.html' %}
{% endwith %}
{% endif %}
{% endfor %}

{% endblock %}
{% endblock %}
5 changes: 3 additions & 2 deletions sqladmin/templates/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<h3 class="card-title">Edit {{ model_view.name }}</h3>
</div>
<div class="card-body border-bottom py-3">
<form action="{{ model_view._build_url_for('admin:edit', request, obj) }}" method="POST" enctype="multipart/form-data">
<form action="{{ model_view._build_url_for('admin:edit', request, obj) }}" method="POST"
enctype="multipart/form-data">
<fieldset class="form-fieldset">
{% for field in form %}
<div class="mb-3 form-group row">
Expand Down Expand Up @@ -49,4 +50,4 @@ <h3 class="card-title">Edit {{ model_view.name }}</h3>
</div>
</div>
</div>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion sqladmin/templates/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
</div>
</div>
</div>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion sqladmin/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% extends "layout.html" %}
{% block content %}
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions sqladmin/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h3>{{ admin.title }}</h3>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
{{ display_menu(admin._menu, request) }}
{{ display_menu(admin._menu, request) }}
</div>
</nav>
{% if admin.authentication_backend %}
Expand Down Expand Up @@ -52,4 +52,4 @@ <h2 class="page-title">{{ title }}</h2>
</div>
</div>
</div>
{% endblock %}
{% endblock %}
Loading

0 comments on commit fadf4d6

Please sign in to comment.