/// /** Angular 2 */ import * as ng from "@angular/core"; import { FormGroup } from '@angular/forms'; /** Core */ import { CoreComponent, EventArgs } from "cmf.core/src/core"; import { OnValidateArgs, OnValidate } from "cmf.core.controls/src/directives/validator/validator"; import { Cmf } from "cmf.lbos"; import { QueryService } from "./queryService"; /** kendo */ import "kendo.autocomplete"; /** * Defines the maximum number of results to get */ export declare const MAX_NUMBER_OF_RESULTS: number; /** * Find entity exclusions, used in the query */ export declare enum FindEntityExclusions { /** * Filter terminated entities */ terminated = 1, /** * Filter non terminated entities */ nonTerminated = 2, /** * Filter templates */ templates = 4, /** * Filter non templates */ nonTemplates = 8, /** * Filter effective entities */ effective = 16, /** * Filter non effective entities */ nonEffective = 32 } /** * Find entity onSelect event args */ export interface FindEntitySelectEventArgs extends EventArgs { result: Cmf.Foundation.BusinessObjects.Entity; } /** * Allows a user to search for a given entity type by a given query. * * Important note: data and query properties are mutually exclusive. * * By default fields like 'Id', 'Name', 'Description', 'Version', 'LastServiceHistoryId' are retrieved. To retrieve more fields * use the property "data-fields" to specify more. * * ## Inputs * * **disabled**: Sets the disabled property * * **entity-type**: Entity type full namespace to be used in the nested cmf-core-business-controls-navigation component * * **entity-type-id**: Entity type id to be used in the nested cmf-core-business-controls-navigation component * * **data-text-field**: Text field that will be displayed in the component when an item is selected * * `any[] | kendo.data.DataSource` **data**: Searching pool. If defined no query to the server will be made. * * **data-fields**: Additional entity fields to be retrieved by the control. * * **additionalFilters**: Additional filters * * **exclusions**: Find entity query exclusions. By default it excludes the entities of type 'terminated' and 'templates' * * **query**: User-given query to be executed. * * **search-field**: Gets or sets the used searchable field. By default it uses "Name" * * **value**: Currently selected entity type instance. This property changes when the user interacts with the component * * **valueReferenceType**: Reference Type Value if a reference type is specified, it will be used in the underline query * * **showAdditionalFields**: If additional fields appear list items * * **singleElementPreSelect** - Defines if the component should pre-select when there's only one element available. Default is 'false'; * * ## Outputs * * **valueChange**: The selected value change event, so the component can inform the upper components that the selected value has changed * * **valueStartChange**: When value starts changing (useful in case of custom queries when there is a delay to restore entity) * * ### Example * * ``` * * ``` */ export declare class FindEntity extends CoreComponent implements ng.OnChanges, ng.OnInit, ng.OnDestroy, OnValidate { private _element; private _service; /** * Parameter name to be used in the query that filters the entities */ static QUERY_PARAMETER_NAME: string; /** * Nested input error class */ private static ERROR_CLASS; /** * Fields that will be displayed first in each item (first and second line of each item), the rest of the fields will be flattened and displayed in the third row * * Example: * LIST_ITEM_HEADER_FIELDS[0] * LIST_ITEM_HEADER_FIELDS[1] * field2.key: field2.value | field3.key: field3.value | field4.key: field4.value */ private static LIST_ITEM_HEADER_FIELDS; /** * Fields that will be excluded from the selected object, when it is passed to the parent */ private static COPY_EXCLUDE_FIELDS; /** * Defines if the element is disabled to be filed */ private _disabled; /** * Internal Find Entity Id, useful for connecting with kendo ui Auto Complete dropDown. */ private _internalId; /** * EntityType reference type to be used in the nested cmf-core-business-controls-navigation component */ _referenceType: Cmf.Foundation.Common.ReferenceType; /** * Query object to be used in the lbo call. This property is defined by the component input or using the queryBuilder(). */ private _queryToExecute; /** * Entity type constructor. To be used to create instances of a specific entity type */ private entityTypeConstructor; /** * Angular form control group that wraps the component */ _form: FormGroup; /** * Kendo ui auto complete options that is used to configure the kendo web components */ private _autocompleteOptions; /** * Flag that tell if its to show the Version */ private _isShowingVersion; /** * The kendo dataSource for the current component. Must have the following structure (examples): * * dataSource: { * data: products, * schema: { * model: { * fields: { * ProductName: { type: "string" }, * UnitPrice: { type: "number" }, * UnitsInStock: { type: "number" }, * Discontinued: { type: "boolean" } * } * } * }, * pageSize: 20 * } * * dataSource: { * type: "odata", * transport: { * read: "// demos.telerik.com/kendo-ui/service/Northwind.svc/Orders" * }, * schema: { * model: { * fields: { * OrderID: { type: "number" }, * Freight: { type: "number" }, * ShipName: { type: "string" }, * OrderDate: { type: "date" }, * ShipCity: { type: "string" } * } * } * }, * pageSize: 20, * serverPaging: true, * serverFiltering: true, * serverSorting: true * } * * @property {kendo.data.DataSource} DataSource Object */ private _ds; /** * Kendo ui auto complete reference */ private _kendoAutoComplete; /** * does this control have errors */ _hasErrors: boolean; /** * If additional fields appear list items */ showAdditionalFields: boolean; /** * Clear button classes */ clearClasses: any; /** * anchor for the autocomplete */ private _autoCompleteRef; /** * Search button classes */ searchClasses: any; /** * Show/Hide progress indicator */ /** * Navigable */ navigable: boolean; /** * Entity type full namespace to be used in the nested cmf-core-business-controls-navigation component */ entityTypeName: string; /** * Entity type id to be used in the nested cmf-core-business-controls-navigation component */ entityTypeId: string; /** * Gets or sets the used searchable field. By default it uses "Name" */ querySearchableFieldName: string; /** * Component currently has a selected instance */ hasSelectedInstance: boolean; /** * Find entity query exclusions. By default it excludes the entities of type 'terminated' and 'templates' */ exclusions: FindEntityExclusions; /** * Text field that will be displayed in the component when an item is selected */ dataTextField: string; /** * Searching pool. If defined no query to the server will be made. */ data: any[] | kendo.data.DataSource; /** * Additional entity fields to be retrieved by the control. * ### Example * * ``` * * ``` */ additionalFields: string[]; /** * Additional filters */ additionalFilters: Cmf.Foundation.BusinessObjects.QueryObject.Filter[]; /** * Secondary row transformation function returning the string to be shown bellow each value */ secondaryRowTextGenerator: (entity: Cmf.Foundation.BusinessObjects.Entity) => string; /** * Determines if the present component need to have a value */ isRequired: boolean; /** * User-given query to be executed. */ query: Cmf.Foundation.BusinessObjects.QueryObject.QueryObject; /** * Currently selected entity type instance. This property changes when the user interacts with the component */ value: Cmf.Foundation.BusinessObjects.Entity | string; /** * Defines if the component should pre-select when there's only one element available. Default is 'false'; */ singleElementPreSelect: boolean; /** * Force disabled parameter */ forceDisabled: boolean; /** * Reference Type Value. * If a reference type is specified, it will be used in the underline query. * 3 Possible values will be accounted: * - EntityType ("usual" filters will be applied with the addition of the UniversalState != "effective") * - EntityDefinition (UniversalState "effective" will be excluded and Version = "0" will be included) * - EntityVersion (UniversalState "effective" will be excluded and Version > "0" will be included) * * If no reference type is defined, the component will check the actual entity type metadata. If the Entity type is "versioned", * it will apply a reference valueReferenceType = "EntityDefinition", otherwise "Entity" */ valueReferenceType: Cmf.Foundation.Common.ReferenceType; /** * Returns true if the field is disabled, either from an outside input or disabled internally */ /** * Sets the disabled Property */ disabled: boolean; /** * The selected value change event, so the component can inform the upper components that the selected value has changed */ valueChanged: ng.EventEmitter; /** * When value starts changing (useful in case of custom queries when there is a delay to restore entity) */ valueStartChange: ng.EventEmitter; /** * Builds the query parameters to be used in the query. * * @param {string} * @return {Cmf.Foundation.BusinessObjects.QueryObject.QueryParameterCollection} * @method buildQueryParameters */ static buildQueryParameters(searchTerm: string): Cmf.Foundation.BusinessObjects.QueryObject.QueryParameterCollection; constructor(_element: ng.ElementRef, _service: QueryService); /** * Handle the output generated by the service call - creates the field "fields" in each item that is a flatten string representation of all the objects fields, except the header fields * * @param {Cmf.Foundation.BusinessOrchestration.QueryManagement.OutputObjects.ExecuteQueryOutput} [output] Service call output * @return {any} Appended objects * @method _handleOutput */ private _handleOutput; /** * Internal Validation Method */ private internalValidation; /** * Toggles the visibility of the progress indicator */ toggleProgressIndicator(isVisible: boolean): void; /** * Update Kendo auto complete data source - Based on the current query */ private _updateDataSource; /** * Closes the _kendoAutoComplete instance */ private closeAutoComplete; /** * Update value - based on user input through auto-complete */ private _updateValue; /** * Set value - based on data binding */ private _setValue; /** * Compare check if given value if valid for current instance (taking in account refereceType) */ private compareValues; /** * Generates the query to be used in the input service call * * @param {Cmf.Foundation.BusinessObjects.QueryObject.QueryObject} * @method buildQuery */ protected buildQuery(): Cmf.Foundation.BusinessObjects.QueryObject.QueryObject; /** * Update combo box state */ private updateFindEntityState; /** * The Find Entity component creates by default a query that supports a parameter for name filtering. * When the user inputs text, the query is executed with the value passed from the input field. * When the used query is passed from the user, the filter parameter needs to be append. * * @param query Query to be modified * @returns Query with appended filter for Name filtering */ private updateQueryToSupportNameFiltering; /** * When the autocomplete closes - happens when the input looses focus * * @param {kendo.ui.AutoCompleteSelectEvent} [args] Kendo UI Autocomplete Select Event arguments * @method onSelect */ protected onClose(args: kendo.ui.AutoCompleteCloseEvent): void; /** * When the user selects an item from the list - selects a new entity type instance * * @param {kendo.ui.AutoCompleteSelectEvent} [args] Kendo UI Autocomplete Select Event arguments * @method onSelect */ protected onSelect(args: kendo.ui.AutoCompleteSelectEvent): void; /** * When the user clicks in the clear button - clears selection * * @param {kendo.ui.AutoComplete} [args] Kendo UI Autocomplete * @method onClearClick */ onClearClick(autocomplete: HTMLInputElement): void; /** * When the user clicks in the search button - executes search with the current text as input * * @param {kendo.ui.AutoComplete} [args] Kendo UI Autocomplete * @method onSearchClick */ onSearchClick(autocomplete: HTMLInputElement): void; /** * When the component displays the list of items - clears the selected instance * * @param {kendo.ui.AutoComplete} [args] Kendo UI Autocomplete Open Event arguments * @method onOpen Kendo UI Autocomplete */ protected onOpen(args: kendo.ui.AutoCompleteOpenEvent): void; /** * On Validate method */ onValidate(args: OnValidateArgs): Promise; /** * Resets the styling option of the validation process * * @see OnValidate interface */ reset(): Promise; /** * When the component input looses focus - validate * * @param {kendo.ui.AutoComplete} [args] Kendo UI Autocomplete Open Event arguments */ onBlur(args: Event, value: any): void; /** * When component is initiated - check if entity type name is defined */ ngOnInit(): void; /** * On component destruction - destroy kendo auto complete. */ ngOnDestroy(): void; /** * When the component changes - set query. kendo ui autocomplete options and data text field */ ngOnChanges(changes: any): void; } export declare class FindEntityModule { }