This commit is contained in:
Francesco 2023-09-19 23:02:37 +02:00
parent 86fecf45b7
commit 3bd17e6e84
5 changed files with 21 additions and 15 deletions

View File

@ -61,7 +61,8 @@ import tech.ailef.dbadmin.misc.Utils;
* - SQL console (PRO) * - SQL console (PRO)
* - JPA Validation (PRO) * - JPA Validation (PRO)
* - Logging * - Logging
* - ERROR 500: http://localhost:8080/dbadmin/model/tech.ailef.dbadmin.test.models.Order?query=2021 * - TODO FIX: list model page crash
* EDIT error on table product
* - Logs in web ui * - Logs in web ui
* - Tests: AutocompleteController, REST API, create/edit * - Tests: AutocompleteController, REST API, create/edit
*/ */

View File

@ -199,8 +199,13 @@ public class DbObject {
String capitalize = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String capitalize = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
Method[] methods = instance.getClass().getDeclaredMethods(); Method[] methods = instance.getClass().getDeclaredMethods();
String prefix = "get";
if (schema.getFieldByJavaName(fieldName).getType() == DbFieldType.BOOLEAN) {
prefix = "is";
}
for (Method m : methods) { for (Method m : methods) {
if (m.getName().equals("get" + capitalize)) if (m.getName().equals(prefix + capitalize))
return m; return m;
} }

View File

@ -220,16 +220,16 @@ public class DbObjectSchema {
value = files.get(name); value = files.get(name);
} }
String type = params.get("__dbadmin_" + name + "_type"); // String type = params.get("__dbadmin_" + name + "_type");
if (type == null) // if (type == null)
throw new RuntimeException("Missing type hidden field for: " + name); // throw new RuntimeException("Missing type hidden field for: " + name);
try { try {
if (value == null) if (value == null)
row[currentIndex++] = null; row[currentIndex++] = null;
else else
row[currentIndex++] = DbFieldType.valueOf(type).parseValue(value); row[currentIndex++] = value; //DbFieldType.valueOf(type).parseValue(value);
} catch (IllegalArgumentException | SecurityException e) { } catch (IllegalArgumentException | SecurityException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -257,16 +257,16 @@ public class DbObjectSchema {
value = files.get(name); value = files.get(name);
} }
String type = params.get("__dbadmin_" + name + "_type"); // String type = params.get("__dbadmin_" + name + "_type");
if (type == null) // if (type == null)
throw new RuntimeException("Missing type hidden field for: " + name); // throw new RuntimeException("Missing type hidden field for: " + name);
try { try {
if (value == null) if (value == null)
row[currentIndex++] = null; row[currentIndex++] = null;
else else
row[currentIndex++] = DbFieldType.valueOf(type).parseValue(value); row[currentIndex++] = value; //DbFieldType.valueOf(type).parseValue(value);
} catch (IllegalArgumentException | SecurityException e) { } catch (IllegalArgumentException | SecurityException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -45,7 +45,7 @@
<i class="bi bi-caret-right filter-icon align-middle"></i> <i class="bi bi-caret-right filter-icon align-middle"></i>
<span class="fw-bold align-middle" th:text="${field.getName()}"></span> <span class="fw-bold align-middle" th:text="${field.getName()}"></span>
</div> </div>
<div class="card-body d-none"> <div class="card-body">
<form action="" method="GET"> <form action="" method="GET">
<!-- Reset page when applying filter to start back at page 1 --> <!-- Reset page when applying filter to start back at page 1 -->
@ -57,7 +57,7 @@
<th:block th:if="${field.isForeignKey()}"> <th:block th:if="${field.isForeignKey()}">
<div th:replace="~{fragments/forms :: input_autocomplete(field=${field}, value='')}"> <div th:replace="~{fragments/forms :: input_autocomplete(field=${field}, value='')}">
</div> </div>
<input type="hidden" th:value="${field.getType()}" th:name="|__dbadmin_${field.getName()}_type|"> <!-- <input type="hidden" th:value="${field.getType()}" th:name="|__dbadmin_${field.getName()}_type|"> -->
</th:block> </th:block>
<th:block th:unless="${field.isForeignKey()}"> <th:block th:unless="${field.isForeignKey()}">
<div class="container w-25"> <div class="container w-25">
@ -74,7 +74,7 @@
step="any" step="any"
oninvalid="this.setCustomValidity('This field is not nullable.')" oninvalid="this.setCustomValidity('This field is not nullable.')"
oninput="this.setCustomValidity('')"> oninput="this.setCustomValidity('')">
<input type="hidden" th:value="${field.getType()}" th:name="|__dbadmin_${field.getName()}_type|"> <!-- <input type="hidden" th:value="${field.getType()}" th:name="|__dbadmin_${field.getName()}_type|"> -->
</th:block> </th:block>
<th:block th:each="p : ${queryParams.keySet()}"> <th:block th:each="p : ${queryParams.keySet()}">

View File

@ -39,7 +39,7 @@
: (object != null ? object.traverse(field).getPrimaryKeyValue() : '' ) : (object != null ? object.traverse(field).getPrimaryKeyValue() : '' )
})}"> })}">
</div> </div>
<input type="hidden" th:value="${field.getType()}" th:name="|__dbadmin_${field.getName()}_type|"> <!-- <input type="hidden" th:value="${field.getType()}" th:name="|__dbadmin_${field.getName()}_type|"> -->
</th:block> </th:block>
<th:block th:unless="${field.isForeignKey()}"> <th:block th:unless="${field.isForeignKey()}">
<input placeholder="NULL" th:type="${field.getType().getHTMLName()}" <input placeholder="NULL" th:type="${field.getType().getHTMLName()}"
@ -55,7 +55,7 @@
step="any" step="any"
oninvalid="this.setCustomValidity('This field is not nullable.')" oninvalid="this.setCustomValidity('This field is not nullable.')"
oninput="this.setCustomValidity('')"> oninput="this.setCustomValidity('')">
<input type="hidden" th:value="${field.getType()}" th:name="|__dbadmin_${field.getName()}_type|"> <!-- <input type="hidden" th:value="${field.getType()}" th:name="|__dbadmin_${field.getName()}_type|"> -->
</th:block> </th:block>
</div> </div>