Skip to content

Commit

Permalink
Refactor #2368
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 1, 2021
1 parent e7f3d18 commit 0c962e0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api-generator/components/datatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ const DataTableEvents = [
]
},
{
name: 'rowEditorValidator',
name: 'rowEditValidator',
description: 'Callback to invoke to validate the editing row when the save icon is clicked on row editing mode.',
arguments: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/datatable/BodyRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export class BodyRow extends Component {

onEditSave(e) {
const { originalEvent: event } = e;
const valid = this.props.rowEditorValidator ? this.props.rowEditorValidator(this.props.rowData, { props: this.props.tableProps }) : true;
const valid = this.props.rowEditValidator ? this.props.rowEditValidator(this.props.rowData, { props: this.props.tableProps }) : true;

if (this.props.onRowEditSave) {
this.props.onRowEditSave({
Expand Down
4 changes: 2 additions & 2 deletions src/components/datatable/DataTable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ interface DataTableShowRowReorderElementOptions {
props: DataTableProps;
}

interface DataTableRowEditorValidatorOptions {
interface DataTableRowEditValidatorOptions {
props: DataTableProps;
}

Expand Down Expand Up @@ -323,7 +323,7 @@ export interface DataTableProps {
onColReorder?(e: DataTableColReorderParams): void;
onRowReorder?(e: DataTableRowReorderParams): void;
onValueChange?(value: any[]): void;
rowEditorValidator?(data: any, options: DataTableRowEditorValidatorOptions): boolean;
rowEditValidator?(data: any, options: DataTableRowEditValidatorOptions): boolean;
onRowEditInit?(e: DataTableRowEditParams): void;
onRowEditSave?(e: DataTableRowEditSaveParams): void;
onRowEditCancel?(e: DataTableRowEditParams): void;
Expand Down
8 changes: 4 additions & 4 deletions src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class DataTable extends Component {
onCellUnselect: null,
onRowReorder: null,
onValueChange: null,
rowEditorValidator: null,
rowEditValidator: null,
onRowEditInit: null,
onRowEditSave: null,
onRowEditCancel: null,
Expand Down Expand Up @@ -242,7 +242,7 @@ export class DataTable extends Component {
onColReorder: PropTypes.func,
onRowReorder: PropTypes.func,
onValueChange: PropTypes.func,
rowEditorValidator: PropTypes.func,
rowEditValidator: PropTypes.func,
onRowEditInit: PropTypes.func,
onRowEditSave: PropTypes.func,
onRowEditCancel: PropTypes.func,
Expand Down Expand Up @@ -1612,7 +1612,7 @@ export class DataTable extends Component {
groupRowsBy={this.props.groupRowsBy} expandableRowGroups={this.props.expandableRowGroups} loading={this.props.loading} emptyMessage={this.props.emptyMessage}
rowGroupHeaderTemplate={this.props.rowGroupHeaderTemplate} rowExpansionTemplate={this.props.rowExpansionTemplate} rowGroupFooterTemplate={this.props.rowGroupFooterTemplate}
onRowEditChange={this.props.onRowEditChange} compareSelectionBy={this.props.compareSelectionBy} selectOnEdit={this.props.selectOnEdit}
onRowEditInit={this.props.onRowEditInit} rowEditorValidator={this.props.rowEditorValidator} onRowEditSave={this.props.onRowEditSave} onRowEditComplete={this.props.onRowEditComplete} onRowEditCancel={this.props.onRowEditCancel}
onRowEditInit={this.props.onRowEditInit} rowEditValidator={this.props.rowEditValidator} onRowEditSave={this.props.onRowEditSave} onRowEditComplete={this.props.onRowEditComplete} onRowEditCancel={this.props.onRowEditCancel}
cellClassName={this.props.cellClassName} responsiveLayout={this.props.responsiveLayout}
showSelectionElement={this.props.showSelectionElement} showRowReorderElement={this.props.showRowReorderElement}
expandedRowIcon={this.props.expandedRowIcon} collapsedRowIcon={this.props.collapsedRowIcon} rowClassName={this.props.rowClassName}
Expand All @@ -1632,7 +1632,7 @@ export class DataTable extends Component {
groupRowsBy={this.props.groupRowsBy} expandableRowGroups={this.props.expandableRowGroups} loading={this.props.loading} emptyMessage={this.props.emptyMessage}
rowGroupHeaderTemplate={this.props.rowGroupHeaderTemplate} rowExpansionTemplate={this.props.rowExpansionTemplate} rowGroupFooterTemplate={this.props.rowGroupFooterTemplate}
onRowEditChange={this.props.onRowEditChange} compareSelectionBy={this.props.compareSelectionBy} selectOnEdit={this.props.selectOnEdit}
onRowEditInit={this.props.onRowEditInit} rowEditorValidator={this.props.rowEditorValidator} onRowEditSave={this.props.onRowEditSave} onRowEditComplete={this.props.onRowEditComplete} onRowEditCancel={this.props.onRowEditCancel}
onRowEditInit={this.props.onRowEditInit} rowEditValidator={this.props.rowEditValidator} onRowEditSave={this.props.onRowEditSave} onRowEditComplete={this.props.onRowEditComplete} onRowEditCancel={this.props.onRowEditCancel}
cellClassName={this.props.cellClassName} responsiveLayout={this.props.responsiveLayout}
showSelectionElement={this.props.showSelectionElement} showRowReorderElement={this.props.showRowReorderElement}
expandedRowIcon={this.props.expandedRowIcon} collapsedRowIcon={this.props.collapsedRowIcon} rowClassName={this.props.rowClassName}
Expand Down
2 changes: 1 addition & 1 deletion src/components/datatable/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ export class TableBody extends Component {
onRadioChange={this.onRadioChange} onCheckboxChange={this.onCheckboxChange} onCellClick={this.onCellClick} onCellMouseDown={this.onCellMouseDown} onCellMouseUp={this.onCellMouseUp}
editing={editing} editingRows={this.props.editingRows} editingMeta={this.props.editingMeta} editMode={this.props.editMode} onRowEditChange={this.props.onRowEditChange} onEditingMetaChange={this.props.onEditingMetaChange}
groupRowsBy={this.props.groupRowsBy} compareSelectionBy={this.props.compareSelectionBy} dataKey={this.props.dataKey} rowGroupMode={this.props.rowGroupMode}
onRowEditInit={this.props.onRowEditInit} rowEditorValidator={this.props.rowEditorValidator} onRowEditSave={this.props.onRowEditSave} onRowEditComplete={this.props.onRowEditComplete} onRowEditCancel={this.props.onRowEditCancel}
onRowEditInit={this.props.onRowEditInit} rowEditValidator={this.props.rowEditValidator} onRowEditSave={this.props.onRowEditSave} onRowEditComplete={this.props.onRowEditComplete} onRowEditCancel={this.props.onRowEditCancel}
selection={this.props.selection} allowRowSelection={allowRowSelection} allowCellSelection={allowCellSelection} selectOnEdit={this.props.selectOnEdit} selectionMode={this.props.selectionMode} selectionModeInColumn={this.props.selectionModeInColumn}
cellClassName={this.props.cellClassName} responsiveLayout={this.props.responsiveLayout} frozenRow={this.props.frozenRow}
showSelectionElement={this.props.showSelectionElement} showRowReorderElement={this.props.showRowReorderElement}
Expand Down
6 changes: 3 additions & 3 deletions src/showcase/datatable/DataTableDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2071,15 +2071,15 @@ const requiredValidator = (e) => {
<DataTable value={products} editMode="row">
<Column field="code" header="Code" />
<Column field="name" header="Name" />
<Column field="inventoryStatuses" header="Status" editor={statusEditor} onRowEditorValidator={onRowEditorValidator} />
<Column field="inventoryStatuses" header="Status" editor={statusEditor} onRowEditValidator={onRowEditValidator} />
<Column rowEditor />
</DataTable>
`}
</CodeHighlight>

<CodeHighlight lang="js">
{`
const onRowEditorValidator = (rowData) => {
const onRowEditValidator = (rowData) => {
let value = rowData['inventoryStatuses'];
return value.length > 0;
}
Expand Down Expand Up @@ -3319,7 +3319,7 @@ const bodyTemplate = (data, props) => {
<td>Callback to invoke after filtering and sorting to pass the rendered value.</td>
</tr>
<tr>
<td>rowEditorValidator</td>
<td>rowEditValidator</td>
<td>data: Editing row data</td>
<td>Callback to invoke to validate the editing row when the save icon is clicked on row editing mode.</td>
</tr>
Expand Down

0 comments on commit 0c962e0

Please sign in to comment.