refactor: using word depot in rear instead of admin

This commit is contained in:
2024-07-20 09:34:51 +02:00
parent a26e17a064
commit 966291dbd9
38 changed files with 1112 additions and 72 deletions

View File

@@ -0,0 +1,13 @@
{% extends base|none("admin/base.jinja") %}
{% block content %}
<div id="message-box-area" class="ui message" _="init wait 3s then transition opacity to 0 then remove me">
Hi there.
</div>
<div class="ui container">
<h1>Update {{item_model.name}} in {{item_info.name}}</h1>
{% set fields = item_info.fields %}
{% set form = { 'action': item.change_url, 'method': 'PATCH' } %}
{% include "/admin/items/item_change_form.jinja" %}
</div>
{% endblock content %}

View File

@@ -0,0 +1,29 @@
<!--noformat-->
<form class="ui form"
hx-target="main"
{% if form.method|upper == 'POST' or not form.method %}
hx-post="{{form.action}}"
{% elif form.method|upper == 'GET' %}
hx-get="{{form.action}}"
{% elif form.method|upper == 'PATCH' %}
hx-patch="{{form.action}}"
{% elif form.method|upper == 'PUT' %}
hx-put="{{form.action}}"
{% else %}
unknown-form-method={{form.method}}
{% endif %}>
{% from "/admin/items/items.jinja" import field_widget %}
{% for field_name, field_defs in fields %}
{% if item %}
{% set field_value = item.fields[field_name]|none("") %}
{% else %}
{% set field_value = "" %}
{% endif %}
<div class="field">
{{ field_widget(field_name, field_defs, field_value) }}
</div>
{% endfor %}
<button class="ui button" type="submit">Create</button>
</form>
<!--noformat-->

View File

@@ -0,0 +1,17 @@
{% extends base|none("admin/base.jinja") %}
{% block content %}
<div class="ui container">
<h1>Create {{item_model.name}} in {{item_info.name}}</h1>
{% block navigation_bar %}
<div class="ui container">
<button hx-get="{{ item_model.admin_url }}" hx-target="#main" hx-push-url="true">List Items</button>
</div>
{% endblock %}
{% set fields = item_info.fields %}
{% set form = { 'action': item_model.add_url } %}
{% include "/admin/items/item_change_form.jinja" %}
</div>
{% endblock content %}

View File

@@ -0,0 +1,11 @@
{% extends base|none("admin/base.jinja") %}
{% block content %}
{% if item %}
{{item.fields}}
{% else %}
No Item found.
{% endif %}
{% endblock content %}

View File

@@ -0,0 +1,86 @@
{% extends base|none("admin/base.jinja") %}
{% block content %}
<div class="ui container">
<h1>List of {{ item_info.name }}</h1>
{% block navigation_bar %}
<div class="ui container">
<button hx-get="{{ item_model.add_url }}" hx-target="#main" hx-push-url="true">Create New</button>
</div>
{% endblock %}
{% block search_bar %}
<div class="ui icon input">
<input type="text" placeholder="Search...">
<i class="circular search link icon"></i>
</div>
{% endblock %}
{% if item_list %}
{% set item_keys = item_info.display_list or item_list|table_keys %}
{% if item_info.lookup_key in item_keys %}
{% set primary_key = item_info.lookup_key %}
{% endif %}
<div class="ui basic container">
<table class="ui very compact celled table head stuck unstackable">
<caption>{{ item_info.name }}</caption>
<thead>
<tr>
<th class="collapsing grey"></th>
{% for key in item_keys %}
{% if key==primary_key %}
<th class="blue"><i class="key icon"></i>
{{ key|capitalize }}
</th>
{% else %}
<th>{{ key|capitalize }}</th>
{% endif %}
{% endfor %}
</tr>
</thead>
<tbody>
{% for item in item_list %}
<tr>
<td class="collapsing">
<div class="ui buttons">
<button class="ui compact icon button left attached" {% if item.detail_url %} hx-get="{{item.detail_url}}"
hx-target="#main" hx-push-url="true" {% endif %}>
<i class="eye icon"></i>
</button>
<button class="ui compact icon button right attached" {% if item.change_url %}
hx-get="{{item.change_url}}" hx-target="#main" hx-push-url="true" {% endif %}>
<i class="edit icon"></i>
</button>
</div>
</td>
{% for key in item_keys %}
{% if key==primary_key %}
<td class="selectable warning">{% if item.change_url %}<a href="{{item.change_url}}"
hx-get="{{item.change_url}}" hx-target="#main" hx-push-url="true">{{
item.fields[key] }}</a>{%
else %}{{item.fields[key] }}{% endif %}</td>
{% else %}
<td>{{ item.fields[key] }}</td>{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
{% else %}
No Items found.
{% endif %}
{% endblock content %}

View File

@@ -0,0 +1,15 @@
<!--noformat-->
{% macro field_widget(name, definitions, value) -%}
{% set field = {
'type': definitions.type,
'name': name,
'value': value,
'placeholder': definitions.placeholder,
'label': definitions.label,
'readonly': definitions.readonly,
'required': definitions.required,
'options': definitions.options,
}
%}
{% include definitions.widget %}
{%- endmacro %}