@ctodev/cclibrary-typings
Version:
Library typings for use with CLARC INFINITY
198 lines (197 loc) • 10.1 kB
TypeScript
import { Observable, OperatorFunction } from "rxjs";
import { TccODataQuery } from "../../odata/services/tcc-odata-query/tcc-odata-query";
import { TccInfinityScrollComponent } from "../components/tcc-infinity-scroll/tcc-infinity-scroll.component";
import { IExpandable, TccC4Node, TccClarcDate, TccKeyValuePair, TccPermissions, TccRole, TccTranslation } from "../../odata/models/shared.model";
import { TccErrorResponse } from "../../odata/interceptors/tcc-error-translation/tcc-error-translation.interceptor";
import { TccSnackBarService } from "../../core/services/tcc-snackbar/tcc-snackbar.service";
import { ActivatedRoute, Router } from "@angular/router";
import { MatDialogRef } from "@angular/material/dialog";
import { ValidatorFn } from "@angular/forms";
import { TccValidators } from "../models/form-error.model";
import { TccInputMask } from "../models/inputMask.model";
import { TccSearchListDialogServiceNamespace } from "../services/tcc-search-list-dialog/tcc-search-list-dialog.service";
import { TccInputMaskComponent } from "..";
import { TccODataServiceFactory } from "../../odata/factories/tcc-odata-service/tcc-odata-service.factory";
export declare namespace tccCommonFunction {
interface returnType<T> {
errors: {
[entityKey: string]: TccErrorResponse;
};
results: T[];
}
interface nodeGroup {
Key: string;
Value: string;
children: TccC4Node[];
}
}
export declare class TccCommonFunction {
static compare(a: number | string | boolean, b: number | string | boolean, isAsc: boolean): number;
/**
* creates a keyFalue list from a string[]
*/
static getTccKeyValueListFromStringArray(values: string[] | TccKeyValuePair[]): Array<TccKeyValuePair>;
/**
* deprecated use initScrolling
* @param obs
* @param Query
* @param infinityScroll
* @param length
* @returns
*/
static checkScroll<T>(obs: Observable<T[]>, Query: TccODataQuery<T>, infinityScroll: TccInfinityScrollComponent, length: number): Observable<T[]>;
static getNodeNames(Nodes: TccC4Node[], idArr: string[]): {
[id: string]: string;
};
static capitalizeString(str: string): string;
static execMultiOperation<T>(observables: {
[key: string]: Observable<T>;
}): Observable<tccCommonFunction.returnType<T>>;
/**
* @description generates a selectionList for an enum from modelTranslations
*
* @param type string z.B.: TccAnyscan_Translations
* @param enumname string z.B.: Technology
* @param enumeration enum z.B.: TccAnyscan.Technology
* @returns KeyValuePair List für SelectionBox
*/
static generateSelectionList(type: string, enumname: string, enumeration: any, inverted?: boolean): TccKeyValuePair[];
/**
* @description generates a selectionList for an enum from modelTranslations
*
* @param type string z.B.: TccAnyscan_Translations
* @param enumname string z.B.: Technology
* @param enumeration enum z.B.: TccAnyscan.Technology
* @param filterValues stringArray of values, that should be excluded z.B.: [TccAnyscan.Technology]
* @returns KeyValuePair List für SelectionBox
*/
static generateSelectionListFiltered(type: string, enumname: string, enumeration: any, filterValues: string[], inverted?: boolean): TccKeyValuePair[];
/**
* @description generates a selectionList for any enum
*
* @param {enumeration} enumeration the enumeration, that will be used to make the selection list
* @param {boolean} inverted inverts Key and Value
* @param {integer} removeFromStart removes that number of chars from the start of every value. To Remove the Constant Prefix
* @param {{start?: string, end?: string}} addString adds additional chars to the start or end of the enum value
* @returns KeyValuePair List für SelectionBox
*/
static generateSelectionListFromEnum(enumeration: any, inverted?: boolean, removeFromStart?: number, addString?: {
start?: string;
end?: string;
}, keepUnknown?: boolean): TccKeyValuePair[];
static generateSelectionListFromEnumValues(enumeration: any): TccKeyValuePair[];
private static addChars;
/**
* generates a TccKeyValue[] from a TccC4Nodes[]
* @param nodes TccC4Node[] Array of Nodes which should be selectable in Selectionbox
* @returns KeyValuePair List für SelectionBox
*/
static generateSelectionListForNodes(nodes: TccC4Node[]): TccKeyValuePair<string | TccTranslation>[];
/**
* generates a TccInputMask._SelectGroupSelection[] (select with option groups selection) from nodeGroup[]
* @param nodeGroups nodeGroup[] Array of NodeGroups which should be selectable in Selectionbox
* @returns TccInputMask._SelectGroupSelection List für SelectionBox
*/
static generateSelectionListForMultiNodes(nodeGroups: tccCommonFunction.nodeGroup[]): TccInputMask._SelectGroupSelection[];
/**
* Loads inital Data for infinityScroll. Loads until able to scroll or no more elements
* unintentionally loads one page too many
* @param query
* @param PageSize
* @param infinityScroll
* @param initCheck checks scroll even before the query is used to get data
* @returns
*/
static initScrolling<T>(query: TccODataQuery<T>, PageSize: number, infinityScroll: TccInfinityScrollComponent, callbackFunction: (entities: T[]) => Observable<T[]>, initCheck?: boolean): Observable<T[]>;
static catchError<T>(snackBar: TccSnackBarService): OperatorFunction<T, T | never>;
static checkForErrorResponse(err: any): boolean;
/**
* Creates a filter string for odataFilter. Use for search functionality, until server fullTextSearch is implemented
* @param properties all properties, in which the searchStr should be searched
* @param searchStr string, that gets searched
*/
static getSearchFilterString(properties: string[], searchStr: string): string;
/**
* @description Searches through an object, and returns the value based on the provided path
* @param obj object, in which the path should be searched
* @param path path, that gets searched
*/
static findData(obj: any, path: string[]): any;
static isValueInStringEnum<E extends string>(strEnum: Record<string, E>): (value: string) => value is E;
static primitiveToBoolean(value: string | number | boolean | null | undefined): boolean;
static isUndefinedOrNull(val: any): boolean;
static transformTccMessageItem(text: string, args?: string[]): string;
static CreateUUID(): string;
/**
* @description Sets a browser cookie
* @param name string, name of the cookie
* @param value object, value of the cookie
* @param expiration number, time until the cookie expires (miliseconds), default is 7 days if not set
*/
static setCookie(name: string, value: object, expiration?: number): void;
/**
* @description Gets a browser cookie, returns null if none is found
* @param name string, name of the cookie
*/
static getCookie(name: string): IExpandable | null;
static closeDialogOnNavigate(router: Router, dialogRef: MatDialogRef<any, any>): void;
/**
* @description Validator-Function for phonenumbers (google-libphonenumber)
* @param defaultRegion Fallback RegionCode
*/
static phoneNumberValidator(defaultRegion?: string): ValidatorFn;
static phoneValidation(): TccValidators;
/**
* @description returns the number (type number)
* @param localizedNumber number as localized string
* @param currentLocale (from localeService.currentLocale)
*/
static getNumberFromLocalized(localizedNumber: string | number, currentLocale: string): number;
/**
* @description Validator-Function for numbers (localized numbers)
* @param locale (from localeService.currLocale)
*/
static tccLocalizedNumberValidator(locale: string): ValidatorFn;
static tccLocalizedNumberValidation(locale: string): TccValidators;
/**
* list of file formats, from which viewBlobs can be created
*/
static generatableMimeTypes: string[];
/**
* @param nodes C4Nodes Array
* @returns TccKeyValuePair[] of the given C4Nodes
*/
static getKeyValueFromC4Nodes(nodes: TccC4Node[]): TccKeyValuePair[];
/**
* @param data
* @returns SelectGroupSelection for inputMask select element
*/
static getSelectGroupSelectionFromC4Nodes(data: {
Key: string;
Value: string;
Nodes: TccC4Node[];
}[]): TccInputMask._SelectGroupSelection[];
/**
* generates roles data for TccSearchListDialogElement
* @param activeRoles roles object from the entity, that should be changed
* @returns returns all active roles and all possible roles ([activeRoles, allRoles])
*/
static getRoleArraysForSearchListDialog(activeRoles: TccRole[]): [TccSearchListDialogServiceNamespace.item[], TccSearchListDialogServiceNamespace.item[]];
/**
* sets value changes from standard rights (TccSearchListDialog) in the given rights object
* @param rights rights object, where the changes shozuld be applied
* @param valueChanges the value changes
*/
static setRights(rights: TccPermissions, valueChanges: {
[type in 'roles' | 'groups' | 'user']: TccInputMask.eventOutput;
}): void;
private static setMemberRights;
private static setRoleRights;
private static readonly inputMaskPermissionsConfig;
static getInputMaskPermissionsConfig(): TccInputMask.SectionContent<any>;
static initInputMaskPermissionsElement(factory: TccODataServiceFactory, inputMask: TccInputMaskComponent, rights: TccPermissions): void;
static setSearchListPermissionsActiveItems(inputMask: TccInputMaskComponent, rights: TccPermissions): void;
static getValidity(numberOfDays: number): TccClarcDate;
static getValidityTimeString(numberOfDays: number): string;
static getDeepestRoute(route: ActivatedRoute): ActivatedRoute;
}