allow specifying text for the submit butotn in an rjsf form w/ burnettk (#662)
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
016eafa35d
commit
ba8f0a1c74
|
@ -232,6 +232,43 @@ export default function TaskShow() {
|
|||
sendAutosaveEvent({ successCallback });
|
||||
};
|
||||
|
||||
// we had to duplicate this logic because we pass chlidren to the Form.
|
||||
// we pass children to the form because of additional submit buttons on the form for signals, and we
|
||||
// probably want these to be styled next to the default button.
|
||||
// if we remove the children prop from the Form, the submit button text works perfectly per the
|
||||
// docs at https://rjsf-team.github.io/react-jsonschema-form/docs/api-reference/uiSchema
|
||||
const getSubmitButtonOptions = (formUiSchema: any) => {
|
||||
const uiOptionsString = 'ui:options';
|
||||
let submitButtonOptions = {};
|
||||
if ('ui:submitButtonOptions' in formUiSchema) {
|
||||
submitButtonOptions = formUiSchema['ui:submitButtonOptions'];
|
||||
}
|
||||
if (
|
||||
uiOptionsString in formUiSchema &&
|
||||
'submitButtonOptions' in formUiSchema[uiOptionsString]
|
||||
) {
|
||||
submitButtonOptions = {
|
||||
...submitButtonOptions,
|
||||
...formUiSchema[uiOptionsString].submitButtonOptions,
|
||||
};
|
||||
}
|
||||
return submitButtonOptions;
|
||||
};
|
||||
|
||||
const getSubmitButtonText = (formUiSchema: any) => {
|
||||
if (!taskWithTaskData) {
|
||||
return null;
|
||||
}
|
||||
const submitButtonOptions = getSubmitButtonOptions(formUiSchema);
|
||||
let submitButtonText = 'Submit';
|
||||
if ('submitText' in submitButtonOptions) {
|
||||
submitButtonText = submitButtonOptions.submitText as string;
|
||||
} else if (taskWithTaskData.typename === 'ManualTask') {
|
||||
submitButtonText = 'Continue';
|
||||
}
|
||||
return submitButtonText;
|
||||
};
|
||||
|
||||
const formElement = () => {
|
||||
if (!taskWithTaskData) {
|
||||
return null;
|
||||
|
@ -273,11 +310,9 @@ export default function TaskShow() {
|
|||
}
|
||||
|
||||
if (taskWithTaskData.state === 'READY') {
|
||||
let submitButtonText = 'Submit';
|
||||
const submitButtonText = getSubmitButtonText(formUiSchema);
|
||||
let closeButton = null;
|
||||
if (taskWithTaskData.typename === 'ManualTask') {
|
||||
submitButtonText = 'Continue';
|
||||
} else if (
|
||||
if (
|
||||
taskWithTaskData.typename === 'UserTask' &&
|
||||
!UserService.onlyGuestTaskCompletion()
|
||||
) {
|
||||
|
|
Loading…
Reference in New Issue