@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
36 lines (35 loc) • 1.59 kB
TypeScript
/**
* A base class for all form models.
*/
export declare abstract class BaseFormData<TDataModel> {
protected dataModel: TDataModel;
/**
* Initializes a new instance of the form data from a given data model.
*
* @param dataModel - The data model used as a base to create the form model.
* @param initializeModelFromChildren - Whether would like to call initializeFromModel() manually from classes that extends this class.
* This is a required value, can only be true or false, if not passed in, the design is to throw an error.
* Noticed that after ES2022, in the Angular upgrade, there is breaking changes that we need to call initializeFromModel() manually.
* Or we manually add 'declare' to each of the properties in the classes that extends this class.
*
*/
constructor(dataModel: TDataModel, initializeModelFromChildren: boolean);
/**
* Creates a new TDataModel object with the data from the original data model and
* the data from this form model.
*
* @returns The model from the given form data.
*/
abstract convertToModel(): TDataModel;
/**
* Updates the values of the target model with those values from this form.
*
* @param target - The target model to update.
*/
abstract applyUpdatesToModel(target: TDataModel): void;
/**
* Initializes the form data from the model passed to the constructor.
* This is called during the constructor of the base class.
*/
protected abstract initializeFromModel(): void;
}