refactor: remove unneeded concrete common class
custom form fields creation logic as overridable function
This commit is contained in:
@@ -86,7 +86,11 @@ export default abstract class ElixFormsComponentAbstract extends Component<IElix
|
||||
);
|
||||
}
|
||||
|
||||
public createCustomFormFields(callback: (formFieldFactory: IElixFormsComponentCustomFormFieldFactory) => JSX.Element = () => <></>): JSX.Element {
|
||||
protected createCustomFormFields(formFieldFactory: IElixFormsComponentCustomFormFieldFactory): JSX.Element {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
private renderCustomFormFields(): JSX.Element {
|
||||
const formFieldFactory = {
|
||||
createBooleanInput: (name: string, label: string, required: boolean = false) =>
|
||||
this.createBooleanInput(name, label, required),
|
||||
@@ -106,7 +110,7 @@ export default abstract class ElixFormsComponentAbstract extends Component<IElix
|
||||
this.createTextAreaInput(name, label, required),
|
||||
};
|
||||
|
||||
return callback(formFieldFactory);
|
||||
return this.createCustomFormFields(formFieldFactory);
|
||||
}
|
||||
|
||||
public override render(): React.ReactElement<IElixFormsComponentProperties> {
|
||||
@@ -116,8 +120,7 @@ export default abstract class ElixFormsComponentAbstract extends Component<IElix
|
||||
environmentMessage,
|
||||
hasTeamsContext,
|
||||
userDisplayName,
|
||||
additionalFieldsJson,
|
||||
customFormFieldsConfiguration
|
||||
additionalFieldsJson
|
||||
} = this.props;
|
||||
|
||||
const queryParams = new URLSearchParams(window.location.search);
|
||||
@@ -130,7 +133,7 @@ export default abstract class ElixFormsComponentAbstract extends Component<IElix
|
||||
<form action="https://procedure.unipr.it/rwe2/ComeBackToElixAndSave" method="post" acceptCharset="ISO-8859-1">
|
||||
{this.createMandatoryFormFields(queryParams)}
|
||||
{this.createAdditionalFormFields()}
|
||||
{this.createCustomFormFields(customFormFieldsConfiguration)}
|
||||
{this.renderCustomFormFields()}
|
||||
<input type="submit" value="Submit"/>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user