From caffc987b5f9b11554e200745f11b66579a31fff Mon Sep 17 00:00:00 2001 From: Johannes Gocke Date: Fri, 23 Oct 2020 10:02:29 +0200 Subject: [PATCH 1/4] Added more precise definition to Tooltip.d.ts and TooltipOptions.d.ts for position. "top" | "right" | "bottom" | "left" in CSS direction order. --- src/components/tooltip/Tooltip.d.ts | 2 +- src/components/tooltip/TooltipOptions.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/tooltip/Tooltip.d.ts b/src/components/tooltip/Tooltip.d.ts index 26ed7d976d..54cf5aa376 100644 --- a/src/components/tooltip/Tooltip.d.ts +++ b/src/components/tooltip/Tooltip.d.ts @@ -6,7 +6,7 @@ interface TooltipProps { className?: string; style?: object; appendTo?: object; - position?: string; + position?: "top" | "right" | "bottom" | "left"; my?: string; at?: string; event?: string; diff --git a/src/components/tooltip/TooltipOptions.d.ts b/src/components/tooltip/TooltipOptions.d.ts index 5112e40fa1..e30460f9bc 100644 --- a/src/components/tooltip/TooltipOptions.d.ts +++ b/src/components/tooltip/TooltipOptions.d.ts @@ -1,6 +1,6 @@ export default interface TooltipOptions { event?: string; - position?: string; + position?: "top" | "right" | "bottom" | "left"; showDelay?: number; hideDelay?: number; className?: string; From 7c3ee13eea24e24cc1fde62709177b451c377eef Mon Sep 17 00:00:00 2001 From: Johannes Gocke Date: Sun, 27 Dec 2020 21:16:45 +0100 Subject: [PATCH 2/4] Added editingRows property to Datatable. This allows for setting the rows being in editing state and triggering editing state for rows from outside the Datatable. Added valid state to returns of onRowEditSave. Adjusted Typing. --- src/components/datatable/BodyRow.js | 20 +++-------------- src/components/datatable/DataTable.d.ts | 3 ++- src/components/datatable/DataTable.js | 4 +++- src/components/datatable/TableBody.js | 29 ++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/components/datatable/BodyRow.js b/src/components/datatable/BodyRow.js index 19a1f1bc5c..155f77f391 100644 --- a/src/components/datatable/BodyRow.js +++ b/src/components/datatable/BodyRow.js @@ -7,9 +7,6 @@ export class BodyRow extends Component { constructor(props) { super(props); - this.state = { - editing: false - }; this.onClick = this.onClick.bind(this); this.onDoubleClick = this.onDoubleClick.bind(this); @@ -177,10 +174,6 @@ export class BodyRow extends Component { }); } - this.setState({ - editing: true - }); - event.preventDefault(); } @@ -195,14 +188,11 @@ export class BodyRow extends Component { this.props.onRowEditSave({ originalEvent: event, data: this.props.rowData, - index: this.props.rowIndex + index: this.props.rowIndex, + valid: valid }); } - this.setState({ - editing: !valid - }); - event.preventDefault(); } @@ -215,10 +205,6 @@ export class BodyRow extends Component { }); } - this.setState({ - editing: false - }); - event.preventDefault(); } @@ -256,7 +242,7 @@ export class BodyRow extends Component { let cell = ; cells.push(cell); diff --git a/src/components/datatable/DataTable.d.ts b/src/components/datatable/DataTable.d.ts index 64901486dd..af3f8d33b8 100644 --- a/src/components/datatable/DataTable.d.ts +++ b/src/components/datatable/DataTable.d.ts @@ -65,6 +65,7 @@ interface DataTableProps { stateStorage?:string; groupField?:string; editMode?:string; + editingRows?: any[]; expandableRowGroups?:boolean; rowHover?:boolean; showSelectionElement?(e: {data: any}): boolean; @@ -93,7 +94,7 @@ interface DataTableProps { onValueChange?(value: any[]): void; rowEditorValidator?(rowData: any): boolean; onRowEditInit?(e: {originalEvent: Event, data: any, index: number}): void; - onRowEditSave?(e: {originalEvent: Event, data: any, index: number}): void; + onRowEditSave?(e: {originalEvent: Event, data: any, index: number, valid: boolean}): void; onRowEditCancel?(e: {originalEvent: Event, data: any, index: number}): void; exportFunction?(e: {data: any, field: string}): any; customSaveState?(state: any): void; diff --git a/src/components/datatable/DataTable.js b/src/components/datatable/DataTable.js index f5c2560ed4..59a9042f43 100644 --- a/src/components/datatable/DataTable.js +++ b/src/components/datatable/DataTable.js @@ -84,6 +84,7 @@ export class DataTable extends Component { stateKey: null, stateStorage: 'session', editMode: 'cell', + editingRows: null, expandableRowGroups: false, rowHover: false, showSelectionElement: null, @@ -183,6 +184,7 @@ export class DataTable extends Component { stateKey: PropTypes.string, stateStorage: PropTypes.string, editMode: PropTypes.string, + editingRows: PropTypes.oneOfType([PropTypes.array,PropTypes.object]), expandableRowGroups: PropTypes.bool, rowHover: PropTypes.bool, showSelectionElement: PropTypes.func, @@ -1305,7 +1307,7 @@ export class DataTable extends Component { virtualScroll={this.props.virtualScroll} virtualRowHeight={this.props.virtualRowHeight} loading={this.props.loading} groupField={this.props.groupField} rowGroupMode={this.props.rowGroupMode} rowGroupHeaderTemplate={this.props.rowGroupHeaderTemplate} rowGroupFooterTemplate={this.props.rowGroupFooterTemplate} sortField={this.getSortField()} rowClassName={this.props.rowClassName} onRowReorder={this.props.onRowReorder} - editMode={this.props.editMode} rowEditorValidator={this.props.rowEditorValidator} onRowEditInit={this.props.onRowEditInit} onRowEditSave={this.props.onRowEditSave} onRowEditCancel={this.props.onRowEditCancel} + editMode={this.props.editMode} editingRows={this.props.editingRows} rowEditorValidator={this.props.rowEditorValidator} onRowEditInit={this.props.onRowEditInit} onRowEditSave={this.props.onRowEditSave} onRowEditCancel={this.props.onRowEditCancel} expandableRowGroups={this.props.expandableRowGroups} showRowReorderElement={this.props.showRowReorderElement} showSelectionElement={this.props.showSelectionElement}> {columns} ; diff --git a/src/components/datatable/TableBody.js b/src/components/datatable/TableBody.js index 93d7c271f7..fd071fb804 100644 --- a/src/components/datatable/TableBody.js +++ b/src/components/datatable/TableBody.js @@ -359,6 +359,32 @@ export class TableBody extends Component { } } + findEditingRowIndex(row) { + let index = -1; + if (this.props.editingRows) { + for (let i = 0; i < this.props.editingRows.length; i++) { + if (ObjectUtils.equals(this.props.editingRows[i], row)) { + index = i; + break; + } + } + } + return index; + } + + isRowEditing(row) { + let dataKey = this.props.dataKey; + + if (dataKey) { + let dataKeyValue = String(ObjectUtils.resolveFieldData(row, dataKey)); + + return this.props.editingRows && this.props.editingRows[dataKeyValue] != null; + } + else { + return this.findEditingRowIndex(row) !== -1 + } + } + isSelectionEnabled() { if(this.props.selectionMode || this.props.frozenSelectionMode != null) { return true; @@ -503,6 +529,7 @@ export class TableBody extends Component { let rowData = this.props.value[i]; let expanded = this.isRowExpanded(rowData); + let editing = this.isRowEditing(rowData); let selected = selectionEnabled ? this.isSelected(this.props.value[i]) : false; let contextMenuSelected = this.isContextMenuSelected(rowData); let groupRowSpan; @@ -549,7 +576,7 @@ export class TableBody extends Component { sortField={this.props.sortField} rowGroupMode={this.props.rowGroupMode} groupRowSpan={groupRowSpan} onDragStart={(e) => this.onRowDragStart(e, i)} onDragEnd={this.onRowDragEnd} onDragOver={(e) => this.onRowDragOver(e, i)} onDragLeave={this.onRowDragLeave} onDrop={this.onRowDrop} virtualScroll={this.props.virtualScroll} virtualRowHeight={this.props.virtualRowHeight} - editMode={this.props.editMode} rowEditorValidator={this.props.rowEditorValidator} onRowEditInit={this.props.onRowEditInit} onRowEditSave={this.props.onRowEditSave} onRowEditCancel={this.props.onRowEditCancel} + editMode={this.props.editMode} editing={editing} rowEditorValidator={this.props.rowEditorValidator} onRowEditInit={this.props.onRowEditInit} onRowEditSave={this.props.onRowEditSave} onRowEditCancel={this.props.onRowEditCancel} showRowReorderElement={this.props.showRowReorderElement} showSelectionElement={this.props.showSelectionElement}> {this.props.children} From ff7134782603cb659dc31af00e9480336f576e9b Mon Sep 17 00:00:00 2001 From: Johannes Gocke Date: Mon, 29 Mar 2021 12:37:27 +0200 Subject: [PATCH 3/4] Removed change from master --- src/components/tooltip/Tooltip.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/tooltip/Tooltip.d.ts b/src/components/tooltip/Tooltip.d.ts index 9a5eb7a182..4086445dd8 100644 --- a/src/components/tooltip/Tooltip.d.ts +++ b/src/components/tooltip/Tooltip.d.ts @@ -8,7 +8,7 @@ interface TooltipProps { className?: string; style?: object; appendTo?: object; - position?: "top" | "right" | "bottom" | "left"; + position?: string; my?: string; at?: string; event?: string; From b89c06c2d93c0cc71c56ec2ffc1401f7eb4af6a7 Mon Sep 17 00:00:00 2001 From: Johannes Gocke Date: Mon, 29 Mar 2021 12:41:31 +0200 Subject: [PATCH 4/4] Added valid values of tool tip position into typing. --- src/components/tooltip/Tooltip.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/tooltip/Tooltip.d.ts b/src/components/tooltip/Tooltip.d.ts index 4086445dd8..9a5eb7a182 100644 --- a/src/components/tooltip/Tooltip.d.ts +++ b/src/components/tooltip/Tooltip.d.ts @@ -8,7 +8,7 @@ interface TooltipProps { className?: string; style?: object; appendTo?: object; - position?: string; + position?: "top" | "right" | "bottom" | "left"; my?: string; at?: string; event?: string;