/** Core */ import { CoreComponent } from "cmf.core/src/core"; import Cmf from "cmf.lbos"; /** Nested modules */ import { PropertyOptions } from "../entityPropertiesEditor/entityPropertiesEditor"; import { ColumnViewSelectedArgs, ColumnViewHeaderButtons, ColumnViewAddArgs, ColumnViewRemoveArgs } from "cmf.core.controls/src/components/columnView/columnView"; import { ColumnViewModel } from "cmf.core.controls/src/components/columnView/columnViewStructure"; import { OnValidate, OnValidateArgs, ValidatorModel } from "cmf.core.controls/src/directives/validator/validator"; /** Services */ import { EntityRelationsService } from "../entityRelations/entityRelationsService"; /** Angular */ import * as ng from "@angular/core"; /** * Determines whether the columnView shows the Definition or Versioned Relations */ export declare enum EntityReferenceTypeMode { Definition = 0, Version = 1 } /** * @whatItDoes * * This component allows the user to add, edit and remove EntityRelations of a given EntityType * * @howToUse * * To use this, we need to pass the instance, whose relations we want to edit, and its entity and reference type * It's generally used in under the generic relations section on every entityPage * * ### Inputs * `Cmf.Foundation.BusinessObjects.Entity` : **instance** - The current instance * `Cmf.Foundation.BusinessObjects.EntityType` : **entityType** - The instance's EntityType * `EntityReferenceTypeMode` : **entityReferenceTypeMode** - The type of relations we want to see (Definition or Versioned) * `boolean`: **showSystemRelations** - Controls whether or not we want to show the system relations * `Array` : **relationsToIgnore** - A collection of relations to ignore * * ### Outputs * `ng.EventEmitter` : **currentRelationsChange** - Emits the relations as they are, compared to the original ones (Added, Updated and Removed) * `ng.EventEmitter` : **selectedEntityTypeChange** - Emits the selected entity type * * ### Example * To use the component, assume this HTML Template as an example: * * ```HTML * * * ``` * * @description * * ## EntityRelationsEdit Component * * ### Dependencies * * #### Components * * ColumnViewModule : `cmf.core.controls` * * EntityPropertiesEditorModule : `cmf.core.business.controls` * * EntityPropertyEditorModule: `cmf.core.business.controls` * * ProgressIndicatorModule: `cmf.core.controls` * * ValidatorModule: `cmf.core.controls` * * #### Services * * EntityRelationsService : `cmf.core.business.controls` * * #### Directives * _This component does not depend on any directive_ * */ export declare class EntityRelationsEdit extends CoreComponent implements ng.OnInit, OnValidate { private _viewContainerRef; private _ngZone; private _entityRelationsService; private _validatorModel; /** * Instance passed to the component */ instance: Cmf.Foundation.BusinessObjects.Entity; /** * EntityType passed to the component */ entityType: Cmf.Foundation.BusinessObjects.EntityType; /** * Determines if we want to show definition or versioned relations */ entityReferenceTypeMode: EntityReferenceTypeMode; /** * Whether or not we show the system relations */ showSystemRelations: boolean; /** * Collection of relations to ignore */ relationsToIgnore: Array; /** * EventEmitter that emits the changes on relations, per EntityType */ currentRelationsChange: ng.EventEmitter>; /** * EventEmitter that emits the currently selected EntityType */ selectedEntityTypeChange: ng.EventEmitter; /** * Column view model used to support the inner column view */ columnViewModel: ColumnViewModel; /** * Current selected entity type */ selectedEntityType: Cmf.Foundation.BusinessObjects.EntityType; /** * Current selected entity relation */ selectedRelation: Cmf.Foundation.BusinessObjects.EntityRelation; /** * Used to enable and disable add/remove accordingly to the selected node */ columnsDefinition: ColumnViewHeaderButtons[]; /** * Properties to edit */ propertiesToEdit: { [key: string]: PropertyOptions | string; }; /** * Related entity property definition */ relatedEntityProperties: PropertyOptions; /** * Relations for each type */ newRelationsForEntityType: Map; /** * Related entity reference name (Source or Target) */ relatedTypeName: string; /** * Selected columnView leaf */ private _selectedLeaf; /** * Collection of Relations */ private _columnViewRelations; /** * Current definition entityTypes collection */ private _definitionEntities; /** * Current versioned entityTypes collection */ private _versionedEntities; /** * The entity type's relations */ private _objectRelations; /** * The entity type's valid and active relations per EntityType */ private oldRelationsForEntityType; /** * The component's ColumnView */ private _columnView; /** * The column view's element reference */ private _columnViewElementRef; /** * Page settings ColumnView generic methods accessor */ private _columnViewUtil; /** * Selected column view node */ private _selectedNode; /** * Row that was selected before a service call */ private _previouslySelectedNode; /** * Constructor * * @param viewContainerRef the reference to the component view container * @param _entityRelationsService EntityRelationsService */ constructor(_viewContainerRef: ng.ViewContainerRef, _ngZone: ng.NgZone, _entityRelationsService: EntityRelationsService, _validatorModel: ValidatorModel); /** * Loads all relations related to the current instance's EntityType and EntityReference */ private loadColumnViewContent; /** * Build column view model according to given Map */ private buildColumnViewModel; /** * Gather all definition entity types */ private calculateDefinitionEntities; /** * Gather all versioned entity types */ private calculateVersionedEntities; /** * Gets all available and active relations from the given entity type (chosen from the first column) */ private updateRelationsData; /** * Updates the second column data based on the loaded relations */ private updateChildren; /** * Formats the relation's name and description to show on the second column (Relations Column) */ private generateHtmlForRelationName; /** * Chooses the collection of properties that the user can Edit */ private updatePropertiesToEdit; /** * Checks if a given property has to be included */ private isToIncludeProperty; /** * Checks if user has access to property */ private hasAccessLevel; /** * Update selected obj and leaf with column view selection * @param leaf New selected leaf */ private updateSelectedLeaf; /** * Gets and emits the current relations on the second column */ private updateNewRelations; /** * Updates the leaf name and description */ private updateLeafInformation; /** * Compares the old value with the new one to check if any change was made * @param oldValue the old entityrelation property * @param newValue the new entityrelation property */ private detectAnyChange; /** * Updates the information to send for update and the corresponding leaf information */ onRelationPropertyChange(): void; /** * On Init */ ngOnInit(): void; /** * When a leaf is selected (either entity type or relation) * @param args column view selection args */ onSelect(args: ColumnViewSelectedArgs): void; /** * Adds a new row to the column view model * @param args */ onAdd(args: ColumnViewAddArgs): void; /** * Removes row from column view model and removes the relation from the added relations list * @param args */ onRemove(args: ColumnViewRemoveArgs): void; /** * On Validate method * @param context * @param model */ onValidate(context: OnValidateArgs, model?: ValidatorModel): Promise; } export declare class EntityRelationsEditModule { }