/** Core */ import { CoreComponent } from "cmf.core/src/core"; import Cmf from "cmf.lbos"; /** Angular */ import * as ng from "@angular/core"; import * as ngRouter from "@angular/router"; /** Nested components */ import { DataGridBusinessColumn, SelectionMode } from "../dataGrid/dataGrid"; import { DataGridColumn } from "cmf.core.controls/src/components/dataGrid/dataGrid"; import { DialogButtonCallbackArgs } from "cmf.core/src/domain/extensions/dialog"; import { ModalViewInstance } from "cmf.core.controls/src/components/modalView/modalView"; import { ActionButtonBuildContextHandler } from "cmf.core/src/domain/metadata/action"; /** * AttachmentsData Interface */ export interface AttachmentsData { name: string; type: string; description: string; source: string; fileFormat: string; size: string; date: string; id: string; isOpenSupported: boolean; } /** * @whatItDoes * * EntityAttachments component is used to add the functionality of any entity to have its own associated attachments. * The attachments can be files or Urls. * * @howToUse * * This component is used with the input of its own instance. * * ### Inputs: * * `any` : **instance** - The Entity instance used to populate the EntityAttachments component. * * `boolean` : **showActionBar** - Defines if the attachments action bar is visible * * `boolean` : **showAdd** - Defines if the add buttom is visible * * `boolean` : **showDelete** - Defines if the attachments delete buttom is visible * * `boolean` : **showOpen** - Defines if the attachments open buttom is visible * * `boolean` : **showView** - Defines if the attachments view button is visible * * `boolean` : **showDownload** - Defines if the attachments download buttom is visible * * `boolean` : **allowFilters** - Defines if user can filter grid * * `boolean` : **allowOpen** - Defines if user can open attachments directly from grid * * `boolean` : **allowView** - Defines if user can view attachments directly from grid * * `integer` : **defaultPageSize** - Define the default page size of the attachments grid * * `boolean` : **allowMultiselection** - Defines if user has multiselection on attachments grid * * ### Outputs: * * ### Example * To use the component assume this HTML template as an example: * * ```html * * * ``` * * * @description * * ## EntityAttachments Component * * ### Dependencies * * #### Components * * ActionBarModule : `cmf.core.controls` * * ActionButtonModule : `cmf.core.controls` * * SearchBoxModule : `cmf.core.controls` * * SelectListModule : `cmf.core.controls` * * DropdownModule : `cmf.core.controls` * * DialogModule : `cmf.core.controls` * * DataGridColumn : `cmf.core.controls` * * ModalViewModule : `cmf.core.controls` * * #### Services * * _This component does not depend on any service_ * * #### Directives * _This component does not depend on any directive_ * */ export declare class EntityAttachments extends CoreComponent implements ng.OnInit, ng.OnChanges, ng.AfterViewChecked, ng.OnDestroy { private _modalViewInstance; private _elementRef; private cdr; private _router; /** * Used to handle attachments download */ private _util; /** * Data for Content type generic table */ contentTypeTableArray: Array; /** * Source DropBox items */ dropDownSourceItems: Array; /** * Entity instance */ instance: Cmf.Foundation.BusinessObjects.Entity; /** * Defines if the attachments action bar is visible */ showActionBar: boolean; /** * Defines if the add buttom is visible */ showAdd: boolean; /** * Defines if the delete buttom is visible */ showDelete: boolean; /** * Defines if the open buttom is visible */ showOpen: boolean; /** * Defines if the view button is visible */ showView: boolean; /** * Defines if the download buttom is visible */ showDownload: boolean; /** * Define the default page size of the attachments grid */ defaultPageSize: number; /** * Defines if user has multiselection on attachments grid */ allowMultiselection: boolean; /** * Defines if user can filter grid */ allowFilters: boolean; /** * Defines if user can open attachments directly from grid */ allowOpen: boolean; /** * Defines if user can view attachments directly from grid */ allowView: boolean; /** * Variable to define if the Entity has attachments */ hasAttachments: boolean; /** * Raw data that will be used to populate the dataGrid. Its content will be used to store the raw data information from the service. * After, this raw data will be transformed into a more convenient type (AttachmentsData type) */ data: Array; /** * DataGrid columns existing in the DataGrid inner component. */ columns: DataGridBusinessColumn[]; /** * The user selected items in the DataGrid component. */ selectedItems: AttachmentsData[]; /** * Selection mode of the data grid. This value is one of DataGrid inputs and defines its selection mode, in this case, multiple selection. */ _selectionMode: SelectionMode; /** * Search Box input fragment. It corresponds to the users input on the search box, used as a fragment to trigger the searching. */ _nameFragment: string; /** * Entity Attachments in server type */ entityAttachments: Cmf.Foundation.BusinessObjects.EntityDocumentationCollection; /** * Icons of the action bar */ _iconDisplayFilters: Array; /** * filtered entity attachments filtered by the search box */ _filteredAttachments: Array; /** * Filter used in the search box */ nameFilter: string; /** * Source Filter used in the search box */ sourceFilter: string; /** * Type Filter used in the search box */ typeFilter: string; /** * Type of Attachment to show in the SelectDropdownModule */ _typeOfAttachmentsToShow: Array; /** * Enums with "all items" element in the Type drop box */ allItemsElement: string; /** * Open action button state */ openDisabled: boolean; /** * View action button state */ viewDisabled: boolean; /** * Download action button state */ downloadDisabled: boolean; /** * Delete action button state */ deleteDisabled: boolean; /** * Gets or sets if the dropzone class is ative or not. */ _isDropZoneActive: boolean; /** * Kendo data grid source */ private _dataGridDataSource; /** * DataGrid Columns */ private _dataGridColumns; /** * Subscribed nodes that will be used for event unsubscription in order to avoid leaks */ private _subscribedNodes; /** * Selected Items Change Event emitter on the dataGrid Fix the Any */ private selectedItemsChange; constructor(_modalViewInstance: ModalViewInstance, _elementRef: ng.ElementRef, cdr: ng.ChangeDetectorRef, _router: ngRouter.Router); /** * OnInit Angular function */ ngOnInit(): void; /** * When action is evaluated and requires context */ onBuildContextHandlerForWizard: ActionButtonBuildContextHandler; /** * File select handler drop * * @param event */ fileSelectHandler(event: any): void; /** * Drag Hover event used to stop propagation and set style of drop zone * @param event Mouse event */ fileDragHover(event: MouseEvent): void; /** * On delete attachment(s). The attachments selected by the user are deleted, calling the appropriate service. * @param event any */ onDelete(event: any, args: DialogButtonCallbackArgs): Promise; /** * When open is clicked, open the attachment in a new tab */ onOpen(): void; /** * When view is clicked, view the attachment in a modal popup. */ onView(): void; /** * Verifies if the button the attachment can be open * * @memberof EntityAttachments */ checkOnOpen(): void; /** * Verifies if the view button of the attachment can be open * * @memberof EntityAttachments */ checkOnView(): void; /** * Handler for selected items changes in the DataGrid * @param items AttachmentsData[] */ selectedItemsChanged(items: AttachmentsData[]): void; /** * Make server request to fetch entity's attachments. * Also Fetch\Update the Content Type Data Array */ private getEntityAttachments; /** * Conversion of the entity attachments from the server response (server format) into the component attachments format, to put on data grid content * @param entityDocumentationArray Cmf.Foundation.BusinessObjects.EntityDocumentationCollection */ private entityAttachmentsInit; /** * Initialization of the DataGrid columns names */ private dataGridColumnsInit; /** * Property _dataGridColumns getter. */ /** * Property _dataGridColumns setter. */ dataGridColumns: Array; /** * User's text typing event on the search box * @param userInputEvent string */ searchByName(userInputEvent: string): void; /** * AfterViewChecked Angular method */ ngAfterViewChecked(): void; ngOnDestroy(): void; onAdd(): void; /** * On Source Item filter is changed by the user on the drop box * @param event */ onSourceSelect(event: any): void; /** * On Source Item filter is changed by the user on the drop box * @param event */ onTypeSelect(event: any): void; /** * On DataGrid ready subscribe custom column click */ onDataGridReady(): void; /** * Filter the attachments by the user's input. * The filtering will be used by all filters available : name, source and type. * @param event users input text */ filterAttachments(): void; /** * On changes Angular method */ ngOnChanges(changes: any): void; /** * Download selected attachments * @param event */ onDownload(event: any): void; /** * Check if browser supports mime type so that we can open file directly on browser * @param mimeType mime type */ private mimeCheck; /** * Check if open action is supported on entityDocumentation. * * @param entityDocumentation EntityDocumentation where check will * be made if attachment can be open * * @returns A promise that is fulfilled to "true" if the open * action is supported for the given EntityDocumentation, "false" * otherwise. */ private checkIfOpenIsSupported; /** * Check if view action is supported on entityDocumentation * * @param entityDocumentation EntityDocumentation where check will * be made if attachment can be viewed * * @returns A Promise that is fulfilled to "true" if the view * action is supported for the given EntityDocumentation, "false" * otherwise. */ private checkIfViewIsSupported; /** * Set enable\disable open, download and delete buttom */ private setDisabledActions; /** * Refresh the Attachments from a new server request and the components selected items in the DataGrid */ private refreshAttachments; /** * Retrieves the attachments that were selected by the user. * * @private * @returns {Cmf.Foundation.BusinessObjects.EntityDocumentation[]} * @memberof EntityAttachments */ private getSelectedAttachments; /** * Checks of the attachment is external storage. * * @private * @param {Cmf.Foundation.BusinessObjects.EntityDocumentation} attachment * @returns {boolean} * @memberof EntityAttachments */ private isExternalStorage; } export declare class EntityAttachmentsModule { }