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

Include REFERENCE_TABLE and make PropertyFormItemEditConfig abstract #710

Merged
merged 1 commit into from
Sep 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
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;

}
Loading