import * as _angular_core from '@angular/core'; import { Type, OnDestroy, AfterViewInit } from '@angular/core'; import { YuvEvent, YuvUser, HttpOptions, ObjectFormGroup } from '@yuuvis/client-core'; import { Observable } from 'rxjs'; interface IObjectForm { getFormData(): void; setFormPristine(): void; resetForm(): void; } /** * Interface for providing components, that render an model based form. */ interface ObjectFormOptions { /** * The form model holding all groups and elements */ formModel: any; /** * Data to be merged with the forms model. Usually this will be an * object of property value pairs where the properties name equals the name of * the form element. For search forms (form situation 'SEARCH') data is supposed * to be an array of SearchFilter objects, because search forms may support * range searches in some cases. */ data: Record; objectId?: string; /** * whether or not to disable the complete form */ disabled?: boolean; /** * in context of BPM forms, form scripts will also provide access to the actions * of a work item. This object is supposed to contain properties in a key value manner, * where key is the actions code and value is the WorkItemAction itself. */ actions?: any; /** * object form may also provide a collection of objects to be passed to the * form script (e.g. BPM forms provide data from attached dms objects) */ objects?: any[]; context?: { id: string; title: string; objectTypeId: string; }; } /** * event data emitted by the statusChanged callback */ interface FormStatusChangedEvent { /** * flag indicating whether or not the form is invalid * */ invalid: boolean; /** * flag indicating whether or not the form has been edited */ dirty: boolean; /** * flag indicating whether or not the forms indexdata has been changed */ indexdataChanged: boolean; /** * the extracted data from the form */ data?: any; } type ObjectFormModelChange = { name: 'value' | 'required' | 'readonly' | 'error' | 'onrowedit' | 'onchange'; newValue: any; }; /** * Providing a plugin service and injected into form scripts */ interface FormScriptingAPI { /** * Register a new form scripting element extension */ elementExtensions: { register(extensions: FormScriptingElementExtension[]): void; }; /** * Listen to a certain type of yuuvis event ({@link YuvEventType}) * */ events: { yuuvisEventType: any; on(type: string): Observable; /** * Trigger a certain type of yuuvis event ({@link YuvEventType}) * @param type Key of the event to be triggered * @param data Some data to attach to the event */ trigger(type: string, data?: any): void; }; /** * Get the user that is currently logged in */ session: { getUser(): YuvUser; user: { get: () => YuvUser; hasRole: (role: string) => boolean; }; }; /** * Execute a requests against yuuvis backend */ http: { /** * Execute a GET request against yuuvis backend * @param uri URI the request should be sent to * @param base URI part of the service this request belongs to * @param options additional HttpOptions */ get(uri: string, base?: string, options?: HttpOptions): any; /** * Execute a POST request against yuuvis backend * @param uri URI the request should be sent to * @param data Data to be send along with the request * @param base URI part of the service this request belongs to * @param options additional HttpOptions */ post(uri: string, data: any, base?: string, options?: HttpOptions): any; /** * Execute a DELETE request against yuuvis backend * @param uri URI the request should be sent to * @param base URI part of the service this request belongs to * @param options additional HttpOptions */ del(uri: string, base?: string, options?: HttpOptions): any; /** * Execute a PUT request against yuuvis backend * @param uri URI the request should be sent to * @param data Data to be send along with the request * @param base URI part of the service this request belongs to * @param options additional HttpOptions */ put(uri: string, data: any, base?: string, options?: HttpOptions): any; }; /** * Utilities */ form: { activeForms: Map; getValue(formControlName: string): any; setValue(formControlName: string, newValue: any): void; /** * Execute a change of form model * @param formControlName form control unique name | identifier * @param change object that contains name of parameter that should be changed ('value', 'required', ...) and newValue */ modelChange(formControlName: string, change: ObjectFormModelChange): void; }; storage: { getItem: (key: string) => any; setItem: (key: string, value: unknown) => any; }; notifier: { /** * Trigger a SUCCESS notification * @param text Message to be 'toasted' * @param title Title */ success(text: string, title: string): void; /** * Trigger a ERROR notification * @param text Message to be 'toasted' * @param title Title */ error(text: string, title: string): void; /** * Trigger a INFO notification * @param text Message to be 'toasted' * @param title Title */ info(text: string, title: string): void; /** * Trigger a WARNING notification * @param text Message to be 'toasted' * @param title Title */ warning(text: string, title: string): void; }; /** * Utilities */ util: { translate: (key: string, data?: any) => string; }; } interface FormScriptingElementExtension { id: string; icon?: string; label?: string; propertyName: string; callback: () => void; } interface IObjectFormElementExtension { property: string; cmp: Type; } interface IObjectFormElementExtensionComponentInput { formControlName: string; } /** * Class to extend by form element extensions. */ declare abstract class ObjectFormElementExtension { #private; input: _angular_core.InputSignal; protected getApi(): FormScriptingAPI; protected getCurrentValue(): unknown; setValue(value: unknown): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } declare class ObjectFormComponent implements OnDestroy, AfterViewInit { #private; gCount: number; id: string; fo?: ObjectFormOptions; formOptions: _angular_core.InputSignal; inert: _angular_core.InputSignal; readonly: _angular_core.InputSignal; elementExtensions: _angular_core.InputSignal; /** * There are special scenarios where forms are within a form themselves. * Setting this property to true, will handle the current form in a * slightly different way when it comes to form scripting. */ isInnerTableForm: _angular_core.InputSignal; /** * triggered when the forms state has been changed */ statusChanged: _angular_core.OutputEmitterRef; /** * handler to be executed after the form has been set up */ onFormReady: _angular_core.OutputEmitterRef; form?: ObjectFormGroup; formData: any; constructor(); focusForm(): void; getGroup(id: string): ObjectFormGroup; setFormData(data: Record): void; patchValue(data: Record): void; /** * Extracts the values from the form model. Each form value is represented by one * property on the result object holding the fields value. The keys (properties) are the `name` * properties of the form element. * * How values are extracted is influenced by the forms situation. * * @return object of key value pairs */ getFormData(): {}; getFormElements(): any; setFormPristine(): void; resetForm(): void; /** * Returns the observed model that was passed to the current form script running. If there is * no form script, this method will return NULL. * @returns */ getObservedScriptModel(): any; initValidators(form: any): void; ngOnDestroy(): void; ngAfterViewInit(): void; private unsubscribeAll; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } declare class YuvObjectFormModule { static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵmod: _angular_core.ɵɵNgModuleDeclaration; static ɵinj: _angular_core.ɵɵInjectorDeclaration; } export { ObjectFormComponent, ObjectFormElementExtension, YuvObjectFormModule }; export type { FormStatusChangedEvent, IObjectForm, IObjectFormElementExtension, IObjectFormElementExtensionComponentInput, ObjectFormModelChange, ObjectFormOptions };