Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b9619a0c2 |
No files matched your search
@@ -881,7 +881,7 @@ function DashboardWidgets({widgetMetaDataList, tableName, entityPrimaryKey, reco
|
||||
{
|
||||
widgetMetaData.type === "rowBuilder" && (
|
||||
(widgetData && widgetData[i]) ?
|
||||
<RowBuilderWidget widgetMetaData={widgetMetaData} widgetData={widgetData[i]} screen={screen} onSaveCallback={rowBuilderOnSaveCallback} /> :
|
||||
<RowBuilderWidget widgetMetaData={widgetMetaData} widgetData={widgetData[i]} screen={screen} parentFormValues={values} onSaveCallback={rowBuilderOnSaveCallback} /> :
|
||||
<NotLoaded widgetMetaData={widgetMetaData} widgetIndex={i} />
|
||||
)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -368,7 +368,8 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
||||
}
|
||||
|
||||
let isChildRecordWidget = widgetMetaData.type == "childRecordList";
|
||||
if (!isChildRecordWidget && renderedWidgets[activeStep.name][widgetName])
|
||||
let isValueDependentWidget = widgetMetaData.type == "rowBuilder";
|
||||
if (!isChildRecordWidget && !isValueDependentWidget && renderedWidgets[activeStep.name][widgetName])
|
||||
{
|
||||
return renderedWidgets[activeStep.name][widgetName];
|
||||
}
|
||||
@@ -405,7 +406,10 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
||||
const renderedWidget = (<Box m={-2}>
|
||||
<DashboardWidgets widgetMetaDataList={[widgetMetaData]} omitWrappingGridContainer={true} childUrlParams={queryStringParts.join("&")} initialWidgetDataList={initialWidgetDataList} values={processValues} actionCallback={actionCallback} />
|
||||
</Box>);
|
||||
renderedWidgets[activeStep.name][widgetName] = renderedWidget;
|
||||
if (!isValueDependentWidget)
|
||||
{
|
||||
renderedWidgets[activeStep.name][widgetName] = renderedWidget;
|
||||
}
|
||||
return renderedWidget;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ function QFMDBridgeForm({fields, record, handleChange, handleSubmit, helpRoles,
|
||||
}
|
||||
|
||||
}
|
||||
const [lastValues, setLastValues] = useState(initialValues);
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -161,6 +160,18 @@ function QFMDBridgeForm({fields, record, handleChange, handleSubmit, helpRoles,
|
||||
}
|
||||
}
|
||||
|
||||
const bridgeHandleChange = (fieldName: string, newValue: any) =>
|
||||
{
|
||||
const field = fields.find((candidateField) => candidateField.name === fieldName);
|
||||
if (field?.possibleValueSourceName || field?.inlinePossibleValueSource)
|
||||
{
|
||||
handleChange(fieldName, newValue ? newValue.id : null);
|
||||
return;
|
||||
}
|
||||
|
||||
handleChange(fieldName, newValue);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// re-introduce these two context providers, in case the child calls this //
|
||||
// method under a different root... maybe this should be optional per a param? //
|
||||
@@ -178,31 +189,7 @@ function QFMDBridgeForm({fields, record, handleChange, handleSubmit, helpRoles,
|
||||
formData.errors = errors;
|
||||
formData.formFields = dynamicFormFields;
|
||||
|
||||
try
|
||||
{
|
||||
let anyDiffs = false;
|
||||
for (let fieldName in values)
|
||||
{
|
||||
const value = values[fieldName];
|
||||
if (lastValues[fieldName] != value)
|
||||
{
|
||||
handleChange(fieldName, value);
|
||||
lastValues[fieldName] = value;
|
||||
anyDiffs = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (anyDiffs)
|
||||
{
|
||||
setLastValues(lastValues);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
return (<QDynamicForm formData={formData} record={record} helpRoles={helpRoles} helpContentKeyPrefix={helpContentKeyPrefix} />);
|
||||
return (<QDynamicForm formData={formData} record={record} helpRoles={helpRoles} helpContentKeyPrefix={helpContentKeyPrefix} valueChangedCallback={bridgeHandleChange} />);
|
||||
}}
|
||||
</Formik>
|
||||
</ThemeProvider>
|
||||
@@ -229,6 +216,7 @@ QFMDBridgeWidget.defaultProps = {};
|
||||
function QFMDBridgeWidget({widgetName, tableName, record, entityPrimaryKey, actionCallback, qContext: qContextProp}: QFMDBridgeWidgetProps): JSX.Element
|
||||
{
|
||||
const qContext = useContext(QContext) as QContextType;
|
||||
const recordValuesObject = Object.fromEntries(record?.values?.entries?.() ?? []);
|
||||
|
||||
const [ready, setReady] = useState(false);
|
||||
|
||||
@@ -236,9 +224,12 @@ function QFMDBridgeWidget({widgetName, tableName, record, entityPrimaryKey, acti
|
||||
const [widgetData, setWidgetData] = useState(null as any);
|
||||
|
||||
const [tableMetaData, setTableMetaData] = useState(null as QTableMetaData);
|
||||
const recordValuesSignature = JSON.stringify(Object.fromEntries(record?.values?.entries?.() ?? []));
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
let cancelled = false;
|
||||
|
||||
(async () =>
|
||||
{
|
||||
const qController = Client.getInstance();
|
||||
@@ -250,14 +241,24 @@ function QFMDBridgeWidget({widgetName, tableName, record, entityPrimaryKey, acti
|
||||
formData.append(key, record.values.get(key));
|
||||
}
|
||||
|
||||
setWidgetMetaData(qInstance.widgets.get(widgetName));
|
||||
setWidgetData(await qController.widget(widgetName, formData));
|
||||
const nextWidgetMetaData = qInstance.widgets.get(widgetName);
|
||||
const nextWidgetData = await qController.widget(widgetName, formData);
|
||||
|
||||
setReady(true);
|
||||
if (!cancelled)
|
||||
{
|
||||
setWidgetMetaData(nextWidgetMetaData);
|
||||
setWidgetData(nextWidgetData);
|
||||
setReady(true);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
if (!ready)
|
||||
return () =>
|
||||
{
|
||||
cancelled = true;
|
||||
};
|
||||
}, [entityPrimaryKey, recordValuesSignature, tableName, widgetName]);
|
||||
|
||||
if (!ready && (!widgetMetaData || !widgetData))
|
||||
{
|
||||
return (<Box py={"1rem"}>Loading...</Box>);
|
||||
}
|
||||
@@ -274,7 +275,7 @@ function QFMDBridgeWidget({widgetName, tableName, record, entityPrimaryKey, acti
|
||||
setTableMetaData: (tableMetaData: QTableMetaData) => setTableMetaData(tableMetaData),
|
||||
}}>
|
||||
<div className={`bridgedWidget ${widgetMetaData.type}`}>
|
||||
<DashboardWidgets tableName={tableName} widgetMetaDataList={[widgetMetaData]} initialWidgetDataList={[widgetData]} record={record} entityPrimaryKey={entityPrimaryKey} omitWrappingGridContainer={true} actionCallback={actionCallback} />
|
||||
<DashboardWidgets tableName={tableName} widgetMetaDataList={[widgetMetaData]} initialWidgetDataList={[widgetData]} record={record} values={recordValuesObject} entityPrimaryKey={entityPrimaryKey} omitWrappingGridContainer={true} actionCallback={actionCallback} />
|
||||
</div>
|
||||
</QContext.Provider>
|
||||
</ThemeProvider>
|
||||
@@ -434,4 +435,3 @@ export const qfmdBridge =
|
||||
return (<QFMDBridgeForm fields={fields} record={record} handleChange={handleChange} handleSubmit={handleSubmit} helpRoles={helpRoles} helpContentKeyPrefix={helpContentKeyPrefix} />);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user