mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 13:28:21 +00:00
Refactor DbField
to handle disableEditField
explicitly.
Removed the `isDisable` parameter from the `DbField` constructor and set `disableEditField` through a dedicated method. Updated relevant logic to ensure proper handling of non-editable fields across the application.
This commit is contained in:
parent
28063ed583
commit
50f2844319
@ -355,8 +355,8 @@ public class SnapAdmin {
|
|||||||
|
|
||||||
DisplayFormat displayFormat = f.getAnnotation(DisplayFormat.class);
|
DisplayFormat displayFormat = f.getAnnotation(DisplayFormat.class);
|
||||||
DisableEditField disableEdit = f.getAnnotation(DisableEditField.class);
|
DisableEditField disableEdit = f.getAnnotation(DisableEditField.class);
|
||||||
|
|
||||||
DbField field = new DbField(f.getName(), fieldName, f, fieldType, schema, displayFormat != null ? displayFormat.format() : null, disableEdit != null);
|
DbField field = new DbField(f.getName(), fieldName, f, fieldType, schema, displayFormat != null ? displayFormat.format() : null);
|
||||||
field.setConnectedType(connectedType);
|
field.setConnectedType(connectedType);
|
||||||
|
|
||||||
Id[] idAnnotations = f.getAnnotationsByType(Id.class);
|
Id[] idAnnotations = f.getAnnotationsByType(Id.class);
|
||||||
@ -366,6 +366,8 @@ public class SnapAdmin {
|
|||||||
|
|
||||||
if (field.isPrimaryKey())
|
if (field.isPrimaryKey())
|
||||||
field.setNullable(false);
|
field.setNullable(false);
|
||||||
|
|
||||||
|
field.setDisableEditField(disableEdit != null);
|
||||||
|
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
@ -96,14 +96,13 @@ public class DbField {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private DbObjectSchema schema;
|
private DbObjectSchema schema;
|
||||||
|
|
||||||
public DbField(String javaName, String name, Field field, DbFieldType type, DbObjectSchema schema, String format, boolean isDisable) {
|
public DbField(String javaName, String name, Field field, DbFieldType type, DbObjectSchema schema, String format) {
|
||||||
this.javaName = javaName;
|
this.javaName = javaName;
|
||||||
this.dbName = name;
|
this.dbName = name;
|
||||||
this.schema = schema;
|
this.schema = schema;
|
||||||
this.field = field;
|
this.field = field;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.format = format;
|
this.format = format;
|
||||||
this.disableEditField = isDisable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJavaName() {
|
public String getJavaName() {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<form class="form" enctype="multipart/form-data" method="post" th:action="|/${snapadmin_baseUrl}/model/${className}/create|">
|
<form class="form" enctype="multipart/form-data" method="post" th:action="|/${snapadmin_baseUrl}/model/${className}/create|">
|
||||||
<input type="hidden" name="__snapadmin_create" th:value="${create}">
|
<input type="hidden" name="__snapadmin_create" th:value="${create}">
|
||||||
<div th:each="field : ${schema.getSortedFields(false)}" class="mt-2"
|
<div th:each="field : ${schema.getSortedFields(false)}" class="mt-2"
|
||||||
th:unless="${(field.isGeneratedValue() && create) || field.isDisableEditField()}"
|
th:unless="${field.isGeneratedValue() && create || field.isDisableEditField()}"
|
||||||
th:classAppend="|${validationErrors != null && validationErrors.hasErrors(field.getJavaName()) ? 'invalid' : ''}|">
|
th:classAppend="|${validationErrors != null && validationErrors.hasErrors(field.getJavaName()) ? 'invalid' : ''}|">
|
||||||
<label th:for="|__id_${field.getName()}|" class="mb-1 fw-bold">
|
<label th:for="|__id_${field.getName()}|" class="mb-1 fw-bold">
|
||||||
<span th:if="${!field.isNullable() && !field.isPrimaryKey()}">
|
<span th:if="${!field.isNullable() && !field.isPrimaryKey()}">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user