From 036b02bb6ca87c73ffb14c7874068b868ff23128 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Mon, 3 Feb 2025 08:53:30 -0600 Subject: [PATCH] Add defaultValuesForNewChildRecordsFromParentFields to ChildRecordListData --- .../widgets/ChildRecordListRenderer.java | 10 +++++- .../widgets/ChildRecordListData.java | 32 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/dashboard/widgets/ChildRecordListRenderer.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/dashboard/widgets/ChildRecordListRenderer.java index e8f654ed..1cc01320 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/dashboard/widgets/ChildRecordListRenderer.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/dashboard/widgets/ChildRecordListRenderer.java @@ -165,6 +165,7 @@ public class ChildRecordListRenderer extends AbstractWidgetRenderer *******************************************************************************/ public Builder withManageAssociationName(String manageAssociationName) { + // todo - validate association name exists (on the table?) widgetMetaData.withDefaultValue("manageAssociationName", manageAssociationName); return (this); } @@ -194,7 +195,7 @@ public class ChildRecordListRenderer extends AbstractWidgetRenderer } else if(input.getWidgetMetaData().getDefaultValues().containsKey("maxRows")) { - maxRows = ValueUtils.getValueAsInteger(input.getWidgetMetaData().getDefaultValues().containsKey("maxRows")); + maxRows = ValueUtils.getValueAsInteger(input.getWidgetMetaData().getDefaultValues().get("maxRows")); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -299,6 +300,13 @@ public class ChildRecordListRenderer extends AbstractWidgetRenderer } } } + + if(widgetValues.containsKey("defaultValuesForNewChildRecordsFromParentFields")) + { + @SuppressWarnings("unchecked") + Map defaultValuesForNewChildRecordsFromParentFields = (Map) widgetValues.get("defaultValuesForNewChildRecordsFromParentFields"); + widgetData.setDefaultValuesForNewChildRecordsFromParentFields(defaultValuesForNewChildRecordsFromParentFields); + } } widgetData.setAllowRecordEdit(BooleanUtils.isTrue(ValueUtils.getValueAsBoolean(input.getQueryParams().get("allowRecordEdit")))); diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/ChildRecordListData.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/ChildRecordListData.java index a6b3a6eb..a5992234 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/ChildRecordListData.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/ChildRecordListData.java @@ -51,6 +51,7 @@ public class ChildRecordListData extends QWidgetData private boolean canAddChildRecord = false; private Map defaultValuesForNewChildRecords; private Set disabledFieldsForNewChildRecords; + private Map defaultValuesForNewChildRecordsFromParentFields; @@ -523,6 +524,37 @@ public class ChildRecordListData extends QWidgetData return (this); } + + + /******************************************************************************* + ** Getter for defaultValuesForNewChildRecordsFromParentFields + *******************************************************************************/ + public Map getDefaultValuesForNewChildRecordsFromParentFields() + { + return (this.defaultValuesForNewChildRecordsFromParentFields); + } + + + + /******************************************************************************* + ** Setter for defaultValuesForNewChildRecordsFromParentFields + *******************************************************************************/ + public void setDefaultValuesForNewChildRecordsFromParentFields(Map defaultValuesForNewChildRecordsFromParentFields) + { + this.defaultValuesForNewChildRecordsFromParentFields = defaultValuesForNewChildRecordsFromParentFields; + } + + + + /******************************************************************************* + ** Fluent setter for defaultValuesForNewChildRecordsFromParentFields + *******************************************************************************/ + public ChildRecordListData withDefaultValuesForNewChildRecordsFromParentFields(Map defaultValuesForNewChildRecordsFromParentFields) + { + this.defaultValuesForNewChildRecordsFromParentFields = defaultValuesForNewChildRecordsFromParentFields; + return (this); + } + }