mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-09 05:48:20 +00:00
WIP
This commit is contained in:
parent
ef99c3e0ed
commit
d5371b307d
@ -20,6 +20,7 @@ import jakarta.persistence.Entity;
|
|||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.Lob;
|
||||||
import jakarta.persistence.ManyToMany;
|
import jakarta.persistence.ManyToMany;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
@ -201,6 +202,7 @@ public class DbAdmin {
|
|||||||
ManyToMany manyToMany = f.getAnnotation(ManyToMany.class);
|
ManyToMany manyToMany = f.getAnnotation(ManyToMany.class);
|
||||||
ManyToOne manyToOne = f.getAnnotation(ManyToOne.class);
|
ManyToOne manyToOne = f.getAnnotation(ManyToOne.class);
|
||||||
OneToOne oneToOne = f.getAnnotation(OneToOne.class);
|
OneToOne oneToOne = f.getAnnotation(OneToOne.class);
|
||||||
|
Lob lob = f.getAnnotation(Lob.class);
|
||||||
|
|
||||||
String fieldName = determineFieldName(f);
|
String fieldName = determineFieldName(f);
|
||||||
|
|
||||||
@ -212,6 +214,10 @@ public class DbAdmin {
|
|||||||
DbFieldType fieldType = null;
|
DbFieldType fieldType = null;
|
||||||
try {
|
try {
|
||||||
fieldType = DbFieldType.fromClass(f.getType());
|
fieldType = DbFieldType.fromClass(f.getType());
|
||||||
|
|
||||||
|
if (fieldType != null && lob != null && fieldType == DbFieldType.STRING) {
|
||||||
|
fieldType = DbFieldType.TEXT;
|
||||||
|
}
|
||||||
} catch (DbAdminException e) {
|
} catch (DbAdminException e) {
|
||||||
// If failure, we try to map a relationship on this field
|
// If failure, we try to map a relationship on this field
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,10 @@ public class DbField {
|
|||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isText() {
|
||||||
|
return type == DbFieldType.TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DbField [name=" + dbName + ", javaName=" + javaName + ", type=" + type + ", field=" + field
|
return "DbField [name=" + dbName + ", javaName=" + javaName + ", type=" + type + ", field=" + field
|
||||||
|
@ -163,6 +163,28 @@ public enum DbFieldType {
|
|||||||
return List.of(CompareOperator.CONTAINS, CompareOperator.STRING_EQ);
|
return List.of(CompareOperator.CONTAINS, CompareOperator.STRING_EQ);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
TEXT {
|
||||||
|
@Override
|
||||||
|
public String getHTMLName() {
|
||||||
|
return "textarea";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object parseValue(Object value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getJavaClass() {
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CompareOperator> getCompareOperators() {
|
||||||
|
return List.of(CompareOperator.CONTAINS, CompareOperator.STRING_EQ);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
BOOLEAN {
|
BOOLEAN {
|
||||||
@Override
|
@Override
|
||||||
public String getHTMLName() {
|
public String getHTMLName() {
|
||||||
|
@ -43,7 +43,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</th:block>
|
</th:block>
|
||||||
<th:block th:unless="${field.isForeignKey()}">
|
<th:block th:unless="${field.isForeignKey()}">
|
||||||
|
<th:block th:if="${field.isText()}">
|
||||||
|
<textarea placeholder="NULL"
|
||||||
|
th:name="${field.getName()}"
|
||||||
|
th:text="
|
||||||
|
${create ? (params != null ? params.getOrDefault(field.getName(), '') : '')
|
||||||
|
: (object != null ? object.get(field).getValue() : '' )}
|
||||||
|
"
|
||||||
|
class="form-control" th:id="|__id_${field.getName()}|"
|
||||||
|
th:required="${!field.isNullable() && !field.isPrimaryKey()}"
|
||||||
|
oninvalid="this.setCustomValidity('This field is not nullable.')"
|
||||||
|
rows="5"
|
||||||
|
oninput="this.setCustomValidity('')"></textarea>
|
||||||
|
</th:block>
|
||||||
|
<th:block th:if="${!field.isText()}">
|
||||||
<input th:if="${!field.isBinary()}" placeholder="NULL" th:type="${field.getType().getHTMLName()}"
|
<input th:if="${!field.isBinary()}" placeholder="NULL" th:type="${field.getType().getHTMLName()}"
|
||||||
th:name="${field.getName()}"
|
th:name="${field.getName()}"
|
||||||
th:value="
|
th:value="
|
||||||
@ -56,6 +69,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('')">
|
||||||
|
</th:block>
|
||||||
|
|
||||||
<!--/*--> Binary field <!--*/-->
|
<!--/*--> Binary field <!--*/-->
|
||||||
<th:block th:if="${field.isBinary()}">
|
<th:block th:if="${field.isBinary()}">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user