UNPKG

@synerty/vortexjs

Version:

Custom observable data serialisation and routing based on Angular 2+

94 lines (93 loc) 3.43 kB
import { Tuple } from "../Tuple"; import { FormGroup } from "@angular/forms"; export declare abstract class TupleDataLoaderTupleABC extends Tuple { protected constructor(tupleName: string); /** * Creates a new instance of FormGroup to enable ReactiveForms validation. * * * @return {FormGroup} - The newly created FormGroup * instance, or null of formGroup validation is * not required. */ createFormGroup(): FormGroup | null; /** * Update the form group with the given changes. * * If createFormGroup returns null, this method * will never be called. * * @param {object} changes - The changes to apply to the form group. * @return {boolean} - Returns a boolean value indicating if * there were differences to update. */ updateFromFormGroup(changes: {}): boolean | null; /** * Update the validation of a form group. * * This will be called when data in the form group changes, and after those * changes have been synchronised to this data tuple. * * Updates of any kind must be made to the formGroup controls. * * Value reads may be performed on either this tuple or the formGroyp as * both values should be identical. If they arn't then there is a bug in * your updateTupleFromFormGroup call. * * Example: Disable one control based on the value of another control * being null. * * ``` * if (formGroup.get('control_1').value == null) { * formGroup.get('control_2').disable(); * } else { * formGroup.get('control_2').enable(); * } * ``` * * @param {FormGroup} formGroup - The form group to update validation for. * * @return {void} */ updateValidation(formGroup: FormGroup): void; /** * Updates the values of a FormGroup with the values from a given tuple. * * This method is unused at present. * * @param {FormGroup} formGroup - The FormGroup to be updated. * @param {any} tuple - The tuple containing the updated values. * * @return {void} */ static updateTupleToFormGroup(formGroup: FormGroup, tuple: any): void; /** * Updates the values of a tuple based on the provided changes object. * Recursively updates nested objects. * * Example: * ``` * return TupleDataLoaderTupleABC.updateTupleFromFormGroup( * changes, * this.step, * { * parameterMap: StepParameterMappingUiTuple, * links: StepGroupSubStepLinkUiTuple, * makoFileNames: null, * makoParameters: StepPushDesignFileCompiledParamUiTuple, * }, * ); * ``` * * @param changes - The changes object containing a deep stricture of the * updated values. * @param tuple - The tuple to be updated. * @param TupleTypeByFieldName - The dictionary mapping field names to * tuple types. * @return {boolean} - Returns true if any changes were found and * applied, false otherwise. * @throws {Error} - Throws an error if no TupleTypeByFieldName entry is * found for an array. */ static updateTupleFromFormGroup(changes: {}, tuple: Tuple, TupleTypeByFieldName?: {}): boolean; }