UNPKG

@itwin/presentation-frontend

Version:

Frontend of iModel.js Presentation library

152 lines 7.48 kB
/** @packageDocumentation * @module Core */ import { BeEvent } from "@itwin/core-bentley"; import { IModelConnection } from "@itwin/core-frontend"; import { Field } from "@itwin/presentation-common"; import { IFavoritePropertiesStorage } from "./FavoritePropertiesStorage.js"; /** * Scopes that favorite properties can be stored in. * @public */ export declare enum FavoritePropertiesScope { Global = 0, ITwin = 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 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 Disposable { /** Event raised after favorite properties have changed. */ onFavoritesChanged: BeEvent<() => void>; readonly storage: IFavoritePropertiesStorage; private _globalProperties; private _iTwinProperties; private _imodelProperties; private _imodelBaseClassesByClass; private _imodelInitializationPromises; private _imodelInitializationHandler; /** Property order is saved only in iModel scope */ private _propertiesOrder; constructor(props: FavoritePropertiesManagerProps); [Symbol.dispose](): void; /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */ dispose(): void; /** * Initialize favorite properties for the provided IModelConnection. * @deprecated in 4.5 - will not be removed until after 2026-06-13. Initialization is performed automatically by all async methods and only needed for deprecated [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]]. */ initializeConnection: (imodel: IModelConnection) => Promise<void>; /** * Function that removes order information of properties that are no longer * favorited and adds missing order information for favorited properties. */ private _adjustPropertyOrderInfos; private isInitialized; /** * Checks if [[FavoritePropertiesManager.initializeConnection]] has been called for a given imodel. * Can be removed when [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]] are removed. */ private validateInitialization; private startConnectionInitialization; private ensureInitialized; /** * 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. */ add(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void>; /** * 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. */ remove(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void>; /** * Removes all favorite properties from a certain scope. * @param imodel IModelConnection. * @param scope FavoritePropertiesScope to remove the favorite properties from. */ clear(imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<void>; /** * 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. * @deprecated in 4.5 - will not be removed until after 2026-06-13. Use [[FavoritePropertiesManager.hasAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]]. */ has(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): 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. */ hasAsync(field: Field, imodel: IModelConnection, scope: FavoritePropertiesScope): Promise<boolean>; /** * 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. * @deprecated in 4.5 - will not be removed until after 2026-06-13. Use [[FavoritePropertiesManager.sortFieldsAsync]] instead. This method is not async, therefore it requires early initialization by calling [[FavoritePropertiesManager.initializeConnection]]. */ sortFields: (imodel: IModelConnection, fields: Field[]) => Field[]; /** * 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. */ sortFieldsAsync(imodel: IModelConnection, fields: Field[]): Promise<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. */ changeFieldPriority(imodel: IModelConnection, field: Field, afterField: Field | undefined, visibleFields: Field[]): Promise<void>; } /** @internal */ export declare const getFieldInfos: (field: Field) => Set<PropertyFullName>; /** @internal */ export declare const createFieldOrderInfos: (field: Field) => FavoritePropertiesOrderInfo[]; //# sourceMappingURL=FavoritePropertiesManager.d.ts.map