/** Core */ import { Framework } from "cmf.core/src/core"; /** Angular */ import * as ng from "@angular/core"; import * as ngRouter from "@angular/router"; /** * Injection token that can be used by a component that wishes to use the FolderExplorer directly. */ export declare const SPECIALIZED_FOLDER_EXPLORER_SERVICE: ng.InjectionToken; /** * This interface exposes the Folder Explorer service behavior. * Classes should implement this interface and be injected into the Folder Explorer component. * * The service can be used in an eager-load manner as well as a lazy load. * The loadRoot method kick starts the process. * In an eager load strategy, it's expected that the complete structure is loaded by the loadRoot. * The loadRoot method should therefore load the data and organize it in a hierarchy manner, following the FolderNode interface. * If the strategy is lazy-load, then the the loadRoot's job is to load the root Folder node. * From there on, it's expected that the loading process is progressive and * on each node click (other than a leaf node), * the onFolderSelected method will be called to collect the child folder nodes of the activated node */ export interface FolderExplorerServiceDef { /** * This is a setting that will tell the FolderExplorer that there is a single root for the folder structure being considered. * This avoids having a single root level collapsed and therefore always having to pass though it first to see its children. * If there is only one root like in this service, then this visual symptom can be avoided. */ isSingleRoot: boolean; /** * What actions are available to each folder. * The actions can be enabled or disabled according to business logic that may be responsibility * of an implementing service, and/or the component that uses the FolderExplorer. For instance, * one may need to load different info that isn't related * with folders to understand if it's possible to execute one action. * */ folderActions: Map; /** * An event that can be used to notify the FolderExplorer to reset */ resetFolderExplorer?: ng.EventEmitter; /** * This method allows for any configuration that may be required to start the service. * * @param {any} initParams that represent any parameters that may be required to bootstrap the service */ init(...initParams: any[]): any; /** * This method loads the FolderNode root structure. It's not expected that all the tree is loaded, * only the root level. But it's absolutely * fine to load the complete tree is this data is already available. * If the implementing service will load the tree in a lazy-load approach, then it's important to mark each FolderNode as * isLeaf = false and children =[] so this can give the user the visual indication that there may be a bit more to load * if a certain node is clicked. * * @returns {Promise>} that contains all the Root level FolderNodes to display */ loadRootFolders(): Promise>; /** * This method is called whenever a FolderNode is selected. If the tree is lazy-load, * this is the hook to load another level of the tree. * Elements may be appended or not. If none is found, then the FolderExplorer will convert the node into a leaf, * so no further requests are issued. * * @param {FolderNode} folder The selected FolderNode * @returns {Promise>} that will resolve to new child FolderNodes to append. */ loadFolderChildren(folder: FolderNode): Promise>; } /** * Simple interface to represent each folder node. */ export interface FolderNode { /** * Id of the node */ id: string; /** * Name of the node. This name can be transformed with HTML to better suit the folder explorer */ name: string; /** * Backup name, to safe keep the actual name of the folder. Since nodes can become leaves or roots, then this will come in handy */ backupName?: string; /** * A folder normally has a path, either a physical or some other sort of hierarchy that should be transparent to folder explorer */ path: string; /** * Icon class for the FolderNode. Consumers may provide their own icon classes to use. */ iconClass?: string; /** * This is a sort of tag. Normally there is a source object that feeds the data displayed by the folder explorer. * This property should be used to set this source object. * If associated with the FolderNode, then one can use the folder object to operate according to * the business domain the folder explorer is being used. */ folder?: Object; /** * States if the FolderNode is a leaf or not (correlates to the visual representation of the FolderNode where * we can see if the node can be drilled down). */ isLeaf?: boolean; /** * A FolderNode can have multiple FolderNode as children. */ children: Array; /** * The parent's FolderNode. As there can be children, then we can also count in a relation wih one parent. */ parent?: FolderNode; /** * When one FolderNode is drill down, the same FolderNode is represented again as a root node on a new column. * This means that a dummy FolderNode will be generated and marked as isRoot = true. */ isRoot?: boolean; } /** * Several operations can be performed on a FolderNode. Each consumer of the FolderExplorer can specify what each FolderNode can do. * This interface simply provides an organized structure for displaying the action and triggering them. */ export interface FolderAction { /** * Name of the action */ name: string; /** * Value of the action */ value: any; /** * Icon for the action */ iconClass: string; /** * If the action is enabled or not. There can be business logic that needs to run that will tell if a given FolderNode * can execute or not. This logic will be invoked * when the FolderNode is selected. */ isEnabled: boolean; /** * If there is the need to have a bottom border to separate the FolderAction of others */ isSeparator?: boolean; /** * If the action will invoke a system action, this will stamp what action to call */ actionToInvoke?: string; /** * The execute function will be called when the action is clicked. * * @param {ngRouter.Router} router Router of the component in case router navigation is required. * @param {Framework} framework Framework to perform sandbox tasks * @param {ng.ElementRef} elementRef The ElementRef of the FolderExplorer component * @param {FolderNode} folderNode The FolderNode which the FolderAction is being called upon */ execute: (router: ngRouter.Router, framework: Framework, elementRef: ng.ElementRef, folderNode: FolderNode) => void; }