ngx-core-business
Version:
A comprehensive solution designed to streamline the development of enterprise-level Angular applications.
139 lines (138 loc) • 4.91 kB
TypeScript
import { UntypedFormGroup, AbstractControl, UntypedFormBuilder } from '@angular/forms';
import { MatDialogRef } from '@angular/material/dialog';
import { OnInit, Injector } from '@angular/core';
import { Observable } from 'rxjs';
import { DialogService } from './services/dialog.service';
import { NotificationsService } from './services/notifications.service';
import { FormBuilderHelper, FormField, FormFieldDefinition, FormFields } from './form-builder-helper';
import * as i0 from "@angular/core";
/**
* Form Component
* EDITAR Y GUARDAR
* Clase base para todos los formularios
*/
export declare class FormDialogComponent<T> implements OnInit {
protected injector: Injector;
hostCls: string;
mode: 'add' | 'edit';
data: any;
parent: any;
model: T;
modelIdProperty: string;
apiUrl: string;
dataPath: string;
fieldRequiredErrorMessageText: string;
msgSuccessfulCreateText: string;
msgSuccessfulUpdateText: string;
invalidValuesMessage: string;
/**
* FormGrup asignado al formulario
*/
formModel: UntypedFormGroup;
protected formFields: FormFields;
/**
* Si es true se usará el metodo getRawValue() obtener los valores del formulari
* caso contrario solo se usará la propiedad value.
*/
useFormRawValue: boolean;
/**
* Llamar al metodo buildFormModel al inicio.
*/
buildFormModelOnInit: boolean;
/**
* @cfg
* Definir los campos que tendrá el formulario
*/
protected fields: FormField[];
/**
* Valores iniciales del fomulario
*/
protected values: any;
protected api: any;
protected notifications: NotificationsService;
protected formBuilder: UntypedFormBuilder;
protected dialogService: DialogService;
protected fbHelper: FormBuilderHelper;
protected dialogRef: MatDialogRef<any>;
_isReady: boolean;
_isSaving: boolean;
constructor(injector: Injector, api: any, dialogRef: any, inputData: any);
createModel(): {};
/**
* Enviar datos
*/
onSubmit(): void;
isNew(): boolean;
getSaveService(model: any): Observable<any>;
showInvalidValuesMessage(): void;
/**
* Este metodo puede ser sobre escrito para manejar internamente las excepciones del servidor
*/
handleServerError(xhr: any): void;
isCreationMode(): boolean;
isEditionMode(): boolean;
ngOnInit(): void;
/**
* Hook for data loading, it is called once on ngOnInit
*/
loadDatasets(): void;
isValid(): boolean;
/**
* Este metodo retorna los campos que son enviados al servidor
*/
getPostData(): any;
/**
* Permite determinar si el campo debe incluirse en el formulario
* @param field
* @returns
*/
hasField(field: string): boolean;
/**
* Retorna el campo del formulario solicitado
* @param name
*/
getFormControl(name: string): AbstractControl | null;
getFieldProperty(fieldName: string, prop: keyof FormFieldDefinition): any;
hasError(fieldName: string, errorType: string): boolean | undefined;
isFieldRequired(fieldName: string): boolean | undefined;
hasMinLengthError(fieldName: string): boolean | undefined;
hasMaxLengthError(fieldName: string): boolean | undefined;
hasPatternError(fieldName: string): boolean | undefined;
getRequiredErrorMessage(_fieldName?: string): string;
getMinLengthErrorMessage(fieldName: string): string;
getMaxLengthErrorMessage(fieldName: string): string;
shouldShowErrorMessage(fieldName: string): boolean | null;
getFieldValue(field: string): any;
setFieldValue(field: string, value: any): void;
isFieldValid(field: string): boolean | undefined;
private buildFormModel;
defineFormModel(): void;
/**
* Permite modificar la definición original del campo antes de construir el formControl
* @param field
* @returns
*/
protected transformDefinedField(_fieldName: string, field: FormFieldDefinition): FormFieldDefinition;
/**
* Permite modificar los valores que se usarán para construir el formControl
* @param field
* @returns
*/
protected getValuesForFormModel(values: T): any;
protected updateForm(): void;
/**
* Permite modificar la definición original del campo antes de construir un formControl
* @param field
* @returns
*/
protected preProcessDefinedField(field: FormField): FormField;
setFieldDisabled(fieldName: string, disabled: boolean): void;
setStatusReady(): void;
setStatusSaving(): void;
protected __forceClose(): void;
getApiUrl(): string;
getDataPath(): string;
getCollectionUrl(): string;
static ɵfac: i0.ɵɵFactoryDeclaration<FormDialogComponent<any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<FormDialogComponent<any>, never, never, {}, {}, never, never, true, never>;
}