Removed FragmentContext and instead created multiple versions of input fields fragments for different contexts (search, create)

This commit is contained in:
Francesco
2023-10-08 10:55:21 +02:00
parent bf7a4c8956
commit 3bf6b1f58d
6 changed files with 138 additions and 79 deletions

View File

@@ -90,7 +90,7 @@
<option th:value="${op}" th:each="op : ${field.getType().getCompareOperators()}"
th:text="${op.getDisplayName()}">
</select>
<input th:replace="~{fragments/inputs ::
<input th:replace="~{fragments/search_inputs ::
__${field.getFragmentName()}__(
field=${field},
create=${create},

View File

@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
<input placeholder="NULL" th:fragment="textarea(field, create, name, value)"
type="text"
th:value="${value}"
th:name="${name}"
class="form-control " th:id="|__id_${field.getName()}|"
th:classAppend="|${(field.isPrimaryKey() && object != null) ||
(field.isReadOnly() && !create) ? 'disable' : ''}|"
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
></input>
<input placeholder="NULL" th:fragment="char(field, create, name, value)"
type="text"
th:value="${value}"
th:name="${name}"
class="form-control " th:id="|__id_${field.getName()}|"
th:classAppend="|${(field.isPrimaryKey() && object != null) ||
(field.isReadOnly() && !create) ? 'disable' : ''}|"
maxlength="1"
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
></input>
<input placeholder="NULL" th:fragment="text(field, create, name, value)"
type="text"
th:value="${value}"
th:name="${name}"
class="form-control " th:id="|__id_${field.getName()}|"
th:classAppend="|${(field.isPrimaryKey() && object != null) ||
(field.isReadOnly() && !create) ? 'disable' : ''}|"
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
></input>
<input placeholder="NULL" th:fragment="number(field, create, name, value)"
type="number"
th:value="${value}"
th:name="${name}"
class="form-control " th:id="|__id_${field.getName()}|"
th:classAppend="|${(field.isPrimaryKey() && object != null) ||
(field.isReadOnly() && !create) ? 'disable' : ''}|"
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
step="any"
></input>
<input placeholder="NULL" th:fragment="datetime(field, create, name, value)"
type="datetime-local"
th:value="${value}"
th:name="${name}"
class="form-control " th:id="|__id_${field.getName()}|"
th:classAppend="|${create != null && ((field.isPrimaryKey() && object != null) ||
(field.isReadOnly() && !create)) ? 'disable' : ''}|"
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
></input>
<input placeholder="NULL" th:fragment="date(field, create, name, value)"
type="date"
th:value="${value}"
th:name="${name}"
class="form-control " th:id="|__id_${field.getName()}|"
th:classAppend="|${create != null && ((field.isPrimaryKey() && object != null) ||
(field.isReadOnly() && !create)) ? 'disable' : ''}|"
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
></input>
</html>