import { EventEmitter, InitModelOf, LifecycleEventMap, LifecycleModel, ObjectWithType, Session, SomeRequired, Status, Widget } from '../index'; /** * Abstract base class for validation lifecycles as used for forms. * A subclass must set the properties, in order to display messages: * - emptyMandatoryElementsTextKey * - invalidElementsErrorTextKey * - invalidElementsWarningTextKey * - saveChangesQuestionTextKey */ export declare abstract class Lifecycle extends EventEmitter implements LifecycleModel, ObjectWithType { model: LifecycleModel; initModel: SomeRequired; eventMap: LifecycleEventMap; self: Lifecycle; objectType: string; widget: Widget; emptyMandatoryElementsTextKey: string; emptyMandatoryElementsText: string; invalidElementsErrorTextKey: string; invalidElementsErrorText: string; invalidElementsWarningTextKey: string; invalidElementsWarningText: string; saveChangesQuestionTextKey: string; askIfNeedSave: boolean; askIfNeedSaveText: string; handlers: Record JQuery.Promise>; constructor(); init(model: InitModelOf): void; load(): JQuery.Promise; protected _load(): JQuery.Promise; protected _defaultLoad(): JQuery.Promise; ok(): JQuery.Promise; cancel(): JQuery.Promise; protected _showYesNoCancelMessageBox(message: string, yesAction: () => JQuery.Promise, noAction: () => JQuery.Promise): JQuery.Promise; reset(): JQuery.Promise; close(): JQuery.Promise; protected _close(): JQuery.Promise; save(): JQuery.Promise; protected _reset(): void; protected _save(): JQuery.Promise; protected _defaultSave(): JQuery.Promise; markAsSaved(): void; /** * Override this function to check if any data has changed and saving is required. */ saveNeeded(): boolean; setAskIfNeedSave(askIfNeedSave: boolean): void; protected _validateAndHandle(): JQuery.Promise; protected _handleInvalid(status: Status): JQuery.Promise; /** * @returns a promise resolved with the validation result as {@link Status}. */ validate(): JQuery.Promise; protected _validate(): JQuery.Promise; /** * Validates all elements (i.e. form-fields) covered by the lifecycle and checks for missing or invalid elements. */ protected _validateElements(): Status; protected _revealInvalidElement(invalidElement: TValidationResult): void; /** * Validates the widget (i.e. form) associated with this lifecycle. This function is only called when there are * no missing or invalid elements. It is used to implement an overall-validate logic which has nothing to do * with a specific element or field. For instance, you could validate if an internal member variable of a Lifecycle * or Form is set. */ protected _validateWidget(): Status | JQuery.Promise; /** * Override this function to check for invalid elements on the parent which prevent saving of the parent (e.g. check if all mandatory elements contain a value). */ protected invalidElements(): { missingElements: TValidationResult[]; invalidElements: TValidationResult[]; }; /** * Creates an HTML message used to display missing and invalid fields in a message box. */ protected _createInvalidElementsMessageHtml(missing: TValidationResult[], invalid: TValidationResult[]): string; /** * Override this function to retrieve the text of an invalid element */ protected _invalidElementText(element: TValidationResult): string; protected _invalidElementErrorText(element: TValidationResult): string; protected _invalidElementWarningText(element: TValidationResult): string; /** * Override this function to retrieve the text of a missing mandatory element */ protected _missingElementText(element: TValidationResult): string; session(): Session; /** * Register a handler function for save actions. * All handler functions must return a Status. In case of an error a Status object with severity error must be returned. * Note: in contrast to events, handlers can control the flow of the lifecycle. They also have a return value where events have none. * Only one handler can be registered for each type. */ handle(type: 'load' | 'save', func: () => JQuery.Promise): void; } //# sourceMappingURL=Lifecycle.d.ts.map