import { Adminizer } from "../Adminizer"; import { StorageServices } from "./Navigation"; /** * Interface `Item` describes the data that the UI will operate on * This is a common interface for all data that is linked to the catalog * This data will also be sent to crud Item * */ export interface Item { id: string | number; name: string; parentId: string | number; /** * */ childs?: Item[]; sortOrder: number; icon: string; type: string; marked?: boolean; } export type _Item_ = { [key: string]: boolean | string | number | object; }; /** * General Item structure that will be available for all elements, including groups */ export declare abstract class BaseItem { storageServices?: StorageServices; abstract readonly type: string; /** * Used for infer T * I haven't found an easier way to extract this type that goes into generic * If you know how to open PR * */ abstract adminizer: Adminizer; /** * Catalog name */ abstract readonly name: string; /** * A sign that this is a group */ abstract readonly isGroup: boolean; /** * Is it allowed or not to add an element to the root */ abstract readonly allowedRoot: boolean; /** * icon (url or id) */ abstract readonly icon: string; /** * Array of all global contexts, which will appear for all elements */ readonly actionHandlers: ActionHandler[]; /** * Adds the context menu processor */ addActionHandler(contextHandler: ActionHandler): void; /** * Adds the required fields * @param item */ _enrich(item: T): void; _find(itemId: string | number, catalogId: string, req?: ReqType): Promise; abstract find(itemId: string | number, catalogId: string, req?: ReqType): Promise; /** * Is false because default value Group is added */ abstract update(itemId: string | number, data: T, catalogId: string, req?: ReqType): Promise; /** * * @param modelId * @param data * @param catalogId * @param req */ abstract updateModelItems(modelId: string | number, data: any, catalogId: string, req?: ReqType): Promise; /** * Create catalog * @param data * @param catalogId * @param req */ abstract create(data: T, catalogId: string, req?: ReqType): Promise; /** * delete element */ abstract deleteItem(itemId: string | number, catalogId: string, req?: ReqType): Promise; /** * get add template * @param req */ abstract getAddTemplate(req: ReqType): Promise<{ type: 'component' | 'navigation.group' | 'navigation.link' | 'model' | 'model.link'; data: any; }>; /** * get edit template * @param id * @param catalogId * @param req * @param modelId */ abstract getEditTemplate(id: string | number, catalogId: string, req: ReqType, modelId?: string | number): Promise<{ type: 'component' | 'navigation.group' | 'navigation.link' | 'model' | 'model.link'; data: any; }>; _getChilds(parentId: string | number, catalogId: string, req?: ReqType): Promise; abstract getChilds(parentId: string | number, catalogId: string, req?: ReqType): Promise; abstract search(s: string, catalogId: string, req?: ReqType): Promise; } export declare abstract class AbstractGroup extends BaseItem { readonly type: string; readonly isGroup: boolean; icon: string; } export declare abstract class AbstractItem extends BaseItem { readonly isGroup: boolean; } export declare abstract class ActionHandler { /** * Three actions are possible, without configuration, configuration via pop-up, and just external action * For the first two, a handler is provided, but the third type of action simply calls the HTML in the popup; the controller will be implemented externally * */ abstract readonly type: "basic" | "external" | "link"; /** * Will be shown in the context menu section */ abstract readonly displayContext: boolean; /** * Will be shown in the toolbox section */ abstract readonly displayTool: boolean; /** * For "external" */ abstract getPopUpTemplate(req?: ReqType): Promise; /** * Only for link type */ abstract getLink(data?: any): Promise; /** * For which elements the action can be used */ readonly selectedItemTypes: string[]; /** * icon (url or id) */ abstract readonly id: string; abstract readonly icon: string; abstract readonly name: string; /** * Implementation of a method that will do something with elements. * there's really not much you can do with the context menu * @param items * @param data * @param req */ abstract handler(items: Item[], data?: any, req?: ReqType): Promise; } /** * Abstract ____ _ _____ _ _ ___ ____ / ___| / \|_ _|/ \ | | / _ \ / ___| | | / _ \ | | / _ \ | | | | | | | _ | |___ / ___ \| |/ ___ \| |__| |_| | |_| | \____/_/ \_|_/_/ \_|_____\___/ \____| */ export declare abstract class AbstractCatalog { /** * id for catalog please use id format * * */ id: string; /** * Catalog name */ abstract readonly name: string; /** * Catalog slug */ abstract readonly slug: string; /** * moving groups to the root only */ movingGroupsRootOnly: boolean; /** * Array of all global contexts, which will appear for all elements */ readonly actionHandlers: ActionHandler[]; /** * icon (url or id) */ abstract readonly icon: string; /** * List of element types */ readonly itemTypes: BaseItem[]; /** * Method for getting childs elements * if pass null as parentId this root */ getChilds(parentId: string | number, byItemType?: string, req?: ReqType): Promise; private _bindAccessRight; protected constructor(adminizer: Adminizer, items: BaseItem[]); setId(id: string): void; /** * Gettind id list method * @info This is a dummy method, please make realization in sub class */ getIdList(): Promise; getItemType(type: string): BaseItem; getGroupType(): BaseItem; additemTypes>(itemType: T): void; /** * Get an element */ find(item: Item, req?: ReqType): Promise; /** * Removing an element */ deleteItem(type: string, id: string | number, req?: ReqType): Promise; /** * Get edit template from an item type * @param item * @param id * @param req * @param modelId */ getEditTemplate(item: Item, id: string | number, req: ReqType, modelId?: string | number): Promise<{ type: "component" | "navigation.group" | "navigation.link" | "model" | "model.link"; data: any; }>; /** * Get add template from an item type * @param item * @param req */ getAddTemplate(item: Item, req: ReqType): Promise<{ type: "component" | "navigation.group" | "navigation.link" | "model" | "model.link"; data: any; }>; addActionHandler(actionHandler: ActionHandler): void; /** * Method for getting group elements * If there are several Items, then the global ones will be obtained */ getActions(items?: Item[]): ActionHandler[]; /** * Implements search and execution of a specific action handler */ handleAction(actionId: string, items?: Item[], data?: any, req?: ReqType): Promise; /** * Only For a Link action * @param actionId */ getLink(actionId: string): Promise; /** * For Extermal and actions * @param actionId * @param req */ getPopUpTemplate(actionId: string, req?: ReqType): Promise; /** * * @param data * @param req */ createItem(data: T, req?: ReqType): Promise; updateItem(id: string | number, type: string, data: T, req?: ReqType): Promise; /** * To update all items in the tree after updating the model * @param modelId * @param type * @param data * @param req */ updateModelItems(modelId: string | number, type: string, data: T, req?: ReqType): Promise; /** * Method for getting group elements */ getitemTypes(): { type: string; name: string; isGroup: boolean; allowedRoot: boolean; icon: string; actionHandlers: ActionHandler[]; }[]; search(s: string, hasExtras?: boolean, req?: ReqType): Promise; static buildTree(items: Item[]): Item[]; }