UNPKG

@eclipse-scout/core

Version:
72 lines 3.73 kB
/// <reference types="jquery" /> import { InitModelOf, ObjectModel, ObjectOrModel, Permission, PermissionLevel, PropertyChangeEvent, PropertyEventEmitter, PropertyEventMap } from '../index'; export declare class PermissionCollection extends PropertyEventEmitter implements PermissionCollectionModel { self: PermissionCollection; model: PermissionCollectionModel; initModel: PermissionCollectionModel; eventMap: PermissionCollectionEventMap; permissions: PermissionMap; type: PermissionCollectionType; constructor(); init(model: InitModelOf<this>): void; setPermissions(permissions: PermissionModelMapModel): void; protected _setPermissions(permissions: PermissionModelMapModel): void; setType(type: PermissionCollectionType): void; protected _setType(type: PermissionCollectionType): void; /** * Check if the given {@link Permission} is implied (see {@link PermissionCollectionType}). * Quick implies is executed synchronously while non-quick implies is executed asynchronously. */ implies(permission: Permission, quick: true): boolean; implies(permission: Permission, quick?: false): JQuery.Promise<boolean>; implies(permission: Permission, quick?: boolean): boolean | JQuery.Promise<boolean>; /** * Returns the granted {@link PermissionLevel} for a given permission instance `permission`. * - {@link Permission.Level.UNDEFINED} if `permission` is `null` or in general 'not an {@link Permission}' * - {@link Permission.Level.NONE} if no level at all is granted to `permission` * - {@link PermissionLevel} if the level can be determined exactly. * - {@link Permission.Level.UNDEFINED} if there are multiple granted permission levels possible and there is not enough data in the `permission` contained to determine the result closer. */ getGrantedPermissionLevel(permission: Permission): PermissionLevel; /** * Ensures that the given `permissionCollection` is of type {@link PermissionCollection}. If a model is provided, a new {@link PermissionCollection} will be created. */ static ensure<T extends PermissionCollection = PermissionCollection>(permissionCollection: ObjectOrModel<T>): T; /** * Ensures that the given `permissionModelMapModel` is of type {@link PermissionMap}. * * @param permissionModelMapModel map/object of {@link Permission}s or their model grouped by `id`. */ protected static _ensurePermissionMap(permissionModelMapModel: PermissionModelMapModel): PermissionMap; } export interface PermissionCollectionModel extends ObjectModel<PermissionCollection> { /** * {@link Permission}s grouped by `id`. */ permissions?: PermissionModelMapModel; /** * The type of the {@link PermissionCollection} (see {@link PermissionCollectionType}). */ type?: PermissionCollectionType; } export type PermissionMap = Map<string, Set<Permission>>; export type PermissionModelMapModel = Map<string, Set<ObjectOrModel<Permission>> | ObjectOrModel<Permission>[]> | Record<string, Set<ObjectOrModel<Permission>> | ObjectOrModel<Permission>[]>; export interface PermissionCollectionEventMap extends PropertyEventMap { 'propertyChange:permissions': PropertyChangeEvent<PermissionMap>; 'propertyChange:type': PropertyChangeEvent<PermissionCollectionType>; } export declare enum PermissionCollectionType { /** * Check if {@link Permission} is contained {@link PermissionCollection}. */ DEFAULT = "DEFAULT", /** * All {@link Permission}s are implied. */ ALL = "ALL", /** * No {@link Permission} is implied. */ NONE = "NONE" } //# sourceMappingURL=PermissionCollection.d.ts.map