import { CoreComponent, EventArgs } from "cmf.core/src/core"; import * as ng from "@angular/core"; import * as ColumnViewStructure from "./columnViewStructure"; import { ColumnViewColumn, ColumnViewColumnSelectedArgs, ColumnViewColumnActionArgs, ColumnViewColumnRemoveArgs } from "./columnViewColumn"; import { ElementQuery } from "../../directives/elementQuery/elementQuery"; import { ColumnViewUtil } from "./columnViewUtil"; import { OnValidateArgs, OnValidate, ValidatorModel } from "../../directives/validator/validator"; export declare type ColumnViewSelectedArgs = ColumnViewColumnSelectedArgs; export declare type ColumnViewActionArgs = ColumnViewColumnActionArgs; export declare type ColumnViewRemoveArgs = ColumnViewColumnRemoveArgs; export { ColumnViewStructure as ColumnViewModel }; export { ColumnViewUtil }; export interface ColumnViewAddArgs extends EventArgs { /** * The column index where the add operation has been requested */ columnIndex: number; /** * The parent columnViewNode so a parent component can append its own children */ columnViewNode: ColumnViewStructure.ColumnViewNode; /** * Number of element to add on changing number of element. Only necessary when adding several */ numberOfElementsToAdd?: number; /** * This function needs to be explicitly called in order to detect the changes made by the add */ add(jumpToLast?: boolean): Promise; } export interface ColumnViewValidateArgs extends ColumnViewStructure.ColumnViewRowModel { isValid: boolean; } export interface ColumnViewHeaderButtons { showActionAdd: boolean; showActionRemove: boolean; isOrderable: boolean; showActionChangeNumberOfElements?: boolean; } /** * Header template used to add an custom action * into a column of the column view. */ export interface CustomHeaderTemplate { /** * Template that will be showed for custom action */ template: ng.TemplateRef; /** * Show custom action only on active column */ onlyOnActive: boolean; /** * Show only on last visible column */ onlyOnLastVisible: boolean; } /** * Enum to type the column view part. * If it's the columnView or leaf part */ export declare enum ColumnViewPart { ColumnView = 0, Leaf = 1 } /** * Enum of possible auto select modes. * Focus will focus and Select will select all content of target. */ export declare enum AutoSelectMode { NoSelection = 0, Focus = 1, Select = 2 } /** * Interface that setups the auto selection mode. * Receives a mode (Check AutoSelectMode) and a targetId (its a css selector) */ export interface AutoSelectInput { mode: AutoSelectMode; targetId: string; } /** * DropOnRowArgs */ export interface DropOnRowArgs { event: any; rowIndex: number; columnIndex: number; row: any; } export declare class LeafContent { } /** * @whatItDoes * The ColumnView Component displays a tree structure on a Mac OSX Finder style. * * @howToUse * This component is used with the inputs and outputs mentioned below. * * ### Inputs * `ColumnViewStructure.ColumnViewModel` : **model** - Column view model ; * `number` : **maxColumns** - Max column view columns ; * `string` : **mainTitle** - Title that is displayed in the header ; * `string` : **leafTitle** - leaf title ; * `number` : **columnViewFlexWeight** - Weight of the columnView. Flex value assuming that the leaf have the weight of 1 ; * `boolean` : **leafValidation** - If the columnView validates the selected leaf ; * `boolean` : **showColumnsHeader** - Used to control if the columns header will appear ; * `boolean` : **showActionAdd** - Used to control if the header add action will appear ; * `boolean` : **showActionRemove** - Used to control if the header remove action will appear ; * `boolean | Array` : **showHeaderByColumn** - Tells the component if there has to be an header of a column basis * and if so, what actions will be shown ; * `boolean` : **isOrderable** - Used to control if the up and down actions will appear ; * `boolean` : **showActionChangeNumberOfLines** - Used to control if the header add lines action will appear ; * `string` : **changeNumberOfElementsMessage** - Used to pass a custom message to show on dropdown of add several lines ; * `boolean` : **showOverallHeader** - Used to tell the component to show the header by default but can be used to completely hide it ; * `boolean` : **showOverallFooter** - Used to tell the component to show the footer by default but can be used to completely hide it ; * `boolean` : **multiSelection** - Controls wether the user can select multiple rows by using a checkbox ; * `CustomHeaderTemplate | Array` : **showHeaderCustomActionsByColumn** - Tells the component if there are custom actions * that will appear on each available columns . * `boolean` : **fullHeight** - Tells the component to be full height * `AutoSelectInput` : **autoSelectField** - Used to deal with auto-select/autofocus of a given input of leaf. By default do nothing. * `boolean` : **canAddDisabled** - Tells the component if new items can be added * * ### Outputs * `ColumnViewSelectedArgs` : **selected** - Triggered when an item is selected (leaf or node). $event contains the item object selected ; * `ColumnViewActionArgs` : **action** - Triggered when an action (inside of a leaf or node) is selected. $event contains the item with the action selected ; * `ColumnViewAddArgs` : **add** - Triggered when the action add (on the header) is clicked ; * `ColumnViewRemoveArgs` : **remove** - Triggered when the action remove(inside of a leaf or node) is clicked. $event contains the item that can be removed ; * `ColumnViewValidateArgs` : **validate** - Triggered when a validation to a leaf occurs ; * `ColumnViewAddArgs` : **numberOfElementsChanged** - Triggered when the action change number of lines changes ; * `null` : **allUnselected** - Triggered when no column is selected . * `DropOnRowArgs` : **onReceiveDropInRow** - When something was dropped in a row * `boolean` : **onLargeModeChanged** - When largeMode changes (true if no longer in mobile mode | false if now in mobile mode) * * ### Example * To use the component, assume this HTML Template as an example: * * ```HTML * * * *
* * * *
* ``` * * ### Code Behind * ```typescript * public myModel: Controls.ColumnViewModel = { * rootNode: { * id: "root", * name: "Parameter Groups", * children: [ * { * id: "pmg1", * name: "Parameter Group 1", * children: [ * { * id: "p1", * name: "Parameter Name 1", * value: "1" * }, * { * id: "p1", * name: "Parameter Name 2", * value: "3" * }, * { * id: "pmg12", * name: "Parameter Group 1", * children: (node: Controls.ColumnViewNode): Promise => { * return Promise.resolve( [ * { * id: "p1", * name: "Parameter Name 1", * value: "1" * }, * { * id: "p1", * name: "Parameter Name 2", * value: "3" * } * ]); * } * } * ] * }, * { * id: "pmg2", * name: "Parameter Leaf", * value: "2" * } * ] * } * }; * ``` * */ export declare class ColumnView extends CoreComponent implements ng.OnChanges, ng.OnDestroy, ng.AfterViewChecked, ng.AfterViewInit, OnValidate { private _elementRef; private _parentValidatorModel; private _validatorModel; /** * if the user is editing a leaf or not */ isEditingLeaf: boolean; /** * Column view header columns */ _headerColumns: Array; /** * Max column view columns */ private maxColumns; /** * Number of visible columns */ visibleColumns: number; /** * Whether or not new items can be added in the ColumnView */ canAddDisabled: boolean; /** * Used to control if any column was recently added */ private elementRecentlyAdded; /** * ColumnView generic methods accessor */ private _columnViewUtil; /** * The index of the array matches each columnViewColumn index. * In each index, we store if that column's selected row can be removed or not. * This can signal each columnViewColumn header if the current selected row can be removed or not. * This does not affect the other ColumnViewColumns that may be displayed if the showHeaderByColumn mode is switched on */ _selectedRows: Array<{ canRemove: boolean; selectedRowArgs: ColumnViewColumnSelectedArgs; }>; /** * Column view body element getter */ private _contentElement; private readonly contentElement; private contentRef; /** * event resize subscription */ private _columnViewSizeSubscription; /** * Leaf Element Accessor */ private leafContent; content: ng.ElementRef; private _dropdownSpinner; private _spinner; /** * The depth of the tree */ treeDepth: number; /** * If the leaf as content or not */ hasLeafContent: boolean; /** * If the user is in largeMode (columnView and leaf side-by-side) or not * If by any change somebody changes the default value from true to false, the whole * logic regarding leaf instantiation needs to be reviewed, because content projection * is currently only working because large mode is by default true on component init. */ largeMode: boolean; /** * If true, screen changed to large mode, if false, screen changed to mobile mode. */ onLargeModeChanged: ng.EventEmitter; /** * Validator of the leaf */ private _validator; /** * Used to explicitly select a consecutive set of rows, used to keep the correct order of columns */ private _rowsToSelect; /** * Column view model */ model: ColumnViewStructure.ColumnViewModel; /** * Column view columns */ columns: ColumnViewStructure.ColumnViewColumnModel[]; /** * Used to control if the up and down actions will appear */ isOrderable: boolean; /** * Used to control if the header add action will appear */ showActionAdd: boolean; /** * Used to control if the header change number of lines action will appear */ showActionChangeNumberOfLines: boolean; /** * If the columnView validates the selected leaf */ leafValidation: boolean; /** * Used to control if the header remove action will appear */ showActionRemove: boolean; /** * Used to control if the columns header will appear */ showColumnsHeader: boolean; /** * Title that is displayed in the header - it becomes the node title upon navigation */ mainTitle: string; /** * Deprecated title input */ title: string; /** * Column view selected column index */ selectedColumnIndex: number; /** * Column view selected row args - mainly used to perform row removals */ selectedRowArgs: ColumnViewColumnSelectedArgs; /** * Tells the component if there has to be an header of a column basis and if so, what actions will be shown */ showHeaderByColumn: boolean | Array; /** * Tells the component if there are custom actions that will appear on each available columns */ showHeaderCustomActionsByColumn: CustomHeaderTemplate | Array; /** * Controls wether the user can select multiple rows using a checkbox */ multiSelection: boolean; /** * leaf title */ leafTitle: string; /** * Weight of the columnView. Flex value assuming that the leaf have the weight of 1 */ columnViewFlexWeight: number; /** * Tells the component to show the header by default but can be used to completely hide it */ showOverallHeader: boolean; /** * Tells the component to show the footer by default but can be used to completely hide it */ showOverallFooter: boolean; /** * Setup auto-select input logic on add event. By default do nothing. */ autoSelectField: AutoSelectInput; /** * Event emitters */ selected: ng.EventEmitter; action: ng.EventEmitter; add: ng.EventEmitter; remove: ng.EventEmitter; order: ng.EventEmitter; beforeSelected: ng.EventEmitter; validate: ng.EventEmitter; allUnselected: ng.EventEmitter; onReceiveDropInRow: ng.EventEmitter; numberOfElementsChanged: ng.EventEmitter; /** * Child columns accessor */ childColumns: ng.QueryList; /** * Child columns accessor for ElementRef */ childColumnsElementRef: ng.QueryList; /** * Element Query Accessor */ elementQuery: ElementQuery; /** * Get the and array on column placeholders used to fill up the empty space */ readonly emptyColumns: any[]; /** * Value that appears on change number of lines dropdown */ numberOfElementsSpinner: number; /** * Minimum value of the number of lines on dropdown */ minimumOfElementsOnSpinner: number; /** * Custom message that appears on change number of lines dropdown. * By default is null */ changeNumberOfElementsMessage: string; /** * The maximum flex value of columnView or leaf. */ private maximumFlexWeight; /** * Constructor method that also manages the validator model logic * @param _elementRef Page reference * @param _parentValidatorModel the parent validator, the top element * @param _validatorModel the current validator model, the columnView and its children */ constructor(_elementRef: ng.ElementRef, _parentValidatorModel: ValidatorModel, _validatorModel: ValidatorModel); /** * When something is dropped on a row */ onDropInRow(args: any, index: number): void; /** * Just a simple verification to whether or not the header actions should shown on a column basis */ isHeaderByColumnActive(index: number): boolean; /** * Can the remove action be shown for a given index */ isRemoveOnColumnActive(index: number): boolean; /** * Can the ad action be shown for a given index */ isAddOnColumnActive(index: number): boolean; /** * Takes into account if the showHeaderByColumn mode is active, and checks the _selectedRows array for a column basis config, * otherwise just uses the selectedRowArgs */ isRemoveOnColumnDisabled(index: number): boolean; /** * Can the change number of lines action be shown for a given index */ isChangeNumberOfLinesOnColumnActive(index: number): boolean; /** * Updates/Resets the column view columns */ private handleModelChange; /** * Calculate the depth of the tree. Not considering the "function" nodes */ private calculateTreeDepth; /** * Verify if a column must be hidden or not */ isColumnHidden(columnIndex: number): boolean; /** * Verify if index is the first visible one */ isFirstVisibleColumn(columnIndex: number): boolean; /** * Verify if index is the last visible one */ isLastVisibleColumn(columnIndex: number): boolean; /** * Check if the validateRow should be executed in the current context */ private isToValidate; /** * Removes columns right to the indicated one. * @param index Index of the soon to be right most column. */ private removeDeeperNodes; /** * Center on column * @param index Column Index */ private centerOn; /** * Encapsulate add event logic */ private addEvent; dealWithInputAutoSelection(): void; /** * Angular 2 - After view init */ ngAfterViewInit(): void; /** * On component destruction - unsubscribe events. */ ngOnDestroy(): void; /** * OnChanges - handle model changes */ ngOnChanges(changes: { [key: string]: ng.SimpleChange; }): void; /** * ngAfterViewChecked - Check if any element was recently added */ ngAfterViewChecked(): void; /** * onRowSelected - update selected row/index and notify parent component */ onRowSelected(event: ColumnViewColumnSelectedArgs, column: ColumnViewStructure.ColumnViewColumnModel, index: number): void; /** * Logic to change the selected row * @param event * @param index */ changeRow(event: ColumnViewColumnSelectedArgs, index: number): any; onAction(event: ColumnViewColumnActionArgs, column: ColumnViewStructure.ColumnViewColumnModel, index: number): void; /** * On ColumnView order */ onOrder(column: ColumnViewStructure.ColumnViewItem[]): void; onRemove(event: ColumnViewColumnRemoveArgs, column: ColumnViewStructure.ColumnViewColumnModel, index: number): void; onHeaderAdd(event: Event, column: ColumnViewStructure.ColumnViewColumnModel, index: number): void; /** * Move the selected line upwards */ onArrowUpClick(event: Event, columnIndex: number): void; /** * Move the selected line downwards */ onArrowDownClick(event: Event, columnIndex: number): void; /** * Move Cursor Horizontally * @param direction Direction of the movement. (-1 <- left, +1 -> right) */ moveCursor(direction: number, isCycling?: boolean): boolean; /** * Move the selected row * @param selectedColumnIndex column index * @param oldSelectedRowIndex old row index * @param newSelectedRowIndex new row index */ private moveRow; /** * Validates a row * @param row Row that will the added the error icon if leaf invalid * @param isToIgnoreIcon should the error icon and messages be updated on validate */ private validateRow; /** * Validates the column with the given index * @param columnToValidate the column index */ private validateParentColumn; /** * Fills the columnView model warning message bag for each columnView * @param resultMessage the result messages from the onValidate * @param result the result of the validate function, if false then there can be errors to show * @param row the row to use add the messaged */ private fillWarningMessages; /** * Verify if the down arrow must be disabled (ex: last row of column) */ isDownArrowDisabled(index: number): boolean; /** * Verify if the up arrow must be disabled (ex: first row of column) */ isUpArrowDisabled(index: number): boolean; /** * Can the up and down actions be shown for a given column index */ isOrderableOnColumnActive(index: number): boolean; isChangeNumberOfLinesActive(index: number): boolean; onHeaderRemove(event: any, enabled: boolean, index: number): void; /** * Event when clicking on columnView back button */ onBackClick(event: MouseEvent, currentIndex?: number): void; /** * Check if back icon is visible according to visible columns and header mode * @param index */ isBackVisible(index: number): boolean; /** * Moves the cursor to the next element. * Opposite of @see previous. */ next(): void; /** * Moves the cursor to the previous element. * Opposite of @see next. */ previous(moveToLast?: boolean): void; /** * Moves the cursor to the previous column. */ previousColumn(): void; /** * Moves the cursor to the next column. */ nextColumn(): void; /** * Sets the cursor on the column with the index specified. * @param newSelectedIndex Index of the column to be selected. * @param focus Defines if the column will receive the focus after select */ setColumn(newSelectedIndex: number, focus?: boolean): void; /** * Moves the cursor to next available position downwards. */ down(): Promise; /** * Goes to the leaf # specified. * @param rowNumber Number of the leaf (using a depth-first search). */ goToLeaf(rowNumber: number): boolean; /** * Resets selection - both column and row */ resetSelection(): boolean; /** * Selects a specific row in a specific column * @param recvRow row index to select * @param recvColumn column index to select * @param focus * @param triggerNotification */ selectRow(recvRow: number, recvColumn: number, focus?: boolean, triggerNotification?: boolean): void; /** * Handle for the form resize event. */ private onColumnViewResize; /** * Event when clicking on leaf back button. Mobile only event */ endLeafEdition(event: MouseEvent): void; /** * Calculate the flex weight considering the current layout */ getFlexWeight(type: ColumnViewPart): number; /** * Get parent of the currently selected item */ getParentOfSelectedItem(): ColumnViewStructure.ColumnViewItem; /** * On click cancel on change number of lines dropdown, close dropdown */ onDropdownSpinnerClickCancel(event: any): void; /** * On click Ok on change number of lines dropdown, emit change if value was increased and close the dropdown */ onDropdownSpinnerClickOk(event: Event, column: ColumnViewStructure.ColumnViewColumnModel, index: number): void; /** * On opening change number of lines dropdown. */ onAddSeveralLinesSelect(event: Event, column: ColumnViewStructure.ColumnViewColumnModel, index: number): void; /** * Validate the columnView rows * @param context the context to validate * @param model the model top validate */ onValidate(context: OnValidateArgs): Promise; /** * Returns error count all the rows in the columnView * @param context the context to validate * @returns error count */ errorCount(context: OnValidateArgs): number; } export declare class ColumnViewModule { }