mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
110 lines
5.2 KiB
HTML
110 lines
5.2 KiB
HTML
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
|
|
<head th:replace="~{fragments/resources::head}">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="bg-light main-wrapper">
|
|
<nav th:replace="~{fragments/resources :: navbar}"></nav>
|
|
<div class="d-flex">
|
|
<div th:replace="~{fragments/resources :: sidebar('entities')}"></div>
|
|
<div class="main-content bg-lighter">
|
|
<th:block th:replace="~{fragments/resources :: alerts}"></th:block>
|
|
|
|
<h1 class="fw-bold mb-4">
|
|
<i class="align-middle bi bi-database"></i>
|
|
<span class="align-middle"><a href="/dbadmin">Entities</a></span>
|
|
<i class="align-middle bi bi-chevron-double-right"></i>
|
|
<a class="align-middle" th:href="|/dbadmin/model/${schema.getJavaClass().getName()}|">
|
|
[[ ${schema.getJavaClass().getSimpleName()} ]] </a>
|
|
<i class="align-middle bi bi-chevron-double-right"></i>
|
|
<span class="align-middle" th:text="${create ? 'Create' : 'Edit'}"></span>
|
|
<th:block th:if="${!create}">
|
|
<i class="align-middle bi bi-chevron-double-right"></i>
|
|
<span class="align-middle" th:text="${object.getDisplayName()}"></span>
|
|
</th:block>
|
|
</h1>
|
|
<div class="row mt-4">
|
|
<div class="col">
|
|
<div class="box">
|
|
<h3 class="fw-bold mb-4" th:text="${create ? schema.getJavaClass().getSimpleName() : object.getDisplayName()}"></h3>
|
|
<form class="form" enctype="multipart/form-data" method="post" th:action="|/dbadmin/model/${className}/create|">
|
|
<input type="hidden" name="__dbadmin_create" th:value="${create}">
|
|
<div th:each="field : ${schema.getSortedFields()}" class="mt-2">
|
|
<label th:for="|__id_${field.getName()}|" class="mb-1 fw-bold">
|
|
[[ ${field.getName()} ]]
|
|
</label>
|
|
|
|
<th:block th:if="${field.isForeignKey()}">
|
|
<div th:replace="~{fragments/forms :: input_autocomplete(field=${field}, value=${
|
|
create ? (params != null ? params.getOrDefault(field.getName(), '') : '')
|
|
: (object != null ? object.traverse(field).getPrimaryKeyValue() : '' )
|
|
})}">
|
|
</div>
|
|
</th:block>
|
|
<th:block th:unless="${field.isForeignKey()}">
|
|
|
|
<input th:if="${!field.isBinary()}" placeholder="NULL" th:type="${field.getType().getHTMLName()}"
|
|
th:name="${field.getName()}"
|
|
th:value="
|
|
${create ? (params != null ? params.getOrDefault(field.getName(), '') : '')
|
|
: (object != null ? object.get(field).getValue() : '' )}
|
|
"
|
|
class="form-control" th:id="|__id_${field.getName()}|"
|
|
th:classAppend="${field.isPrimaryKey() && object != null ? 'disable' : ''}"
|
|
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
|
|
step="any"
|
|
oninvalid="this.setCustomValidity('This field is not nullable.')"
|
|
oninput="this.setCustomValidity('')">
|
|
|
|
<!--/*--> Binary field <!--*/-->
|
|
<th:block th:if="${field.isBinary()}">
|
|
<!--/*--> Edit options <!--*/-->
|
|
<div th:if="${!create && object.get(field).getValue() != null}">
|
|
<input type="checkbox"
|
|
class="binary-field-checkbox"
|
|
th:data-fieldname="${field.getName()}"
|
|
th:id="|__keep_${field.getName()}|"
|
|
checked
|
|
th:name="|__keep_${field.getName()}|">
|
|
<span>Keep current data</span>
|
|
<div th:if="${field.isImage()}" class="mb-2">
|
|
<img class="thumb-image" th:id="|__thumb_${field.getName()}|"
|
|
th:src="|/dbadmin/download/${schema.getClassName()}/${field.getJavaName()}/${object.getPrimaryKeyValue()}/image|">
|
|
</div>
|
|
</div>
|
|
<!--/*--> File input <!--*/-->
|
|
<input th:if="${field.isBinary()}" placeholder="NULL" th:type="${field.getType().getHTMLName()}"
|
|
th:name="${field.getName()}"
|
|
class="form-control mt-2" th:id="|__id_${field.getName()}|"
|
|
th:required="${!field.isNullable()}"
|
|
oninvalid="this.setCustomValidity('This field is not nullable.')"
|
|
oninput="this.setCustomValidity('')">
|
|
</th:block>
|
|
</th:block>
|
|
<div class="separator mt-3 mb-2 separator-light"></div>
|
|
</div>
|
|
|
|
<div th:each="field : ${schema.getManyToManyOwnedFields()}" class="mt-3">
|
|
<h2><span th:title="|${field.getType()} relationship|"><i class="bi bi-share"></i> [[ ${field.getJavaName()} ]]</span></h2>
|
|
<div th:replace="~{fragments/forms :: input_autocomplete_multi(field=${field},
|
|
values=${object != null ? object.traverseMany(field) : null } )}">
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="d-flex mt-4 justify-content-between">
|
|
<a th:href="|/dbadmin/model/${schema.getClassName()}|" class="ui-btn btn btn-secondary">Cancel</a>
|
|
<input type="submit" class="ui-btn btn btn-primary" th:value="${object != null ? 'Save' : 'Create'}">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</body>
|
|
</html> |