diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/enumeration/EditFormComponentType.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/enumeration/EditFormComponentType.java index eb2366562..d373ed782 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/enumeration/EditFormComponentType.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/enumeration/EditFormComponentType.java @@ -22,6 +22,7 @@ public enum EditFormComponentType { DISPLAY("Display"), INPUT("Input"), NUMBER("Number"), + REFERENCE_TABLE("ReferenceTable"), SELECT("Select"), SWITCH("Switch"), TEXTAREA("TextArea"), diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditConfig.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditConfig.java index 78bbcd675..58acc3b67 100644 --- a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditConfig.java +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditConfig.java @@ -17,7 +17,10 @@ package de.terrestris.shogun.lib.model.jsonb.layer; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; import de.terrestris.shogun.lib.enumeration.EditFormComponentType; +import io.swagger.v3.oas.annotations.media.DiscriminatorMapping; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Data; @@ -29,7 +32,78 @@ @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @AllArgsConstructor -public class PropertyFormItemEditConfig extends PropertyFormItemReadConfig { +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "component", + include = JsonTypeInfo.As.EXISTING_PROPERTY, + visible = true, + defaultImpl = PropertyFormItemEditDefaultConfig.class +) +@JsonSubTypes({ + @JsonSubTypes.Type( + value = PropertyFormItemEditReferenceTableConfig.class, + name = "REFERENCE_TABLE" + ), + @JsonSubTypes.Type( + value = PropertyFormItemEditDefaultConfig.class, + names = { + "CHECKBOX", + "DATE", + "DISPLAY", + "INPUT", + "NUMBER", + "SELECT", + "SWITCH", + "TEXTAREA", + "UPLOAD" + } + ) +}) +@Schema( + discriminatorMapping = { + @DiscriminatorMapping( + value = "REFERENCE_TABLE", + schema = PropertyFormItemEditReferenceTableConfig.class + ), + @DiscriminatorMapping( + value = "CHECKBOX", + schema = PropertyFormItemEditDefaultConfig.class + ), + @DiscriminatorMapping( + value = "DATE", + schema = PropertyFormItemEditDefaultConfig.class + ), + @DiscriminatorMapping( + value = "DISPLAY", + schema = PropertyFormItemEditDefaultConfig.class + ), + @DiscriminatorMapping( + value = "INPUT", + schema = PropertyFormItemEditDefaultConfig.class + ), + @DiscriminatorMapping( + value = "NUMBER", + schema = PropertyFormItemEditDefaultConfig.class + ), + @DiscriminatorMapping( + value = "SELECT", + schema = PropertyFormItemEditDefaultConfig.class + ), + @DiscriminatorMapping( + value = "SWITCH", + schema = PropertyFormItemEditDefaultConfig.class + ), + @DiscriminatorMapping( + value = "TEXTAREA", + schema = PropertyFormItemEditDefaultConfig.class + ), + @DiscriminatorMapping( + value = "UPLOAD", + schema = PropertyFormItemEditDefaultConfig.class + ) + } +) +public abstract class PropertyFormItemEditConfig extends PropertyFormItemReadConfig { @Schema( description = "The identifier of the component to render for this property.", diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditDefaultConfig.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditDefaultConfig.java new file mode 100644 index 000000000..8b9f7978e --- /dev/null +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditDefaultConfig.java @@ -0,0 +1,28 @@ +/* SHOGun, https://terrestris.github.io/shogun/ + * + * Copyright © 2023-present terrestris GmbH & Co. KG + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.terrestris.shogun.lib.model.jsonb.layer; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +@ToString +@EqualsAndHashCode(callSuper = true) +public class PropertyFormItemEditDefaultConfig extends PropertyFormItemEditConfig { } diff --git a/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditReferenceTableConfig.java b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditReferenceTableConfig.java new file mode 100644 index 000000000..b7e44eca6 --- /dev/null +++ b/shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/layer/PropertyFormItemEditReferenceTableConfig.java @@ -0,0 +1,43 @@ +/* SHOGun, https://terrestris.github.io/shogun/ + * + * Copyright © 2023-present terrestris GmbH & Co. KG + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.terrestris.shogun.lib.model.jsonb.layer; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +@ToString +@EqualsAndHashCode(callSuper = false) +public class PropertyFormItemEditReferenceTableConfig extends PropertyFormItemEditConfig { + + @Schema( + description = "Set the property of the referenced layer (see layerId) that should be displayed in the " + + "table. If not set the 'id' field will be used.", + example = "BUILDING_ID" + ) + private String tablePropertyName; + + @Schema( + description = "Set the configuration of the referenced schema." + ) + private PropertyFormItemEditConfig[] editFormConfig; + +}