Try to make happier when scripts & apis don't live together

This commit is contained in:
2023-04-28 16:00:06 -05:00
parent d35f150202
commit 9ce45934a8

View File

@ -382,7 +382,6 @@ public class ScriptsMetaDataProvider
.withRecordLabelFormat("%s v%s")
.withRecordLabelFields(List.of("scriptId", "sequenceNo"))
.withSection(new QFieldSection("identity", new QIcon().withName("badge"), Tier.T1, List.of("id", "scriptId", "sequenceNo")))
.withSection(new QFieldSection("api", "API", new QIcon().withName("code"), Tier.T2, List.of("apiName", "apiVersion")))
.withSection(new QFieldSection("code", new QIcon().withName("data_object"), Tier.T2, List.of("contents")))
.withSection(new QFieldSection("changeManagement", new QIcon().withName("history"), Tier.T2, List.of("commitMessage", "author")))
.withSection(new QFieldSection("dates", new QIcon().withName("calendar_month"), Tier.T3, List.of("createDate", "modifyDate")));
@ -390,6 +389,23 @@ public class ScriptsMetaDataProvider
tableMetaData.getField("contents").withFieldAdornment(new FieldAdornment(AdornmentType.CODE_EDITOR).withValue(AdornmentType.CodeEditorValues.languageMode("javascript")));
tableMetaData.getField("scriptId").withFieldAdornment(AdornmentType.Size.LARGE.toAdornment());
try
{
////////////////////////////////////////////////////////////////////////////////////////////////////
// if the api module is loaded, then add a section to the table for the api name & version fields //
////////////////////////////////////////////////////////////////////////////////////////////////////
Class.forName("com.kingsrook.qqq.api.model.metadata.ApiInstanceMetaDataProvider");
tableMetaData.getSections().add(1, new QFieldSection("api", "API", new QIcon().withName("code"), Tier.T2, List.of("apiName", "apiVersion")));
}
catch(ClassNotFoundException e)
{
/////////////////////////////////////////////////////////////////////////////////////////////////////
// if the api module is not loaded, then make sure we don't have these fields in our scripts table //
/////////////////////////////////////////////////////////////////////////////////////////////////////
tableMetaData.getFields().remove("apiName");
tableMetaData.getFields().remove("apiVersion");
}
return (tableMetaData);
}