Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use AutoPopulated as String to avoid requiring data #656

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion views-fieldset/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
testImplementation(mnValidation.micronaut.validation)

compileOnly(projects.micronautViewsCore)
compileOnly(mnData.micronaut.data.model)

testImplementation(mnData.micronaut.data.model)

testAnnotationProcessor(mn.micronaut.inject.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.micronaut.core.beans.BeanProperty;
import io.micronaut.core.beans.BeanWrapper;
import io.micronaut.core.util.StringUtils;
import io.micronaut.data.annotation.AutoPopulated;
import io.micronaut.views.fields.annotations.InputCheckbox;
import io.micronaut.views.fields.annotations.InputEmail;
import io.micronaut.views.fields.annotations.InputHidden;
Expand Down Expand Up @@ -92,6 +91,7 @@ public class DefaultFieldGenerator implements FieldsetGenerator {
);
private static final String MEMBER_MIN = "min";
private static final String MEMBER_MAX = "max";
private static final String CLASS_IO_MICRONAUT_DATA_ANNOTATION_AUTO_POPULATED = "io.micronaut.data.annotation.AutoPopulated";

private final EnumOptionFetcher<?> enumOptionFetcher;

Expand Down Expand Up @@ -183,7 +183,7 @@ private <T> List<? extends FormElement> generateOfBeanWrapper(@NonNull BeanWrapp

@NonNull
private <T> Optional<Class<? extends FormElement>> formElementClassForBeanProperty(@NonNull BeanProperty<T, ?> beanProperty) {
if (beanProperty.hasStereotype(AutoPopulated.class)) {
if (beanProperty.hasStereotype(CLASS_IO_MICRONAUT_DATA_ANNOTATION_AUTO_POPULATED)) {
return Optional.empty();
}
for (var mapping : ANNOTATION_MAPPING.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

import io.micronaut.context.annotation.Configuration;
import io.micronaut.context.annotation.Requires;
import io.micronaut.views.ViewsRenderer;
import io.micronaut.views.ViewsRenderer;
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
@Property(name = "spec.name", value = "AutomaticallyPopulatedTest")
@MicronautTest(startApplication = false)
class AutomaticallyPopulatedTest {

// @DateCreated and @DateUpdated are @AutoPopulated annotations
@Introspected
record Book(@NotBlank String title,
@DateCreated @Nullable LocalDate dateCreated,
Expand Down
Loading