Some layout tweaks.
This commit is contained in:
parent
3c07741500
commit
9181ba660f
5 changed files with 80 additions and 65 deletions
|
|
@ -15,11 +15,19 @@ def _fields_for_model(model: str):
|
|||
layout = []
|
||||
|
||||
if model == "inventory":
|
||||
fields = []
|
||||
fields = [
|
||||
"label",
|
||||
"name",
|
||||
"serial",
|
||||
"barcode",
|
||||
"model",
|
||||
"condition",
|
||||
"notes",
|
||||
]
|
||||
fields_spec = [
|
||||
{"name": "label", "type": "display", "label": "", "row": "label",
|
||||
"attrs": {"class": "display-6 mb-3"}, "wrap": {"class": "col"}},
|
||||
{"name": "submit", "label": "", "row": "label", "type": "template", "template": "submit_button.html",
|
||||
{"name": "submit", "label": "", "row": "label", "type": "template", "template": "entry_buttons.html",
|
||||
"wrap": {"class": "col-auto text-end me-2"}, "attrs": {"data-model": model}},
|
||||
{"name": "name", "row": "names", "label": "Name", "wrap": {"class": "col-3"},
|
||||
"attrs": {"class": "form-control"}, "label_attrs": {"class": "form-label"}},
|
||||
|
|
@ -70,11 +78,18 @@ def _fields_for_model(model: str):
|
|||
]
|
||||
|
||||
elif model.lower() == 'user':
|
||||
fields = []
|
||||
fields = [
|
||||
"label",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"title",
|
||||
"active",
|
||||
"staff"
|
||||
]
|
||||
fields_spec = [
|
||||
{"name": "label", "row": "label", "label": "", "type": "display",
|
||||
"attrs": {"class": "display-6 mb-3"}, "wrap": {"class": "col"}},
|
||||
{"name": "submit", "label": "", "row": "label", "type": "template", "template": "submit_button.html",
|
||||
{"name": "submit", "label": "", "row": "label", "type": "template", "template": "entry_buttons.html",
|
||||
"wrap": {"class": "col-auto text-end me-2"}, "attrs": {"data-model": model}},
|
||||
{"name": "last_name", "label": "Last Name", "label_attrs": {"class": "form-label"},
|
||||
"attrs": {"placeholder": "Doe", "class": "form-control"}, "row": "name", "wrap": {"class": "col-3"}},
|
||||
|
|
@ -119,7 +134,7 @@ def _fields_for_model(model: str):
|
|||
fields_spec = [
|
||||
{"name": "id", "label": "", "type": "display", "label_spec": "Work Item #{id}",
|
||||
"attrs": {"class": "display-6 mb-3"}, "row": "label", "wrap": {"class": "col"}},
|
||||
{"name": "submit", "label": "", "row": "label", "type": "template", "template": "submit_button.html",
|
||||
{"name": "submit", "label": "", "row": "label", "type": "template", "template": "entry_buttons.html",
|
||||
"wrap": {"class": "col-auto text-end me-2"}, "attrs": {"data-model": model}},
|
||||
{"name": "contact", "row": "ownership", "wrap": {"class": "col"}, "label": "Contact",
|
||||
"label_spec": "{label}", "attrs": {"class": "form-control"}, "label_attrs": {"class": "form-label"}},
|
||||
|
|
@ -139,6 +154,7 @@ def _fields_for_model(model: str):
|
|||
{"name": "ownership", "order": 10, "attrs": {"class": "row mb-2"}},
|
||||
{"name": "timestamps", "order": 20, "attrs": {"class": "row d-flex align-items-center"}},
|
||||
{"name": "updates", "order": 30, "attrs": {"class": "row"}},
|
||||
{"name": "buttons"},
|
||||
]
|
||||
|
||||
return (fields, fields_spec, layout)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<div class="table-responsive mx-5" style="max-height: 80vh;">
|
||||
<div class="table-responsive" style="max-height: 80vh;">
|
||||
<table class="table table-info table-striped table-hover table-bordered border-tertiary text-nowrap overflow-x-auto mx-auto">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
<div class="btn-group">
|
||||
<button type="submit" class="btn btn-primary" id="submit">Save</button>
|
||||
<button type="button" class="btn btn-outline-primary" onclick="location.href='{{ url_for("entry.entry_new", model=(field['attrs']['data-model'])) }}'">New</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.newDrafts = window.newDrafts || [];
|
||||
window.deletedIds = window.deletedIds || [];
|
||||
|
|
@ -5,23 +5,21 @@ Inventory Manager - {{ model|title }} Listing
|
|||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="container-fluid">
|
||||
<h1 class="display-4 text-center mt-5">{{ model|title }} Listing</h1>
|
||||
<div class="mx-5">
|
||||
<h1 class="display-4 text-center mt-2">{{ model|title }} Listing</h1>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary mb-3"
|
||||
onclick="location.href='{{ url_for('entry.entry_new', model=model) }}'">New</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ table | safe }}
|
||||
|
||||
<nav class="d-flex justify-content-center my-4" aria-label="Pagination">
|
||||
<nav class="d-flex justify-content-center my-2" aria-label="Pagination">
|
||||
<ul class="pagination mb-0">
|
||||
|
||||
{# Prev #}
|
||||
<li class="page-item {% if not pagination.has_prev %}disabled{% endif %}">
|
||||
<a class="page-link"
|
||||
href="{{ pagination.prev_url if pagination.has_prev else '#' }}"
|
||||
<a class="page-link" href="{{ pagination.prev_url if pagination.has_prev else '#' }}"
|
||||
aria-label="Previous">Previous</a>
|
||||
</li>
|
||||
|
||||
|
|
@ -29,9 +27,7 @@ Inventory Manager - {{ model|title }} Listing
|
|||
{% for item in pagination.nav %}
|
||||
{% if item.type == 'page' %}
|
||||
<li class="page-item {% if item.active %}active{% endif %}">
|
||||
<a class="page-link"
|
||||
href="{{ item.url }}"
|
||||
{% if item.active %}aria-current="page"{% endif %}>{{ item.n }}</a>
|
||||
<a class="page-link" href="{{ item.url }}" {% if item.active %}aria-current="page" {% endif %}>{{ item.n }}</a>
|
||||
</li>
|
||||
{% elif item.type == 'ellipsis' %}
|
||||
<li class="page-item disabled">
|
||||
|
|
@ -42,15 +38,14 @@ Inventory Manager - {{ model|title }} Listing
|
|||
|
||||
{# Next #}
|
||||
<li class="page-item {% if not pagination.has_next %}disabled{% endif %}">
|
||||
<a class="page-link"
|
||||
href="{{ pagination.next_url if pagination.has_next else '#' }}"
|
||||
aria-label="Next">Next</a>
|
||||
<a class="page-link" href="{{ pagination.next_url if pagination.has_next else '#' }}" aria-label="Next">Next</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<p class="text-center text-muted small mb-5">
|
||||
<p class="text-center text-muted small mb-2">
|
||||
Page {{ pagination.page }} of {{ pagination.pages }} · {{ pagination.total }} records
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
|
@ -1,5 +1,19 @@
|
|||
{% set items = (field.template_ctx.instance.updates or []) %}
|
||||
|
||||
<div class="mt-3">
|
||||
<label class="form-label">Add update</label>
|
||||
<textarea id="newUpdateInput" class="form-control auto-md" rows="3" placeholder="Write a new update..."></textarea>
|
||||
<div class="mt-2 d-flex gap-2">
|
||||
<button type="button" class="btn btn-primary btn-sm" onclick="addNewDraft()">Add</button>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" onclick="clearNewDraft()">Clear</button>
|
||||
</div>
|
||||
|
||||
<div id="newDraftsList" class="mt-3 d-none">
|
||||
<div class="fw-semibold mb-1">Pending new updates</div>
|
||||
<ul class="list-group" id="newDraftsUl"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="list-group mt-3">
|
||||
{% for n in items %}
|
||||
<li class="list-group-item">
|
||||
|
|
@ -30,20 +44,6 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<div class="mt-3">
|
||||
<label class="form-label">Add update</label>
|
||||
<textarea id="newUpdateInput" class="form-control auto-md" rows="3" placeholder="Write a new update..."></textarea>
|
||||
<div class="mt-2 d-flex gap-2">
|
||||
<button type="button" class="btn btn-primary btn-sm" onclick="addNewDraft()">Add</button>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" onclick="clearNewDraft()">Clear</button>
|
||||
</div>
|
||||
|
||||
<div id="newDraftsList" class="mt-3 d-none">
|
||||
<div class="fw-semibold mb-1">Pending new updates</div>
|
||||
<ul class="list-group" id="newDraftsUl"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5/github-markdown.min.css">
|
||||
<style>
|
||||
textarea.auto-md {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue