/** Core */ import { CoreComponent } from "cmf.core/src/core"; /** Nested modules/services */ import { ColumnViewSelectedArgs, DropOnRowArgs } from "../columnView/columnView"; import { ColumnViewModel } from "../columnView/columnViewStructure"; import { FolderNode, FolderAction } from "./folderExplorerInterfaces"; import { PageBag } from "../page/pageBag"; /** Angular */ import * as ng from "@angular/core"; import * as ngRouter from "@angular/router"; /** * @WhatItDoes * * This component is a folder explorer using a column view instead of a tree view. * It is not bound to any data source. It relies on a service being provided that allows it * to call all the mechanics that are required. In a sense, this is a dummy component with no actual business logic, * it just triggers service requests and bridges the outputs * from the column view. * All consuming components must be aware that they need to provide a service that implements the FolderExplorerServiceDef. * * @howToUse * * This component is used with the inputs and outputs mentioned below. * * ### Inputs * `string` : **header** - The FolderExplorer has an header and this input can be used to specify what to show. * If none is provided, the header is not shown. * `string` : **allElements** - The FolderExplorer can show a link to request all Elements that (in theory) are associated with the folders. * This link triggers a request to load these elements that will be shown elsewhere. * `folderRootName`: **folderRootName** - The root name for the FolderExplorer that will be displayed on top of FolderExplorer ColumnView. * `number` : **maxColumns** - Maximum number of columns to use in the Folder Explorer * * ### Outputs * (Provide a detailed list of the outputs here. Syntax for each output description: " * type [string, number, Object...] : * name - description") Ex: * `{folderActions: Map}` : **loadAll** - When the user clicks the all items link. * The current folder actions are passed in, so consumers can configured them. * `{ folder : FolderNode, folderActions: Map}` : **folderSelect** - When the user selects a folder. * FolderNode and FolderActions are passed in. * `{ folder : FolderNode, folderActions: Map, dropEvent: any}` : **onDropOnFolder** - On drop something on a folder * * ### Example * To use the component, assume this HTML Template as an example: * * ```HTML * * ``` * * @description * * ## FolderExplorer Component * * ### Dependencies * * #### Components * * ColumnView : `cmf.core.controls` * * MoreOptionsDropdown : `cmf.core.controls` * * #### Services * _This component does not have a strong dependency on any service, however it requires one implementing the * FolderServiceDef interface to be provided by a consumer component._ * * #### Directives * _This component has no directives_ * */ export declare class FolderExplorer extends CoreComponent implements ng.OnChanges, ng.OnDestroy { private router; private pageBag; private elementRef; /** * Folder Explorer Service that is set by the consumer component */ private _folderExplorerService; /** * The underlying ColumnView component that is slightly tweaked to comply with the hierarchy nature defined for the Folder Explorer * */ private _columnView; /** * The current selected column view row */ private _selectedRow; /** * PageBag refresh event subscription */ private _refreshEventSubscription; /** * Service reset event subscription */ private _resetEventSubscription; /** * Event for the load all elements. When the all elements is clicked, this event is raised, * so consumer components can be signalled to load structures to which the folders are bound. */ loadAll: ng.EventEmitter<{ folderActions: Map; }>; /** * Event for when a FolderNode is selected. Consumer components can react to this change ad */ folderSelect: ng.EventEmitter<{ folder: FolderNode; folderActions: Map; }>; /** * Event for when something is dropped on a FolderNode */ onDropOnFolder: ng.EventEmitter<{ folder: FolderNode; folderActions: Map; dropEvent: any; }>; /** * Header input that, if defined, will display the header portion of the Folder Explorer component. * Value defined will be the text to display on the header. */ header: string; /** * All elements input that, if defined, will display the section with a link to request all elements that are bound to folders * (ex: files, queries, documents,...). * Value defined will be the link text to display */ allElements: string; /** * Name for the folder root */ folderRootName: string; /** * Maximum number of columns to use in the Folder Explorer */ maxColumns: number; /** * The ColumnView model that will be composed of FolderNodes. */ model: ColumnViewModel; /** * The ColumnView model that will be composed of FolderNodes. */ private _model; /** * List of actions that are possible for each FolderNode. This will be set by the consumer component's injected service. */ folderActions: Map; /** * The same folder actions as folderActions but only the Values */ folderActionsAsArray: Array; /** * Property to hold the text of the "GoBack" link which allows to navigate back to previous columnView column * */ goBackLink: any; /** * Just a simple flag that marks if the component is asking for all elements in the folders instead of a specific folder. */ isAllElements: boolean; /** * Simple flag that marks if the columnView is in its first column. If so, no "goBack" functionality should be available. * */ isFirstColumn: boolean; /** * Collection of FolderNodes which hierarchical nature is flattened out so they can be tracked easily whenever * FolderNodes need to be moved or removed. */ flatNodes: Array; /** * Constructor * * @param router the component's router * @param pageBag the Page's PageBag * @param elementRef the ElementRef of the component * @param viewContainerRef the reference to the component view container * @param specializedFolderExplorerService is the service that MUST be provided by a consuming component. * The FolderExplorer component has no default service, it is just a component that implements mechanics and * delegates business logic to the provided service. */ constructor(router: ngRouter.Router, pageBag: PageBag, elementRef: ng.ElementRef, viewContainerRef: ng.ViewContainerRef, specializedFolderExplorerService: Object); /** * This method resets the FolderExplorer, for instance after a ngOnChanges or a page refresh */ private resetFolderExplorer; /** * This method loads the main model to inject into the underlying ColumnView. * It will use an implementation of the FolderExplorerDef interface that dictates how the folder load should be performed. * In a nutshell the load can be eager-load * or lazy-load. It really depends on the service implementation. If the service is eager-load, * then it's expected that this call will load the complete FolderNode * tree structure. In case of a lazy-load approach, the service should load what will immediately be visible, * which in this case should be root level of folders. * From there on, on each FolderNode select, the component will call the service once again to fetch another level of folders. * The load service is expected to resolve to a list of FolderNode instances that should be organized as a tree * (use "children" property to compose relationships). * * * Additional details: * * On each level, we need to create a dummy parent so we get the following layout: * FOLDER * CHILD FOLDER 1 * CHILD FOLDER 2 * * If one folder has children, then once we navigate to that folder, * it will need to show up again in the new level like displayed above. * We will use indentation on children folders to give this sense of hierarchy, * although for ColumnView this is still at the same level. We are manipulating the * ColumnView component to apply this requirement. * */ private loadRoot; /** * This method receives a parent FolderNode and deals with creating a new level of folder, * with all indented children and dummy root FolderNode * * @param {FolderNode} folder that is the parent folder for the next level that is being created */ private prepareChildren; /** * This method creates a dummy FolderNode as a copy of the FolderNode passed by parameter. * The idea is that at each new level visited, we need to display the parent * FolderNode once again. To comply with the tree nature of how the FolderNodes and ColumnView is organized, * the best option is to create this new node to be as smooth * as possible. * * @param {FolderNode} sourceFolderNode that serves as the source of the dummy FolderNode to create. * @returns the dummy FolderNode */ private createDummyRootFolderNode; /** * Base method that serves a base HTML template for child FolderNodes so as to deliver the indentation that is required. * * @param {FolderNode} folder * @returns the HTML block with the child Folder node indented. */ private buildNodeTemplate; /** * Simply selects the root Folder Node of the current ColumnViewColumn */ private selectDummyRootFolderNode; /** * This method simply invokes the ColumnView underlying component to move back one column. */ private goBack; /** * On Header drag over */ onHeaderDragOver(event: any): void; /** * On Drop on Header */ onDropOnHeader(event: any): void; /** * On receive drop in row */ onReceiveDropInRow(args: DropOnRowArgs): void; /** * On Init Angular's life cycle hook that is used to kick start the Folder Explorer. */ ngOnChanges(): Promise; /** * On Destroy Angular's life cycle hook that only unsubscribes from the refresh event. */ ngOnDestroy(): void; /** * Event handler for when the LoadAll elements link is clicked. * An loadAll event is raised so consumer components can react to this change with the objective of loading all items * that are bound to the folders. */ onLoadAll(): void; /** * Event handler for when a FolderNode is selected but prior to its effective selection in the ColumnView. * The before hook is important for when we are lazy loading a node. We may need to call a service * that may return no items and therefore we need to cancel * the ColumnView navigation. In other words, a node becomes a leaf. * * @param {ColumnViewSelectedArgs} args with the selected ColumnView row. */ onBeforeSelected(args: ColumnViewSelectedArgs): void; /** * Event handler for when the "goBack" link is clicked. * * @param {Event} event for the "goBack" link click */ onBack(event: Event): void; } export declare class FolderExplorerModule { }