mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-09 05:48:20 +00:00
Support for char
and short
field types; Improved UI on create/edit form, now showing the type for each input element
This commit is contained in:
parent
e1010a6c86
commit
bf7a4c8956
@ -20,7 +20,6 @@
|
|||||||
package tech.ailef.dbadmin.external.dbmapping;
|
package tech.ailef.dbadmin.external.dbmapping;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -352,6 +352,48 @@ public enum DbFieldType {
|
|||||||
return List.of(CompareOperator.GT, CompareOperator.EQ, CompareOperator.LT);
|
return List.of(CompareOperator.GT, CompareOperator.EQ, CompareOperator.LT);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
CHAR {
|
||||||
|
@Override
|
||||||
|
public String getFragmentName(FragmentContext c) {
|
||||||
|
return "char";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object parseValue(Object value) {
|
||||||
|
return value.toString().charAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getJavaClass() {
|
||||||
|
return char.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CompareOperator> getCompareOperators() {
|
||||||
|
return List.of(CompareOperator.STRING_EQ);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
BYTE {
|
||||||
|
@Override
|
||||||
|
public String getFragmentName(FragmentContext c) {
|
||||||
|
return "number";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object parseValue(Object value) {
|
||||||
|
return value.toString().getBytes()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getJavaClass() {
|
||||||
|
return byte.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CompareOperator> getCompareOperators() {
|
||||||
|
throw new DbAdminException("Binary fields are not comparable");
|
||||||
|
}
|
||||||
|
},
|
||||||
BYTE_ARRAY {
|
BYTE_ARRAY {
|
||||||
@Override
|
@Override
|
||||||
public String getFragmentName(FragmentContext c) {
|
public String getFragmentName(FragmentContext c) {
|
||||||
@ -559,6 +601,10 @@ public enum DbFieldType {
|
|||||||
return BYTE_ARRAY;
|
return BYTE_ARRAY;
|
||||||
} else if (klass == OffsetDateTime.class) {
|
} else if (klass == OffsetDateTime.class) {
|
||||||
return OFFSET_DATE_TIME;
|
return OFFSET_DATE_TIME;
|
||||||
|
} else if (klass == byte.class || klass == Byte.class) {
|
||||||
|
return BYTE;
|
||||||
|
} else if (klass == char.class || klass == Character.class) {
|
||||||
|
return CHAR;
|
||||||
} else {
|
} else {
|
||||||
throw new DbAdminException("Unsupported field type: " + klass);
|
throw new DbAdminException("Unsupported field type: " + klass);
|
||||||
}
|
}
|
||||||
|
@ -8,37 +8,75 @@
|
|||||||
rows="5"
|
rows="5"
|
||||||
th:classAppend="|${field.isReadOnly() && !create ? 'disable' : ''}|"
|
th:classAppend="|${field.isReadOnly() && !create ? 'disable' : ''}|"
|
||||||
></textarea>
|
></textarea>
|
||||||
<input placeholder="NULL" th:fragment="text(field, create, name, value)"
|
<th:block th:fragment="char(field, create, name, value)">
|
||||||
type="text"
|
<div class="input-group">
|
||||||
th:value="${value}"
|
<span class="input-group-text font-monospace">
|
||||||
th:name="${name}"
|
[[ ${field.getType()} ]]
|
||||||
class="form-control " th:id="|__id_${field.getName()}|"
|
</span>
|
||||||
th:classAppend="|${(field.isPrimaryKey() && object != null) ||
|
<input placeholder="NULL"
|
||||||
(field.isReadOnly() && !create) ? 'disable' : ''}|"
|
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>
|
||||||
|
</div>
|
||||||
|
</th:block>
|
||||||
|
<th:block th:fragment="text(field, create, name, value)">
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text font-monospace">
|
||||||
|
[[ ${field.getType()} ]]
|
||||||
|
</span>
|
||||||
|
<input placeholder="NULL"
|
||||||
|
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()}"
|
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
|
||||||
></input>
|
></input>
|
||||||
<input placeholder="NULL" th:fragment="number(field, create, name, value)"
|
</div>
|
||||||
type="number"
|
</th:block>
|
||||||
th:value="${value}"
|
<th:block th:fragment="number(field, create, name, value)">
|
||||||
th:name="${name}"
|
<div class="input-group">
|
||||||
class="form-control " th:id="|__id_${field.getName()}|"
|
<span class="input-group-text font-monospace">
|
||||||
th:classAppend="|${(field.isPrimaryKey() && object != null) ||
|
[[ ${field.getType()} ]]
|
||||||
(field.isReadOnly() && !create) ? 'disable' : ''}|"
|
</span>
|
||||||
|
<input placeholder="NULL"
|
||||||
|
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()}"
|
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
|
||||||
step="any"
|
step="any"
|
||||||
></input>
|
></input>
|
||||||
<input placeholder="NULL" th:fragment="datetime(field, create, name, value)"
|
</div>
|
||||||
type="datetime-local"
|
</th:block>
|
||||||
th:value="${value}"
|
<th:block th:fragment="datetime(field, create, name, value)"
|
||||||
th:name="${name}"
|
<span class="input-group-text font-monospace">
|
||||||
class="form-control " th:id="|__id_${field.getName()}|"
|
[[ ${field.getType()} ]]
|
||||||
th:classAppend="|${create != null && ((field.isPrimaryKey() && object != null) ||
|
</span>
|
||||||
(field.isReadOnly() && !create)) ? 'disable' : ''}|"
|
<div class="input-group">
|
||||||
|
<input placeholder="NULL"
|
||||||
|
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()}"
|
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
|
||||||
></input>
|
></input>
|
||||||
|
</div>
|
||||||
|
</th:block>
|
||||||
<!--
|
<!--
|
||||||
<th:block th:fragment="offset_datetime(field, create, name, value)">
|
<th:block th:fragment="offset_datetime(field, create, name, value)">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -65,16 +103,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</th:block>
|
</th:block>
|
||||||
-->
|
-->
|
||||||
<input placeholder="NULL" th:fragment="date(field, create, name, value)"
|
<th:block th:fragment="date(field, create, name, value)">
|
||||||
type="date"
|
<div class="input-group">
|
||||||
th:value="${value}"
|
<span class="input-group-text font-monospace">
|
||||||
th:name="${name}"
|
[[ ${field.getType()} ]]
|
||||||
class="form-control " th:id="|__id_${field.getName()}|"
|
</span>
|
||||||
th:classAppend="|${create != null && ((field.isPrimaryKey() && object != null) ||
|
<input placeholder="NULL"
|
||||||
(field.isReadOnly() && !create)) ? 'disable' : ''}|"
|
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()}"
|
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
|
||||||
></input>
|
></input>
|
||||||
|
</div>
|
||||||
|
</th:block>
|
||||||
<th:block th:if="${field.isBinary()}" th:fragment="file(field, create, name, value)" >
|
<th:block th:if="${field.isBinary()}" th:fragment="file(field, create, name, value)" >
|
||||||
<!--/*--> Edit options <!--*/-->
|
<!--/*--> Edit options <!--*/-->
|
||||||
<div th:if="${!create && object.get(field).getValue() != null}">
|
<div th:if="${!create && object.get(field).getValue() != null}">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user