wip: full editing support and login of user achieved, updated minijinja to v2, htmx, hyperscript

This commit is contained in:
2024-07-18 00:45:21 +02:00
parent 402585f968
commit a26e17a064
15 changed files with 94 additions and 25 deletions

View File

@@ -139,6 +139,9 @@
{% endblock body %}
{% block bodyjs %}
<script src="/static/htmx/htmx.min.js"></script>
<script src="/static/hyperscript/hyperscript.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#main_sidemenu').sidebar({

View File

@@ -1,6 +1,9 @@
{% 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 %}

View File

@@ -1,5 +1,18 @@
<form action="{{form.action}}" method="{{form.method|default('POST')}}" class="ui form">
<!--noformat-->
<!--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 %}
@@ -11,6 +24,6 @@
{{ field_widget(field_name, field_defs, field_value) }}
</div>
{% endfor %}
<!--noformat-->
<button class="ui button" type="submit">Create</button>
</form>
</form>
<!--noformat-->

View File

@@ -0,0 +1,8 @@
<div class="ui toggle checkbox">
<!--noformat-->
<input type="checkbox"
name="{{ field.name }}"
{% if field.value %}checked="checked" {% endif %}>
<label>{{field.label or field.name|capitalize}}</label>
<!--noformat-->
</div>

View File

@@ -0,0 +1,8 @@
<div class="ui action input inline field">
<label>{{field.label or field.name|capitalize}}</label>
<input type="text" value="{{field.value}}" readonly="readonly">
<button class="ui teal right labeled icon button" hx-disable>
<i class="key icon"></i>
Set Password...
</button>
</div>