/** @packageDocumentation * @module Core */ import { BeEvent, IDisposable } from "@bentley/bentleyjs-core"; import { IModelConnection } from "@bentley/imodeljs-frontend"; import { Field } from "@bentley/presentation-common"; import { IFavoritePropertiesStorage } from "./FavoritePropertiesStorage"; /** * Scopes that favorite properties can be stored in. * @public */ export declare enum FavoritePropertiesScope { Global = 0, Project = 1, IModel = 2 } /** * Format: * Regular property - [{path from parent class}-]{schema name}:{class name}:{property name}. * Nested property - [{path from parent class}-]{content class schema name}:{content class name}. * Primitive property - {field name}. * @public */ export declare type PropertyFullName = string; /** * Holds the information of favorite properties ordering. * @public */ export interface FavoritePropertiesOrderInfo { parentClassName: string | undefined; name: PropertyFullName; priority: number; orderedTimestamp: Date; } /** * Properties for initializing [[FavoritePropertiesManager]] * @public */ export interface FavoritePropertiesManagerProps { /** * Implementation of a persistence layer for storing favorite properties and their order. * @public */ storage: IFavoritePropertiesStorage; } /** * The favorite property manager which lets to store favorite properties * and check if field contains favorite properties. * * @public */ export declare class FavoritePropertiesManager implements IDisposable { /** * Used in tests to avoid collisions between multiple runs using the same storage * @internal */ static FAVORITES_IDENTIFIER_PREFIX: string; /** Event raised after favorite properties have changed. */ onFavoritesChanged: BeEvent<() => void>; private _storage; private _globalProperties; private _projectProperties; private _imodelProperties; private _imodelBaseClassesByClass; /** Property order is saved only in iModel scope */ private _propertiesOrder; constructor(props: FavoritePropertiesManagerProps); dispose(): void; /** * Initialize favorite properties for the provided IModelConnection. */ initializeConnection: (imodel: IModelConnection) => Promise; /** * Function that removes order information of properties that are no longer * favorited and adds missing order information for favorited properties. */ private _adjustPropertyOrderInfos; private validateInitializedScope; private validateInitialization; /** * Adds favorite properties into a certain scope. * @param field Field that contains properties. If field contains multiple properties, all of them will be favorited. * @param projectId Project Id, if the favorite property is specific to a project, otherwise undefined. * @param imodelId iModel Id, if the favorite property is specific to a iModel, otherwise undefined. The projectId must be specified if iModelId is specified. * @deprecated */ add(field: Field, projectId?: string, imodelId?: string): Promise; /** * Adds favorite properties into a certain scope. * @param field Field that contains properties. If field contains multiple properties, all of them will be favorited. * @param imodel IModelConnection. * @param scope FavoritePropertiesScope to put the favorite properties into. * @note `initializeConnection` must be called with the `imodel` before calling this function. */ add(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise; private addWithOrder; private addWithoutOrder; /** * Removes favorite properties from scopes that there is info about. * @param field Field that contains properties. If field contains multiple properties, all of them will be un-favorited. * @param projectId Project Id to additionaly remove favorite properties from project scope, otherwise undefined. * @param imodelId iModel Id to additionaly remove favorite properties from iModel scope, otherwise undefined. The projectId must be specified if iModelId is specified. * @deprecated */ remove(field: Field, projectId?: string, imodelId?: string): Promise; /** * Removes favorite properties from a scope specified and all the more general scopes. * @param field Field that contains properties. If field contains multiple properties, all of them will be un-favorited. * @param imodel IModelConnection. * @param scope FavoritePropertiesScope to remove the favorite properties from. It also removes from more general scopes. * @note `initializeConnection` must be called with the `imodel` before calling this function. */ remove(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise; private removeWithOrdering; private removeWithoutOrdering; /** * Removes all favorite properties from a certain scope. * @param projectId Project Id, if the favorite property is specific to a project, otherwise undefined. * @param imodelId iModel Id, if the favorite property is specific to a iModel, otherwise undefined. The projectId must be specified if iModelId is specified. * @deprecated */ clear(projectId?: string, imodelId?: string): Promise; /** * Removes all favorite properties from a certain scope. * @param imodel IModelConnection. * @param scope FavoritePropertiesScope to remove the favorite properties from. * @note `initializeConnection` must be called with the `imodel` before calling this function. */ clear(imodel: IModelConnection, scope: FavoritePropertiesScope): Promise; private clearWithOrdering; private clearWithoutOrdering; /** * Check if field contains at least one favorite property. * @param field Field that contains properties. * @param projectId Project Id, to additionally include the project favorite properties, otherwise undefined - only global favorite properties are taken into account. * @param imodelId iModel Id, to additionally include the iModel favorite properties, otherwise undefined. The projectId must be specified if iModelId is specified. * @deprecated */ has(field: Field, projectId?: string, imodelId?: string): boolean; /** * Check if field contains at least one favorite property. * @param field Field that contains properties. * @param imodel IModelConnection. * @param scope FavoritePropertiesScope to check for favorite properties. It also checks the more general scopes. * @note `initializeConnection` must be called with the `imodel` before calling this function. */ has(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): boolean; private hasWithScope; private hasDeprecated; /** * Sorts an array of fields with respect to favorite property order. * Non-favorited fields get sorted by their default priority and always have lower priority than favorited fields. * @param imodel IModelConnection. * @param fields Array of Field's that needs to be sorted. * @note `initializeConnection` must be called with the `imodel` before calling this function. */ sortFields: (imodel: IModelConnection, fields: Field[]) => Field[]; private getFieldPriority; private _getBaseClassesByClass; /** Changes field properties priorities to lower than another fields priority * @param imodel IModelConnection. * @param field Field that priority is being changed. * @param afterField Field that goes before the moved field. If undefined the moving field is changed to the highest priority (to the top). * @param visibleFields Array of fields to move the field in. * @note `initializeConnection` must be called with the `imodel` before calling this function. */ changeFieldPriority(imodel: IModelConnection, field: Field, afterField: Field | undefined, visibleFields: Field[]): Promise; } /** @internal */ export declare const getFieldInfos: (field: Field) => Set; /** @internal */ export declare const createFieldOrderInfos: (field: Field) => FavoritePropertiesOrderInfo[]; //# sourceMappingURL=FavoritePropertiesManager.d.ts.map