import { EventEmitter } from '@angular/core'; import { OnDestroy, AfterViewInit, ElementRef } from '@angular/core'; import { SelectionModel } from '@angular/cdk/collections'; import { MatTableDataSource } from '@angular/material/table'; import { Sort } from '@angular/material/sort'; import 'jquery'; import { SortOrder } from 'mel-common'; import { ListfieldComponent } from '../fields/list-field/listfield.component'; import { ListContext, ListfieldContext, PageModes, SaveRequestEvent } from '../../core/types'; import { FieldMetadata, PagePermissions } from '../../../core/types'; import { RowUI } from '../../core/rowUI'; import * as i0 from "@angular/core"; /** * Usage: With modify-permission you can click in a tablecell to edit this cell (if tablefield is editable) * with click outside the cell, you leave this cell and the cell change to viewmode * "Tab"-Key selects the next editable column in the row. At the end of the row, the first editable field * of the next row is selected or a new row ist inserted, if it was the last row. * "Shift-Tab"-Key selects the previous column in the row until the first editable column is selected * "Arrow-Down"-Key selects the same column in the row below, if exist (the row will be saved before) * "Arrow-Up"-Key selects the same column in the row above, if exist (the row will be saved before) * "Enter"-Key selects the first editable column in the next row and inserts a new row, if it was the last row * * Inputs: context : ListContext * - datasource : A MatTableDatasource of DatasourceRow * - permissions : insert-, modify-, delete-permissions * - metadata : Columnsmetadata of the entity (IColumnMetadata[]) - fieldTriggerObserver : Observes the valid fieldchanges to trigger the fieldtrigger - sortObserver : Observes the sort-requests - saveObserver : Observes the saverequests - addRowObserver : Observes the requests to add a row * Initialisation: * The constructor is provided with the alertService to display messages * * For each tablecell the mel-cell-component is used. A cell get its column-metadata, the permission and its columnindex * To receive notifications from the cell a notificationhandler (onCellNotify) is used. The cell notifies about * - key-navigation : the following Keys are supported: Arrow-Up, Arrow-Down, TAB, Shift-TAB, Enter * - dirty : the datasource-row will be dirty * toDo: If the cell knows his datasourcerow it can set itselt the row dirty * - modeChange : arrives when the cell-mode (view, edit) changes. It is used to save the row * - autocompleted : A field can be autocompleted by the cell-component without changing the datasource, because no userinput * happened. Here we can update the datasource with the autocompleted value * toDo: If the cell knows his datasourcerow it cat set itself the value * - validation : to do * * Validation: When data is loaded we assume, that all fields in the datasource are valid. * For new rows which are initialized with default-values, we assume the same. So the default values must be consistent valid. * After editing a cell (leaving the edit mode of the cell), the cell-value will be validated. * If the cell was invalid a message is displayed in the field. * If the cell becomes valid, the message becomes empty * Only a valid row can be saved * */ export declare class ListComponent implements AfterViewInit, OnDestroy { constructor(); private _listContext?; private _permissions?; private mouseOverIndex?; private _parentPageMode; private optionalFieldcontext; private editableFieldIndices; fieldNames: string[]; rowSelection: SelectionModel>; selectedRowIndices: number[]; onSortAction: EventEmitter; saveRowRequest: EventEmitter; addRowRequest: EventEmitter; rowInitialized: EventEmitter>; listContext?: ListContext; set context(ctx: ListContext); _dataSource?: MatTableDataSource>; get dataSource(): MatTableDataSource>; set permissions(p: PagePermissions); rowHeight: string; tableRef: ElementRef | null; get tableElement(): HTMLTableElement | null; get permissions(): PagePermissions; set parentPagemode(mode: PageModes); get fieldMetadata(): FieldMetadata[]; get isErrorMode(): boolean; get isInsertMode(): boolean; get firstEditableColIndex(): number; get lastEditableColIndex(): number; get firstInvalidRowIndex(): number | undefined; get firstInvalidRow(): RowUI | undefined; get dirtyRows(): RowUI[]; get isDirty(): boolean; isRowDirty(i: number): boolean; getNewRowIndex(): number; setFocusToFirstInvalidCell(row: RowUI): void; /** * * @param row the row data of the current row to display * @param meta the metadata from the model of the field * @param colIndex the columnIndex in the row * @returns the merged objects row, metadata and field-context */ listfieldContext(row: RowUI, meta: FieldMetadata, colIndex: number): ListfieldContext; ngAfterViewInit(): void; ngOnDestroy(): void; /** * called, when the user clicks on the sort-arrow in the listheader * @param sort : Sort */ sortData(sort: Sort): void; shiftPressed: boolean; ctrlPressed: boolean; onKeyUp(event: KeyboardEvent): void; onKeyDown(event: KeyboardEvent): void; handleShortcut(field: ListfieldComponent, keyboardEvent: KeyboardEvent): void; onCellKeyNavigation(field: ListfieldComponent, keyboardEvent: KeyboardEvent): Promise; /** * Helpers */ private simulateMouse; private getCellAt; /** * Handles the click-event on a row. * if all cells are in VIEWmode and an editable field was clicked, this handler is called AFTER the editable has switched to editmode. * if a field is in EDITmode, this clickhandler is called BEFORE the editable-clickhandler * @param row */ onRowClick(row: RowUI, rowIndex: number): void; /** * Handels the hover-event and saves then mouseoverindex for the backgroundcolor * @param index */ onMouseover(index: number): void; /** * handels the key-events "ArrorDown", "ArrowUp", "Tab", Shift+Tab and "Enter" in editmode * @param key the name of the keyboard-key * @param currColIndex the current columnIndex */ getBackgroundColor(index: number): "" | "LightYellow" | "WhiteSmoke" | "LightGray"; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵcmp: i0.ɵɵComponentDeclaration, "mel-list", never, { "context": "context"; "_dataSource": "dataSource"; "permissions": "permissions"; "rowHeight": "rowHeight"; }, {}, never, never>; }