mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
Enabled OffsetDateTime support
This commit is contained in:
parent
cc131739c3
commit
1142e393e7
@ -123,29 +123,29 @@ public enum DbFieldType {
|
||||
return List.of(CompareOperator.GT, CompareOperator.EQ, CompareOperator.LT);
|
||||
}
|
||||
},
|
||||
// OFFSET_DATE_TIME {
|
||||
// @Override
|
||||
// public String getFragmentName(FragmentContext c) {
|
||||
// return "text";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Object parseValue(Object value) {
|
||||
// if (value == null) return null;
|
||||
// return OffsetDateTime.parse(value.toString());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Class<?> getJavaClass() {
|
||||
// return OffsetDateTime.class;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<CompareOperator> getCompareOperators() {
|
||||
// return List.of(CompareOperator.AFTER, CompareOperator.STRING_EQ, CompareOperator.BEFORE);
|
||||
// }
|
||||
//
|
||||
// },
|
||||
OFFSET_DATE_TIME {
|
||||
@Override
|
||||
public String getFragmentName(FragmentContext c) {
|
||||
return "datetime";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parseValue(Object value) {
|
||||
if (value == null) return null;
|
||||
return OffsetDateTime.parse(value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getJavaClass() {
|
||||
return OffsetDateTime.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompareOperator> getCompareOperators() {
|
||||
return List.of(CompareOperator.AFTER, CompareOperator.STRING_EQ, CompareOperator.BEFORE);
|
||||
}
|
||||
|
||||
},
|
||||
LOCAL_DATE {
|
||||
@Override
|
||||
public String getFragmentName(FragmentContext c) {
|
||||
@ -450,8 +450,8 @@ public enum DbFieldType {
|
||||
return BIG_DECIMAL;
|
||||
} else if (klass == byte[].class) {
|
||||
return BYTE_ARRAY;
|
||||
// } else if (klass == OffsetDateTime.class) {
|
||||
// return OFFSET_DATE_TIME;
|
||||
} else if (klass == OffsetDateTime.class) {
|
||||
return OFFSET_DATE_TIME;
|
||||
} else {
|
||||
throw new DbAdminException("Unsupported field type: " + klass);
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package tech.ailef.dbadmin.external.dbmapping;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@ -38,6 +40,17 @@ public class DbFieldValue {
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
/*
|
||||
* Special handling of OffsetDateTime to be compatbile
|
||||
* with the HTML datetime-local input field: we "cast"
|
||||
* it to a LocalDateTime so the toString() method will
|
||||
* not produce the ending "Z" which prevents the datepicker
|
||||
* to be autofilled on edit pages.
|
||||
*/
|
||||
if (value instanceof OffsetDateTime) {
|
||||
return LocalDateTime.from((OffsetDateTime)value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
||||
<div class="separator mb-2 mt-2"></div>
|
||||
<h3 th:if="${!schema.getErrors().isEmpty()}"
|
||||
class="fw-bold mt-3 mb-3"><i class="bi bi-exclamation-triangle"></i> Errors</h3>
|
||||
<ul>
|
||||
<ul class="mapping-errors">
|
||||
<li th:each="error : ${schema.getErrors()}" th:text="${error.getMessage()}">
|
||||
</li>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user