Skip to content

Commit

Permalink
Merge pull request #710 from terrestris/init-reference
Browse files Browse the repository at this point in the history
Include REFERENCE_TABLE and make PropertyFormItemEditConfig abstract
  • Loading branch information
dnlkoch authored Sep 15, 2023
2 parents 60d1cd2 + e4bbaf5 commit f6b329a
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum EditFormComponentType {
DISPLAY("Display"),
INPUT("Input"),
NUMBER("Number"),
REFERENCE_TABLE("ReferenceTable"),
SELECT("Select"),
SWITCH("Switch"),
TEXTAREA("TextArea"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
@@ -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 { }
Original file line number Diff line number Diff line change
@@ -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;

}

0 comments on commit f6b329a

Please sign in to comment.