mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
WIP
This commit is contained in:
parent
82311fd23e
commit
00a3ff53f0
@ -195,6 +195,12 @@ public class DbAdminRepository {
|
||||
Map<String, Object> allValues = new HashMap<>();
|
||||
allValues.putAll(values);
|
||||
|
||||
values.keySet().forEach(fieldName -> {
|
||||
if (values.get(fieldName).isBlank()) {
|
||||
allValues.put(fieldName, null);
|
||||
}
|
||||
});
|
||||
|
||||
files.keySet().forEach(f -> {
|
||||
try {
|
||||
allValues.put(f, files.get(f).getBytes());
|
||||
|
@ -21,6 +21,9 @@ public class DbObject {
|
||||
private DbObjectSchema schema;
|
||||
|
||||
public DbObject(Object instance, DbObjectSchema schema) {
|
||||
if (instance == null)
|
||||
throw new DbAdminException("Trying to build object with instance == null");
|
||||
|
||||
this.instance = instance;
|
||||
this.schema = schema;
|
||||
}
|
||||
@ -54,6 +57,8 @@ public class DbObject {
|
||||
OneToOne oneToOne = field.getPrimitiveField().getAnnotation(OneToOne.class);
|
||||
if (oneToOne != null || manyToOne != null) {
|
||||
Object linkedObject = get(field.getJavaName()).getValue();
|
||||
if (linkedObject == null) return null;
|
||||
|
||||
DbObject linkedDbObject = new DbObject(linkedObject, field.getConnectedSchema());
|
||||
return linkedDbObject;
|
||||
} else {
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
<!-- data-row-field fragment -->
|
||||
<th:block th:fragment="data_row_field(field, object)">
|
||||
<th:block th:if="${field.getConnectedType() != null}">
|
||||
<th:block th:if="${field.getConnectedType() != null && object.traverse(field) != null}">
|
||||
<a th:href="|/dbadmin/model/${field.getConnectedType().getName()}/show/${object.traverse(field).getPrimaryKeyValue()}|">
|
||||
<span th:text="${object.has(field) ? object.traverse(field).getPrimaryKeyValue() : 'NULL'}"></span>
|
||||
</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user