refactor: remove unneeded concrete common class
custom form fields creation logic as overridable function
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
//import * as React from 'react';
|
||||
import ElixFormsComponentAbstract from './ElixFormsComponentAbstract';
|
||||
|
||||
export default class ElixFormsComponent extends ElixFormsComponentAbstract {
|
||||
// public override createCustomFormFields(): React.ReactElement {
|
||||
// // const textTest = this.CreateTextInput("COL0018", "TEXT INPUT");
|
||||
// // const checkTest = this.CreateCheckboxInput("COL0090", "CHECKBOX INPUT", new Map<number, string>([ [1, "Option 1"], [2, "Option 2"], [3, "Option 3"] ]));
|
||||
// // const radioTest = this.CreateRadioInput("COL0091", "RADIO INPUT", new Map<number, string>([ [1, "Option 1"], [2, "Option 2"], [3, "Option 3"] ]));
|
||||
// // const boolTest = this.CreateBooleanInput("COL0092", "BOOLEAN INPUT");
|
||||
// // const textareaTest = this.CreateTextAreaInput("COL0093", "TEXTAREA INPUT");
|
||||
|
||||
// return (<></>);
|
||||
// }
|
||||
}
|
||||
|
||||
export { ElixFormsComponent as ElixFormsReact };
|
||||
@@ -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>
|
||||
|
||||
@@ -8,7 +8,6 @@ export interface IElixFormsComponentProperties {
|
||||
hasTeamsContext: boolean;
|
||||
userDisplayName: string;
|
||||
additionalFieldsJson?: string;
|
||||
customFormFieldsConfiguration?: (formFieldFactory: IElixFormsComponentCustomFormFieldFactory) => JSX.Element;
|
||||
}
|
||||
|
||||
// Additional Fields JSON Schema
|
||||
|
||||
Reference in New Issue
Block a user