editor data refactor - setEditorData can be called with function

This commit is contained in:
Jan Prochazka
2020-12-27 15:38:16 +01:00
parent ab0a551d67
commit 0747614e00
5 changed files with 207 additions and 121 deletions

View File

@@ -0,0 +1,56 @@
import React from 'react';
import { CheckboxField } from '../utility/inputs';
import TableControl, { TableColumn } from '../utility/TableControl';
export default function QueryDesignColumns({ value, onChange }) {
const { columns } = value || {};
console.log('QueryDesignColumns', value);
const changeColumn = React.useCallback(
(col) => {
const newValue = {
...value,
columns: (value.columns || []).map((x) =>
x.designerId == col.designerId && x.columnName == col.columnName ? col : x
),
};
onChange(newValue);
},
[onChange, value]
);
return (
<TableControl rows={columns || []}>
<TableColumn fieldName="columnName" header="Column/Expression" />
<TableColumn fieldName="tableDisplayName" header="Table" />
<TableColumn
fieldName="isOutput"
header="Output"
formatter={(row) => (
<CheckboxField
checked={row.isOutput}
onChange={(e) => {
if (e.target.checked) changeColumn({ ...row, isOutput: true });
else changeColumn({ ...row, isOutput: false });
}}
/>
)}
/>
{/* <TableColumn fieldName="queryDesignInfo.alias" editor="textbox" header="Alias" />
<TableColumn fieldName="queryDesignInfo.isGrouped" editor="checkbox" header="Group by" />
<TableColumn
fieldName="queryDesignInfo.aggregate"
editor="combobox"
header="Aggregate"
comboValues={['---', 'MIN', 'MAX', 'COUNT', 'COUNT DISTINCT', 'SUM', 'AVG']}
/>
<TableColumn
fieldName="queryDesignInfo.sortOrder"
header="Sort order"
editor="combobox"
comboValues={sortComboValues}
/>
<TableColumn fieldName="filter" header="Filter" editor="filterbox" getFilterType={this.getFilterType} /> */}
</TableControl>
);
}