UNPKG

com.phloxui

Version:

PhloxUI Ng2+ Framework

1,499 lines 140 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ import * as tslib_1 from "tslib"; import { Component, ElementRef, Input, Output, EventEmitter } from '@angular/core'; import { TypeResolveService } from '../../service/TypeResolveService.service'; import { TableModel } from '.././model/models'; import { I18N, Option } from '../../decorator/decorators'; import { DataUtils } from '../../share/utils/DataUtils'; import { AbstractHasDataHelp } from '../AbstractHasDataHelp'; import { TableRowController } from './TableRowController'; import { DefaultTableRowGenerator } from './DefaultTableRowGenerator'; import { DefaultTableBody } from './DefaultTableBody.component'; import { DefaultTableRow } from './DefaultTableRow.component'; import { DefaultTableHeader } from './DefaultTableHeader.component'; import { DBL_CLICK_EVENT, CHANGE_EVENT, CLICK_EVENT, FOCUS_EVENT, LOST_FOCUS_EVENT, BEFORE_CLICK_EVENT, BEFORE_DBL_CLICK_EVENT, BEFORE_LOST_FOCUS_EVENT, BEFORE_FOCUS_EVENT, BEFORE_CHANGE_EVENT } from '../../share/CustomEventType'; import { EventUtils } from '../../share/utils/EventUtils'; var /** @type {?} */ TYPE_NAME = "phx-table"; var /** @type {?} */ DEFAULT_LOAD_STATE_DELAY = 0; var /** @type {?} */ DEFAULT_DBL_CLICK_EDIT = true; var PhloxTable = /** @class */ (function (_super) { tslib_1.__extends(PhloxTable, _super); function PhloxTable(typeService, elementRef) { var _this = _super.call(this, elementRef) || this; _this.beforeChangeEvent = new EventEmitter(); _this.changeEvent = new EventEmitter(); _this.beforeChangeEvent = new EventEmitter(); _this.beforeCellClickEvent = new EventEmitter(); _this.beforeCellDblClickEvent = new EventEmitter(); _this.beforeCellLostFocusEvent = new EventEmitter(); _this.beforeCellFocusEvent = new EventEmitter(); _this.cellClickEvent = new EventEmitter(); _this.cellDblClickEvent = new EventEmitter(); _this.cellLostFocusEvent = new EventEmitter(); _this.cellFocusEvent = new EventEmitter(); _this.rowDragEvent = new EventEmitter(); _this.rowDragStartEvent = new EventEmitter(); _this.rowDragEndEvent = new EventEmitter(); _this.rowDragEnterEvent = new EventEmitter(); _this.rowDragOverEvent = new EventEmitter(); _this.rowDragLeaveEvent = new EventEmitter(); _this.rowDropEvent = new EventEmitter(); _this.rowDropAcceptedEvent = new EventEmitter(); _this.rowDropRejectedEvent = new EventEmitter(); _this.typeResolveService = typeService; _this.model = new TableModel(typeService); _this.header = new TableRowController(_this); _this.rows = []; _this.bodyWrapperHandler = function (event) { _this.bodyComponentInstance = event.instance; if (_this.bodyComponentInstance !== null && typeof _this.bodyComponentInstance['initialize'] === 'function') { _this.bodyComponentInstance.initialize(_this); // Auto re-render when new table body was initialized // Auto re-render when new table body was initialized _this.rerender(false); } }; _this.headerWrapperHandler = function (event) { _this.headerComponentInstance = event.instance; if (_this.headerComponentInstance !== null && typeof _this.headerComponentInstance['initialize'] === 'function') { _this.headerComponentInstance.initialize(_this); } }; return _this; } /** * @return {?} */ PhloxTable.prototype.ngOnInit = /** * @return {?} */ function () { _super.prototype.ngOnInit.call(this); // Auto set default header's component type if (this.model.getHeaderModel().getComponentTypeName() === null || typeof this.model.getHeaderModel().getComponentTypeName() === 'undefined') { this.model.getHeaderModel().setComponentTypeName(DefaultTableHeader.TYPE_NAME); } // Auto set default body's component type if (this.model.getBodyComponentTypeName() === null || typeof this.model.getBodyComponentTypeName() === 'undefined') { this.model.setBodyComponentTypeName(DefaultTableBody.TYPE_NAME); } // Auto set default row's component type if (this.model.getRowModel().getComponentTypeName() === null || typeof this.model.getRowModel().getComponentTypeName() === 'undefined') { this.model.getRowModel().setComponentTypeName(DefaultTableRow.TYPE_NAME); } // Set default option values if (this.loadStateDelay === null || typeof this.loadStateDelay === 'undefined') { this.loadStateDelay = DEFAULT_LOAD_STATE_DELAY; } if (this.dblClickEdit === null || typeof this.dblClickEdit === 'undefined') { this.dblClickEdit = DEFAULT_DBL_CLICK_EDIT; } if (this.rowGenerator === null || typeof this.rowGenerator === 'undefined') { this.rowGenerator = new DefaultTableRowGenerator(); } // Auto render when table is initialized (this method also auto apply i18n into "bodyComponentInstance") this.rerender(true); }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compChangeEvent * @return {?} */ PhloxTable.prototype.emitBeforeChangeEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compChangeEvent * @return {?} */ function (rowIdx, colIdx, compChangeEvent) { if (this.beforeChangeEvent !== null && this.beforeChangeEvent !== undefined) { var /** @type {?} */ data = { oldValue: DataUtils.getDataValue('detail.data.oldValue', compChangeEvent), newValue: DataUtils.getDataValue('detail.data.newValue', compChangeEvent), rowIndex: rowIdx, columnIndex: colIdx, cellComponent: DataUtils.getDataValue('detail.target', compChangeEvent) }; var /** @type {?} */ ev = EventUtils.newCustomEvent(BEFORE_CHANGE_EVENT, this, data, compChangeEvent); this.beforeChangeEvent.emit(ev); } }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compChangeEvent * @return {?} */ PhloxTable.prototype.emitChangeEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compChangeEvent * @return {?} */ function (rowIdx, colIdx, compChangeEvent) { if (this.changeEvent !== null && this.changeEvent !== undefined) { var /** @type {?} */ data = { oldValue: DataUtils.getDataValue('detail.data.oldValue', compChangeEvent), newValue: DataUtils.getDataValue('detail.data.newValue', compChangeEvent), rowIndex: rowIdx, columnIndex: colIdx, cellComponent: DataUtils.getDataValue('detail.target', compChangeEvent) }; var /** @type {?} */ ev = EventUtils.newCustomEvent(CHANGE_EVENT, this, data, compChangeEvent); this.changeEvent.emit(ev); } }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @return {?} */ PhloxTable.prototype.emitBeforeCellClickEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @return {?} */ function (rowIdx, colIdx, browserEvent) { if (this.beforeCellClickEvent !== null && this.beforeCellClickEvent !== undefined) { var /** @type {?} */ data = { rowIndex: rowIdx, columnIndex: colIdx }; var /** @type {?} */ ev = EventUtils.newCustomEvent(BEFORE_CLICK_EVENT, this, data, browserEvent); this.beforeCellClickEvent.emit(ev); } }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @return {?} */ PhloxTable.prototype.emitCellClickEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @return {?} */ function (rowIdx, colIdx, browserEvent) { if (this.cellClickEvent !== null && this.cellClickEvent !== undefined) { var /** @type {?} */ data = { rowIndex: rowIdx, columnIndex: colIdx }; var /** @type {?} */ ev = EventUtils.newCustomEvent(CLICK_EVENT, this, data, browserEvent); this.cellClickEvent.emit(ev); } }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @return {?} */ PhloxTable.prototype.emitBeforeCellDblClickEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @return {?} */ function (rowIdx, colIdx, browserEvent) { if (this.beforeCellDblClickEvent !== null && this.beforeCellDblClickEvent !== undefined) { var /** @type {?} */ data = { rowIndex: rowIdx, columnIndex: colIdx }; var /** @type {?} */ ev = EventUtils.newCustomEvent(BEFORE_DBL_CLICK_EVENT, this, data, browserEvent); this.beforeCellDblClickEvent.emit(ev); } }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @return {?} */ PhloxTable.prototype.emitCellDblClickEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @return {?} */ function (rowIdx, colIdx, browserEvent) { if (this.cellDblClickEvent !== null && this.cellDblClickEvent !== undefined) { var /** @type {?} */ data = { rowIndex: rowIdx, columnIndex: colIdx }; var /** @type {?} */ ev = EventUtils.newCustomEvent(DBL_CLICK_EVENT, this, data, browserEvent); this.cellDblClickEvent.emit(ev); } }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @return {?} */ PhloxTable.prototype.emitBeforeCellFocusEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @return {?} */ function (rowIdx, colIdx, compFocusEvent) { if (this.beforeCellFocusEvent !== null && this.beforeCellFocusEvent !== undefined) { var /** @type {?} */ data = { rowIndex: rowIdx, columnIndex: colIdx }; var /** @type {?} */ ev = EventUtils.newCustomEvent(BEFORE_FOCUS_EVENT, this, data, compFocusEvent); this.beforeCellFocusEvent.emit(ev); } }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @return {?} */ PhloxTable.prototype.emitCellFocusEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @return {?} */ function (rowIdx, colIdx, compFocusEvent) { if (this.cellFocusEvent !== null && this.cellFocusEvent !== undefined) { var /** @type {?} */ data = { rowIndex: rowIdx, columnIndex: colIdx }; var /** @type {?} */ ev = EventUtils.newCustomEvent(FOCUS_EVENT, this, data, compFocusEvent); this.cellFocusEvent.emit(ev); } }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @return {?} */ PhloxTable.prototype.emitBeforeCellLostFocusEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @return {?} */ function (rowIdx, colIdx, compFocusEvent) { if (this.beforeCellLostFocusEvent !== null && this.beforeCellLostFocusEvent !== undefined) { var /** @type {?} */ data = { rowIndex: rowIdx, columnIndex: colIdx }; var /** @type {?} */ ev = EventUtils.newCustomEvent(BEFORE_LOST_FOCUS_EVENT, this, data, compFocusEvent); this.beforeCellLostFocusEvent.emit(ev); } }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @return {?} */ PhloxTable.prototype.emitCellLostFocusEvent = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @return {?} */ function (rowIdx, colIdx, compFocusEvent) { if (this.cellLostFocusEvent !== null && this.cellLostFocusEvent !== undefined) { var /** @type {?} */ data = { rowIndex: rowIdx, columnIndex: colIdx }; var /** @type {?} */ ev = EventUtils.newCustomEvent(LOST_FOCUS_EVENT, this, data, compFocusEvent); this.cellLostFocusEvent.emit(ev); } }; /** * @param {?} model * @return {?} */ PhloxTable.prototype.setModel = /** * @param {?} model * @return {?} */ function (model) { this.model = model; if (this.model !== null && typeof this.model !== 'undefined') { // Auto set options & auto apply i18n into this.model. if (this.options !== null && typeof this.options !== 'undefined') { this.model.setOptions(this.options['model']); } else { // Set null or undefined into the method. this.model.setOptions(this.options); } // Since @I18N() bypasses key, we directly pass i18nValue into the method here. this.model.applyI18N(this.i18nValue); } }; /** * @return {?} */ PhloxTable.prototype.getModel = /** * @return {?} */ function () { return this.model; }; /** * @param {?} data * @return {?} */ PhloxTable.prototype.setData = /** * @param {?} data * @return {?} */ function (data) { _super.prototype.setData.call(this, data); // Save original data with cloned value this.selfSaveData(this.data); // Auto re-render when new data was set this.rerender(true); }; /** * @return {?} */ PhloxTable.prototype.isSelfDataDirty = /** * @return {?} */ function () { var /** @type {?} */ b = JSON.stringify(this.data) !== JSON.stringify(this.originalData); return b; }; /** * @param {?} data * @return {?} */ PhloxTable.prototype.selfSaveData = /** * @param {?} data * @return {?} */ function (data) { if (typeof this.data === 'object') { this.originalData = JSON.parse(JSON.stringify(this.data)); } else { this.originalData = this.data; } }; /** * @return {?} */ PhloxTable.prototype.selfResetData = /** * @return {?} */ function () { if (this.originalData === null || typeof this.originalData === 'undefined') { this.data = this.originalData; } else if (this.data === null || typeof this.data === 'undefined') { this.data = JSON.parse(JSON.stringify(this.originalData)); } else if (Array.isArray(this.originalData)) { if (Array.isArray(this.data)) { // Re-copy members from original data (do not change this.data object reference) this.data.splice(0, this.data.length); this.data.concat(this.originalData); } else { // Copy array member values this.data = [].concat(this.originalData); } } else if (typeof this.originalData === 'object') { if (typeof this.data === 'object') { // Copy data values from originalData (overwrite=true and resetOldValues=true) // (do not change this.data object reference) DataUtils.copyDataValues(this.originalData, this.data, true, true); } else { // Clone object from original data this.data = JSON.parse(JSON.stringify(this.originalData)); } } else { this.data = this.originalData; } }; /** * @return {?} */ PhloxTable.prototype.getOriginalData = /** * @return {?} */ function () { return this.originalData; }; /** * @return {?} */ PhloxTable.prototype.getBodyComponentInstance = /** * @return {?} */ function () { return this.bodyComponentInstance; }; /** * @return {?} */ PhloxTable.prototype.getRowGenerator = /** * @return {?} */ function () { return this.rowGenerator; }; /** * @param {?} rowGenerator * @return {?} */ PhloxTable.prototype.setRowGenerator = /** * @param {?} rowGenerator * @return {?} */ function (rowGenerator) { var /** @type {?} */ oldGen = this.rowGenerator; this.rowGenerator = rowGenerator; if (oldGen !== this.rowGenerator) { // If the new row generator was set into this table, // we'll rerender the table automatically. this.rerender(true); } }; /** * @return {?} */ PhloxTable.prototype.isDblClickEdit = /** * @return {?} */ function () { return this.dblClickEdit; }; /** * @param {?} dblClickEdit * @return {?} */ PhloxTable.prototype.setDblClickEdit = /** * @param {?} dblClickEdit * @return {?} */ function (dblClickEdit) { this.dblClickEdit = dblClickEdit; }; /** * @param {?=} generateRows * @param {?=} keepState * @return {?} */ PhloxTable.prototype.rerender = /** * @param {?=} generateRows * @param {?=} keepState * @return {?} */ function (generateRows, keepState) { if (generateRows === void 0) { generateRows = false; } if (keepState === void 0) { keepState = true; } this.render(generateRows, keepState).catch(function (error) { // ! TODO Display error on UI? console.error(error); }); }; /** * @param {?=} generateRows * @param {?=} keepState * @return {?} */ PhloxTable.prototype.render = /** * @param {?=} generateRows * @param {?=} keepState * @return {?} */ function (generateRows, keepState) { var _this = this; if (generateRows === void 0) { generateRows = false; } if (keepState === void 0) { keepState = true; } var /** @type {?} */ oldRowStates = this.rows; if (generateRows) { if (this.rowGenerator !== null && typeof this.rowGenerator !== 'undefined') { this.rows = this.rowGenerator.generateTableRows(this, this.data); } else { this.rows = []; } if (this.rows === null || typeof this.rows === 'undefined' || !Array.isArray(this.rows)) { this.rows = []; } } return Promise.resolve().then(function () { if (_this.bodyComponentInstance !== null && typeof _this.bodyComponentInstance.render === 'function') { return _this.bodyComponentInstance.render(_this.rows); } }).then(function () { // Auto apply i18n on "bodyComponentInstance" after re-rendering if (_this.bodyComponentInstance !== null && typeof (/** @type {?} */ (_this.bodyComponentInstance)).applyI18N === 'function') { if (_this.i18nValue === null) { (/** @type {?} */ (_this.bodyComponentInstance)).applyI18N(null); } else if (typeof _this.i18nValue !== 'undefined') { // "bodyComponentInstance" is mapped to "body" i18n key. (/** @type {?} */ (_this.bodyComponentInstance)).applyI18N(_this.i18nValue['body']); } } // Load old row states if (generateRows && keepState) { var /** @type {?} */ doLoad_1 = function () { _this.loadStateTimer = null; _this.loadStateResolve = null; try { for (var _a = tslib_1.__values(_this.rows), _b = _a.next(); !_b.done; _b = _a.next()) { var row = _b.value; // Find old row state var /** @type {?} */ oldRowState = null; for (var /** @type {?} */ i = 0; i < oldRowStates.length; i++) { if (_this.rowGenerator.compareRow(row, oldRowStates[i]) === 0) { oldRowState = oldRowStates[i]; oldRowStates.splice(i, 1); break; } } if (oldRowState !== null) { if (row.getComponentInstance() !== null && typeof row.getComponentInstance() !== 'undefined') { // Call loadState() via component instance to let its (the component) sub class can be // able to hook this event to do something more. row.getComponentInstance().loadState(oldRowState); } else { row.loadState(oldRowState); } } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_1) throw e_1.error; } } var e_1, _c; }; if (_this.loadStateDelay > 0) { // Call doLoad after timeout reached. return new Promise(function (resolve, reject) { if (_this.loadStateTimer !== null && typeof _this.loadStateTimer !== 'undefined') { clearTimeout(_this.loadStateTimer); } if (_this.loadStateResolve !== null && typeof _this.loadStateResolve !== 'undefined') { _this.loadStateResolve(); } _this.loadStateTimer = setTimeout(function () { try { doLoad_1(); resolve(); } catch (/** @type {?} */ e) { reject(e); } }, _this.loadStateDelay); // In case of this timer is canceled out, we'll resolve this promise immeidately. // In case of this timer is canceled out, we'll resolve this promise immeidately. _this.loadStateResolve = resolve; }); } else { // Call doLoad immeidately. // Call doLoad immeidately. doLoad_1(); } } }); }; /** * @return {?} */ PhloxTable.prototype.getRowControllers = /** * @return {?} */ function () { if (this.rows === null || !Array.isArray(this.rows)) { return null; } return [].concat(this.rows); }; /** * @param {?} row * @return {?} */ PhloxTable.prototype.getRowIndex = /** * @param {?} row * @return {?} */ function (row) { if (row === null || typeof row === 'undefined') { return -1; } if (this.rows === null || !Array.isArray(this.rows)) { return -1; } return this.rows.indexOf(row); }; /** * @param {?} data * @param {?=} compareByRef * @return {?} */ PhloxTable.prototype.getRowIndexByData = /** * @param {?} data * @param {?=} compareByRef * @return {?} */ function (data, compareByRef) { if (compareByRef === void 0) { compareByRef = true; } if (this.rows === null || !Array.isArray(this.rows)) { return -1; } for (var /** @type {?} */ i = 0; i < this.rows.length; i++) { var /** @type {?} */ row = this.rows[i]; if (row === null || typeof row === 'undefined') { continue; } if (compareByRef) { if (row.getData() === data) { return i; } } else { if (JSON.stringify(row.getData()) === JSON.stringify(data)) { return i; } } } return -1; }; /** * @param {?} data * @param {?=} compareByRef * @return {?} */ PhloxTable.prototype.getRowController = /** * @param {?} data * @param {?=} compareByRef * @return {?} */ function (data, compareByRef) { if (compareByRef === void 0) { compareByRef = true; } var /** @type {?} */ rowIdx = this.getRowIndexByData(data, compareByRef); if (rowIdx < 0) { return null; } return this.rows[rowIdx]; }; /** * @return {?} */ PhloxTable.prototype.getHeaderController = /** * @return {?} */ function () { return this.header; }; /** * @param {?} rowData * @return {?} */ PhloxTable.prototype.findRow = /** * @param {?} rowData * @return {?} */ function (rowData) { return this.rowGenerator.findRow(this.rows, rowData); }; /** * @param {?} rowIdx * @param {?} colIdx * @return {?} */ PhloxTable.prototype.isCellEditable = /** * @param {?} rowIdx * @param {?} colIdx * @return {?} */ function (rowIdx, colIdx) { if (rowIdx === null || typeof rowIdx !== 'number') { return false; } if (colIdx === null || typeof colIdx !== 'number') { return false; } if (rowIdx < 0 || rowIdx >= this.rows.length) { return false; } var /** @type {?} */ row = this.rows[rowIdx]; if (colIdx < 0 || colIdx >= row.getCellComponentInstances().length) { return false; } return row.isCellEditable(colIdx); }; /** * @param {?} rowIdx * @param {?} colIdx * @return {?} */ PhloxTable.prototype.isCellEditing = /** * @param {?} rowIdx * @param {?} colIdx * @return {?} */ function (rowIdx, colIdx) { if (rowIdx === null || typeof rowIdx !== 'number') { return false; } if (colIdx === null || typeof colIdx !== 'number') { return false; } if (rowIdx < 0 || rowIdx >= this.rows.length) { return false; } var /** @type {?} */ row = this.rows[rowIdx]; if (colIdx < 0 || colIdx >= row.getCellComponentInstances().length) { return false; } return row.isCellEditing(colIdx); }; /** * @param {?} rowIdx * @param {?} colIdx * @return {?} */ PhloxTable.prototype.isCellEditingMode = /** * @param {?} rowIdx * @param {?} colIdx * @return {?} */ function (rowIdx, colIdx) { if (rowIdx === null || typeof rowIdx !== 'number') { return false; } if (colIdx === null || typeof colIdx !== 'number') { return false; } if (rowIdx < 0 || rowIdx >= this.rows.length) { return false; } var /** @type {?} */ row = this.rows[rowIdx]; if (colIdx < 0 || colIdx >= row.getCellComponentInstances().length) { return false; } return row.isCellEditingMode(colIdx); }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} editing * @return {?} */ PhloxTable.prototype.setCellEditing = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} editing * @return {?} */ function (rowIdx, colIdx, editing) { if (rowIdx === null || typeof rowIdx !== 'number') { return; } if (colIdx === null || typeof colIdx !== 'number') { return; } if (rowIdx < 0 || rowIdx >= this.rows.length) { return; } var /** @type {?} */ row = this.rows[rowIdx]; if (colIdx < 0 || colIdx >= row.getCellComponentInstances().length) { return; } return row.setCellEditing(colIdx, editing); }; /** * @param {?} rowIdx * @param {?} colIdx * @return {?} */ PhloxTable.prototype.toggleCellEditing = /** * @param {?} rowIdx * @param {?} colIdx * @return {?} */ function (rowIdx, colIdx) { if (rowIdx === null || typeof rowIdx !== 'number') { return; } if (colIdx === null || typeof colIdx !== 'number') { return; } if (rowIdx < 0 || rowIdx >= this.rows.length) { return; } var /** @type {?} */ row = this.rows[rowIdx]; if (colIdx < 0 || colIdx >= row.getCellComponentInstances().length) { return; } return row.setCellEditing(colIdx, !this.isCellEditing(rowIdx, colIdx)); }; /** * @return {?} */ PhloxTable.prototype._getBodyWrapperHandler = /** * @return {?} */ function () { return this.bodyWrapperHandler; }; /** * @return {?} */ PhloxTable.prototype._getHeaderWrapperHandler = /** * @return {?} */ function () { return this.headerWrapperHandler; }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compChangeEvent * @param {?=} fireEvent * @return {?} */ PhloxTable.prototype.onCellChanged = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compChangeEvent * @param {?=} fireEvent * @return {?} */ function (rowIdx, colIdx, compChangeEvent, fireEvent) { var _this = this; if (fireEvent === null || fireEvent === undefined) { fireEvent = true; } EventUtils.handleBrowserEvent(this, 'beforeChangeEvent', compChangeEvent, fireEvent, function ($event) { // doEvent }, function ($event) { // emitBeforeEvent // emitBeforeEvent _this.emitBeforeChangeEvent(rowIdx, colIdx, $event); }, function ($event, result) { // emitAfterEvent // emitAfterEvent _this.emitChangeEvent(rowIdx, colIdx, $event); }, function ($event) { // doPrevented }); }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @param {?=} fireEvent * @return {?} */ PhloxTable.prototype.onCellClicked = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @param {?=} fireEvent * @return {?} */ function (rowIdx, colIdx, browserEvent, fireEvent) { var _this = this; if (fireEvent === null || fireEvent === undefined) { fireEvent = true; } EventUtils.handleBrowserEvent(this, 'beforeCellClickEvent', browserEvent, fireEvent, function ($event) { // doEvent }, function ($event) { // emitBeforeEvent // emitBeforeEvent _this.emitBeforeCellClickEvent(rowIdx, colIdx, $event); }, function ($event, result) { // emitAfterEvent // emitAfterEvent _this.emitCellClickEvent(rowIdx, colIdx, $event); }, function ($event) { // doPrevented }); }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @param {?=} fireEvent * @return {?} */ PhloxTable.prototype.onCellDblClicked = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} browserEvent * @param {?=} fireEvent * @return {?} */ function (rowIdx, colIdx, browserEvent, fireEvent) { var _this = this; if (fireEvent === null || fireEvent === undefined) { fireEvent = true; } EventUtils.handleBrowserEvent(this, 'beforeCellDblClickEvent', browserEvent, fireEvent, function ($event) { // doEvent if (_this.isDblClickEdit() && _this.isCellEditable(rowIdx, colIdx)) { // Toggle cell editing flag if isDblClickEdit() is enabled. // Toggle cell editing flag if isDblClickEdit() is enabled. _this.toggleCellEditing(rowIdx, colIdx); } }, function ($event) { // emitBeforeEvent // emitBeforeEvent _this.emitBeforeCellDblClickEvent(rowIdx, colIdx, $event); }, function ($event, result) { // emitAfterEvent // emitAfterEvent _this.emitCellDblClickEvent(rowIdx, colIdx, $event); }, function ($event) { // doPrevented }); }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @param {?=} fireEvent * @return {?} */ PhloxTable.prototype.onCellFocused = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compFocusEvent * @param {?=} fireEvent * @return {?} */ function (rowIdx, colIdx, compFocusEvent, fireEvent) { var _this = this; if (fireEvent === null || fireEvent === undefined) { fireEvent = true; } EventUtils.handleBrowserEvent(this, 'beforeCellFocusEvent', compFocusEvent, fireEvent, function ($event) { // doEvent }, function ($event) { // emitBeforeEvent // emitBeforeEvent _this.emitBeforeCellFocusEvent(rowIdx, colIdx, $event); }, function ($event, result) { // emitAfterEvent // emitAfterEvent _this.emitCellFocusEvent(rowIdx, colIdx, $event); }, function ($event) { // doPrevented }); }; /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compLostFocusEvent * @param {?=} fireEvent * @return {?} */ PhloxTable.prototype.onCellLostFocused = /** * @param {?} rowIdx * @param {?} colIdx * @param {?} compLostFocusEvent * @param {?=} fireEvent * @return {?} */ function (rowIdx, colIdx, compLostFocusEvent, fireEvent) { var _this = this; if (fireEvent === null || fireEvent === undefined) { fireEvent = true; } EventUtils.handleBrowserEvent(this, 'beforeCellLostFocusEvent', compLostFocusEvent, fireEvent, function ($event) { // doEvent }, function ($event) { // emitBeforeEvent // emitBeforeEvent _this.emitBeforeCellLostFocusEvent(rowIdx, colIdx, $event); }, function ($event, result) { // emitAfterEvent // emitAfterEvent _this.emitCellLostFocusEvent(rowIdx, colIdx, $event); }, function ($event) { // doPrevented }); }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.onDrag = /** * @param {?} event * @return {?} */ function (event) { if (this.rowDragEvent !== null && this.rowDragEvent !== undefined) { this.rowDragEvent.emit(event); } }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.onDragStart = /** * @param {?} event * @return {?} */ function (event) { if (this.rowDragStartEvent !== null && this.rowDragStartEvent !== undefined) { this.rowDragStartEvent.emit(event); } }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.onDragEnd = /** * @param {?} event * @return {?} */ function (event) { if (this.rowDragEndEvent !== null && this.rowDragEndEvent !== undefined) { this.rowDragEndEvent.emit(event); } }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.onDragEnter = /** * @param {?} event * @return {?} */ function (event) { if (this.rowDragEnterEvent !== null && this.rowDragEnterEvent !== undefined) { this.rowDragEnterEvent.emit(event); } }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.onDragOver = /** * @param {?} event * @return {?} */ function (event) { if (this.rowDragOverEvent !== null && this.rowDragOverEvent !== undefined) { this.rowDragOverEvent.emit(event); } }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.onDragLeave = /** * @param {?} event * @return {?} */ function (event) { if (this.rowDragLeaveEvent !== null && this.rowDragLeaveEvent !== undefined) { this.rowDragLeaveEvent.emit(event); } }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.onDrop = /** * @param {?} event * @return {?} */ function (event) { if (this.rowDropEvent !== null && this.rowDropEvent !== undefined) { this.rowDropEvent.emit(event); } }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.onDropAccepted = /** * @param {?} event * @return {?} */ function (event) { if (this.rowDropAcceptedEvent !== null && this.rowDropAcceptedEvent !== undefined) { this.rowDropAcceptedEvent.emit(event); } }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.onDropRejected = /** * @param {?} event * @return {?} */ function (event) { if (this.rowDropRejectedEvent !== null && this.rowDropRejectedEvent !== undefined) { this.rowDropRejectedEvent.emit(event); } }; /** * @return {?} */ PhloxTable.prototype.getBeforeCellFocusEvent = /** * @return {?} */ function () { return this.beforeCellFocusEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setBeforeCellFocusEvent = /** * @param {?} event * @return {?} */ function (event) { this.beforeCellFocusEvent = event; }; /** * @return {?} */ PhloxTable.prototype.getCellFocusEvent = /** * @return {?} */ function () { return this.cellFocusEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setCellFocusEvent = /** * @param {?} event * @return {?} */ function (event) { this.cellFocusEvent = event; }; /** * @return {?} */ PhloxTable.prototype.getBeforeCellLostFocusEvent = /** * @return {?} */ function () { return this.beforeCellLostFocusEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setBeforeCellLostFocusEvent = /** * @param {?} event * @return {?} */ function (event) { this.beforeCellLostFocusEvent = event; }; /** * @return {?} */ PhloxTable.prototype.getCellLostFocusEvent = /** * @return {?} */ function () { return this.cellLostFocusEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setCellLostFocusEvent = /** * @param {?} event * @return {?} */ function (event) { this.cellLostFocusEvent = event; }; /** * @return {?} */ PhloxTable.prototype.getBeforeCellClickEvent = /** * @return {?} */ function () { return this.beforeCellClickEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setBeforeCellClickEvent = /** * @param {?} event * @return {?} */ function (event) { this.beforeCellClickEvent = event; }; /** * @return {?} */ PhloxTable.prototype.getCellClickEvent = /** * @return {?} */ function () { return this.cellClickEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setCellClickEvent = /** * @param {?} event * @return {?} */ function (event) { this.cellClickEvent = event; }; /** * @return {?} */ PhloxTable.prototype.getBeforeCellDblClickEvent = /** * @return {?} */ function () { return this.beforeCellDblClickEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setBeforeCellDblClickEvent = /** * @param {?} event * @return {?} */ function (event) { this.beforeCellDblClickEvent = event; }; /** * @return {?} */ PhloxTable.prototype.getCellDblClickEvent = /** * @return {?} */ function () { return this.cellDblClickEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setCellDblClickEvent = /** * @param {?} event * @return {?} */ function (event) { this.cellDblClickEvent = event; }; /** * @return {?} */ PhloxTable.prototype.getBeforeChangeEvent = /** * @return {?} */ function () { return this.beforeChangeEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setBeforeChangeEvent = /** * @param {?} event * @return {?} */ function (event) { this.beforeChangeEvent = event; }; /** * @return {?} */ PhloxTable.prototype.getChangeEvent = /** * @return {?} */ function () { return this.changeEvent; }; /** * @param {?} event * @return {?} */ PhloxTable.prototype.setChangeEvent = /** * @param {?} event * @return {?} */ function (event) { this.changeEvent = event; }; PhloxTable.TYPE_NAME = TYPE_NAME; PhloxTable.DEFAULT_LOAD_STATE_DELAY = DEFAULT_LOAD_STATE_DELAY; PhloxTable.decorators = [ { type: Component, args: [{ moduleId: module.id, selector: TYPE_NAME, template: "<!-- <thead> -->\n<phx-component-wrapper [type]=\"getModel().getHeaderModel().getComponentType()\"\n [options]=\"getModel().getHeaderModel().getComponentOptions()\"\n [dataParent]=\"this\"\n [data]=\"getData()\"\n [handler]=\"_getHeaderWrapperHandler()\"\n [class]=\"'phx-table-header' + (getModel().getHeaderModel().getCSSClass() ? ' ' + getModel().getHeaderModel().getCSSClass() : '')\">\n</phx-component-wrapper>\n<!-- <tbody> -->\n<phx-component-wrapper [type]=\"getModel().getBodyComponentType()\"\n [options]=\"getModel().getBodyComponentOptions()\"\n [handler]=\"_getBodyWrapperHandler()\"\n [dataParent]=\"this\"\n [data]=\"getData()\"\n [class]=\"'phx-table-body' + (getModel().getBodyCSSClass() ? ' ' + getModel().getBodyCSSClass() : '')\">\n</phx-component-wrapper>\n" },] }, ]; /** @nocollapse */ PhloxTable.ctorParameters = function () { return [ { type: TypeResolveService, }, { type: ElementRef, }, ]; }; PhloxTable.propDecorators = { "dataParent": [{ type: Input },], "ignoreParentData": [{ type: Input },], "data": [{ type: Input },], "ignoreParentDisabled": [{ type: Input },], "delegateHistory": [{ type: Input },], "onDisabled": [{ type: Input },], "onEnabled": [{ type: Input },], "loadingEnabled": [{ type: Input },], "i18nKey": [{ type: Input },], "bypass": [{ type: Input, args: ['i18nBypass',] },], "options": [{ type: Input },], "disabled": [{ type: Input },], "help": [{ type: Input },], "rowGenerator": [{ type: Input },], "loadStateDelay": [{ type: Input },], "dblClickEdit": [{ type: Input },], "beforeCellClickEvent": [{ type: Output, args: ['phxBeforeCellClick',] },], "beforeCellDblClickEvent": [{ type: Output, args: ['phxBeforeCellDblClick',] },], "beforeCellLostFocusEvent": [{ type: Output, args: ['phxBeforeCellLostFocus',] },], "beforeCellFocusEvent": [{ type: Output, args: ['phxBeforeCellFocus',] },], "cellClickEvent": [{ type: Output, args: ['phxCellClick',] },], "cellDblClickEvent": [{ type: Output, args: ['phxCellDblClick',] },], "cellLostFocusEvent": [{ type: Output, args: ['phxCellLostFocus',] },], "cellFocusEvent": [{ type: Output, args: ['phxCellFocus',] },], "rowDragEvent": [{ type: Output, args: ['phxRowDrag',] },], "rowDragStartEvent": [{ type: Output, args: ['phxRowDragStart',] },], "rowDragEndEvent": [{ type: Output, args: ['phxRowDragEnd',] },], "rowDragEnterEvent": [{ type: Output, args: ['phxRowDragEnter',] },], "rowDragOverEvent": [{ type: Output, args: ['phxRowDragOver',] },], "rowDragLeaveEvent": [{ type: Output, args: ['phxRowDragLeave',] },], "rowDropEvent": [{ type: Output, args: ['phxRowDrop',] },], "rowDropAcceptedEvent": [{ type: Output, args: ['phxRowDropAccepted',] },], "rowDropRejectedEvent": [{ type: Output, args: ['phxRowDropRejected',] },], "changeEvent": [{ type: Output, args: ['phxChange',] },], "beforeChangeEvent": [{ type: Output, args: ['phxBeforeChange',] },], }; tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Object) ], PhloxTable.prototype, "dataParent", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Boolean) ], PhloxTable.prototype, "ignoreParentData", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Object) ], PhloxTable.prototype, "data", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Boolean) ], PhloxTable.prototype, "ignoreParentDisabled", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Boolean) ], PhloxTable.prototype, "delegateHistory", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Function) ], PhloxTable.prototype, "onDisabled", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Function) ], PhloxTable.prototype, "onEnabled", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Boolean) ], PhloxTable.prototype, "loadingEnabled", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", String) ], PhloxTable.prototype, "i18nKey", void 0); tslib_1.__decorate([ Option('i18nBypass'), tslib_1.__metadata("design:type", Boolean) ], PhloxTable.prototype, "bypass", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Boolean) ], PhloxTable.prototype, "disabled", void 0); tslib_1.__decorate([ I18N(), Option(), tslib_1.__metadata("design:type", Object) ], PhloxTable.prototype, "help", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Object) ], PhloxTable.prototype, "rowGenerator", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Number) ], PhloxTable.prototype, "loadStateDelay", void 0); tslib_1.__decorate([ Option(), tslib_1.__metadata("design:type", Boolean) ], PhloxTable.prototype, "dblClickEdit", void 0); tslib_1.__decorate([ Option('beforeCellClick'), tslib_1.__metadata("design:type", EventEmitter) ], PhloxTable.prototype, "beforeCellClickEvent", void 0); tslib_1.__decorate([ Option('beforeCellDblClick'), tslib_1.__metadata("design:type", EventEmitter) ], PhloxTable.prototype, "beforeCellDblClickEvent", void 0); tslib_1.__decorate([ Option('beforeCellLostFocus'), tslib_1.__metadata("design:type", EventEmitter) ], PhloxTable.prototype, "beforeCellLostFocusEvent", void 0); tslib_1.__decorate([ Option('beforeCellFocus'), tslib_1.__metadata("design:type", EventEmitter) ], PhloxTable.prototype, "beforeCellFocusEvent", void 0); tslib_1.__decorate([ Option('cellClick'), tslib_1.__metadata("design:type", EventEmitter) ], PhloxTable.prototype, "cellClickEvent", void 0); tslib_1.__