* Added new condition type * Added new variables to cater to enable/disable conditionals * Adding functionality to disable the drop down control * Added ability to enable/disable to dynamic input text fields * Updated input text control to have enabled/disabled feature * Added enable/disable functionality to FixedKeyInputControl * Added enable/disable func to switch control and stanrdasied var name * Added disable functionality for file picker * Added enable/disable functionality to QUER_DYNAMIC_TEXT * Added new state and object for evaluating conditionals * Connected the output to the final source * Updating loading state on the final component * Tied fetched data to the options of dropdown component * Added declaration to make API call * Added loading state for dropdown * Updated types in reducer * Added implementation to extract API calls from the response and setting the output * Removed extra variables * Moved all calculation logic to the class component * Refactors and added comments * Added flag to store when the value fetch fails * Reduced usage of spread operators
92 lines
2.4 KiB
TypeScript
92 lines
2.4 KiB
TypeScript
import { Component } from "react";
|
|
import { ControlType } from "constants/PropertyControlConstants";
|
|
import { InputType } from "components/constants";
|
|
import {
|
|
ConditonalObject,
|
|
DynamicValues,
|
|
} from "reducers/evaluationReducers/formEvaluationReducer";
|
|
import { DropdownOption } from "components/ads/Dropdown";
|
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
abstract class BaseControl<P extends ControlProps, S = {}> extends Component<
|
|
P,
|
|
S
|
|
> {
|
|
abstract getControlType(): ControlType;
|
|
}
|
|
|
|
export type ComparisonOperations =
|
|
| "EQUALS"
|
|
| "NOT_EQUALS"
|
|
| "LESSER"
|
|
| "GREATER"
|
|
| "IN"
|
|
| "NOT_IN";
|
|
|
|
export type HiddenType = boolean | Condition | ConditionObject;
|
|
|
|
export type ConditionObject = { conditionType: string; conditions: Conditions };
|
|
|
|
export type Condition = {
|
|
path: string;
|
|
comparison: ComparisonOperations;
|
|
value: any;
|
|
};
|
|
|
|
export type Conditions = Array<Condition> | ConditionObject;
|
|
export interface ControlBuilder<T extends ControlProps> {
|
|
buildPropertyControl(controlProps: T): JSX.Element;
|
|
}
|
|
|
|
export interface ControlProps extends ControlData, ControlFunctions {
|
|
key?: string;
|
|
extraData?: ControlData[];
|
|
formName: string;
|
|
}
|
|
|
|
export interface ControlData {
|
|
id: string;
|
|
label: string;
|
|
displayType?: "UI" | "JSON"; //used for switch to JSON view
|
|
tooltipText?: string;
|
|
configProperty: string;
|
|
controlType: ControlType;
|
|
propertyValue?: any;
|
|
isValid: boolean;
|
|
validationMessage?: string;
|
|
validationRegex?: string;
|
|
dataType?: InputType;
|
|
initialValue?: string | boolean | number;
|
|
info?: string; //helper text
|
|
isRequired?: boolean;
|
|
conditionals?: ConditonalObject; // Object that contains the conditionals config
|
|
hidden?: HiddenType;
|
|
placeholderText?: string;
|
|
schema?: any;
|
|
errorText?: string;
|
|
showError?: boolean;
|
|
encrypted?: boolean;
|
|
subtitle?: string;
|
|
url?: string;
|
|
urlText?: string;
|
|
logicalTypes?: string[];
|
|
comparisonTypes?: string[];
|
|
nestedLevels?: number;
|
|
customStyles?: any;
|
|
propertyName?: string;
|
|
identifier?: string;
|
|
sectionName?: string;
|
|
disabled?: boolean;
|
|
dynamicFetchedValues?: DynamicValues; // Object that holds the output of the dynamic fetched values
|
|
}
|
|
export type FormConfig = Omit<ControlData, "configProperty"> & {
|
|
configProperty?: string;
|
|
children?: FormConfig[];
|
|
options?: DropdownOption[];
|
|
};
|
|
|
|
export interface ControlFunctions {
|
|
onPropertyChange?: (propertyName: string, propertyValue: string) => void;
|
|
}
|
|
|
|
export default BaseControl;
|