CE-1955 Switch fieldMetaData to use a type from in here for FieldAdornment, to include some better docs, but also to exclude new FILE_UPLOAD adornment type enum value

This commit is contained in:
2024-12-03 09:51:44 -06:00
parent 2bf12158be
commit 21aeac2def
3 changed files with 151 additions and 33 deletions

View File

@ -0,0 +1,115 @@
/*
* QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2024. Kingsrook, LLC
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
* contact@kingsrook.com
* https://github.com/Kingsrook/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.kingsrook.qqq.middleware.javalin.specs.v1.responses.components;
import java.io.Serializable;
import java.util.EnumSet;
import java.util.Map;
import com.kingsrook.qqq.backend.core.model.metadata.fields.AdornmentType;
import com.kingsrook.qqq.middleware.javalin.schemabuilder.ToSchema;
import com.kingsrook.qqq.middleware.javalin.schemabuilder.annotations.OpenAPIDescription;
import com.kingsrook.qqq.middleware.javalin.schemabuilder.annotations.OpenAPIEnumSubSet;
import com.kingsrook.qqq.middleware.javalin.schemabuilder.annotations.OpenAPIExclude;
/*******************************************************************************
**
*******************************************************************************/
public class FieldAdornment implements ToSchema
{
@OpenAPIExclude()
private com.kingsrook.qqq.backend.core.model.metadata.fields.FieldAdornment wrapped;
/*******************************************************************************
** Constructor
**
*******************************************************************************/
public FieldAdornment(com.kingsrook.qqq.backend.core.model.metadata.fields.FieldAdornment wrapped)
{
this.wrapped = wrapped;
}
/*******************************************************************************
** Constructor
**
*******************************************************************************/
public FieldAdornment()
{
}
/***************************************************************************
**
***************************************************************************/
public static class FieldAdornmentSubSet implements OpenAPIEnumSubSet.EnumSubSet<AdornmentType>
{
private static EnumSet<AdornmentType> subSet = null;
/***************************************************************************
**
***************************************************************************/
@Override
public EnumSet<AdornmentType> getSubSet()
{
if(subSet == null)
{
EnumSet<AdornmentType> subSet = EnumSet.allOf(AdornmentType.class);
subSet.remove(AdornmentType.FILE_UPLOAD); // todo - remove for next version!
FieldAdornmentSubSet.subSet = subSet;
}
return (subSet);
}
}
/***************************************************************************
**
***************************************************************************/
@OpenAPIDescription("Type of this adornment")
@OpenAPIEnumSubSet(FieldAdornmentSubSet.class)
public AdornmentType getType()
{
return (this.wrapped == null || this.wrapped.getType() == null ? null : this.wrapped.getType());
}
/***************************************************************************
**
***************************************************************************/
@OpenAPIDescription("Values associated with this adornment. Keys and the meanings of their values will differ by type.")
public Map<String, Serializable> getValues()
{
return (this.wrapped.getValues());
}
}

View File

@ -23,7 +23,6 @@ package com.kingsrook.qqq.middleware.javalin.specs.v1.responses.components;
import java.util.List;
import com.kingsrook.qqq.backend.core.model.metadata.fields.FieldAdornment;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
import com.kingsrook.qqq.middleware.javalin.schemabuilder.ToSchema;
import com.kingsrook.qqq.middleware.javalin.schemabuilder.annotations.OpenAPIDescription;
@ -61,6 +60,7 @@ public class FieldMetaData implements ToSchema
}
/***************************************************************************
**
***************************************************************************/
@ -82,6 +82,7 @@ public class FieldMetaData implements ToSchema
}
/***************************************************************************
**
***************************************************************************/
@ -92,6 +93,7 @@ public class FieldMetaData implements ToSchema
}
/***************************************************************************
**
***************************************************************************/
@ -102,6 +104,7 @@ public class FieldMetaData implements ToSchema
}
/***************************************************************************
**
***************************************************************************/
@ -112,6 +115,7 @@ public class FieldMetaData implements ToSchema
}
/***************************************************************************
**
***************************************************************************/
@ -122,6 +126,7 @@ public class FieldMetaData implements ToSchema
}
/***************************************************************************
**
***************************************************************************/
@ -143,6 +148,7 @@ public class FieldMetaData implements ToSchema
}
/***************************************************************************
**
***************************************************************************/
@ -153,6 +159,7 @@ public class FieldMetaData implements ToSchema
}
/***************************************************************************
**
***************************************************************************/
@ -166,6 +173,8 @@ public class FieldMetaData implements ToSchema
// todo - inline PVS
/***************************************************************************
**
***************************************************************************/
@ -177,14 +186,17 @@ public class FieldMetaData implements ToSchema
// todo behaviors?
/***************************************************************************
**
***************************************************************************/
@OpenAPIDescription("Special UI dressings to add to the field.")
@OpenAPIListItems(value = FieldAdornment.class) // todo!
@OpenAPIListItems(value = FieldAdornment.class, useRef = true)
public List<FieldAdornment> getAdornments()
{
return (this.wrapped.getAdornments());
return (this.wrapped.getAdornments() == null ? null : this.wrapped.getAdornments().stream().map(a -> new FieldAdornment(a)).toList());
}
// todo help content

View File

@ -130,26 +130,31 @@ components:
description: "Description of the error"
type: "string"
type: "object"
FieldAdornment:
properties:
type:
description: "Type of this adornment"
enum:
- "LINK"
- "CHIP"
- "SIZE"
- "CODE_EDITOR"
- "RENDER_HTML"
- "REVEAL"
- "FILE_DOWNLOAD"
- "ERROR"
type: "string"
values:
description: "Values associated with this adornment. Keys and the meanings\
\ of their values will differ by type."
type: "object"
type: "object"
FieldMetaData:
properties:
adornments:
description: "Special UI dressings to add to the field."
items:
properties:
type:
enum:
- "LINK"
- "CHIP"
- "SIZE"
- "CODE_EDITOR"
- "RENDER_HTML"
- "REVEAL"
- "FILE_DOWNLOAD"
- "ERROR"
type: "string"
values:
type: "object"
type: "object"
$ref: "#/components/schemas/FieldAdornment"
type: "array"
defaultValue:
description: "Default value to use in this field."
@ -973,21 +978,7 @@ components:
adornments:
description: "Special UI dressings to add to the field."
items:
properties:
type:
enum:
- "LINK"
- "CHIP"
- "SIZE"
- "CODE_EDITOR"
- "RENDER_HTML"
- "REVEAL"
- "FILE_DOWNLOAD"
- "ERROR"
type: "string"
values:
type: "object"
type: "object"
$ref: "#/components/schemas/FieldAdornment"
type: "array"
defaultValue:
description: "Default value to use in this field."