Skip to content

Commit

Permalink
Merge pull request #1713 from lyp000119/computedFieldRefactor
Browse files Browse the repository at this point in the history
struct view
  • Loading branch information
Cuiyansong authored Jul 22, 2022
2 parents e5c6eef + 78f7f8d commit 4943fd3
Show file tree
Hide file tree
Showing 2 changed files with 238 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

import { TreeSelect } from 'antd';
import { Form, TreeSelect } from 'antd';
import useI18NPrefix from 'app/hooks/useI18NPrefix';
import { DatabaseSchema } from 'app/pages/MainPage/pages/ViewPage/slice/types';
import { memo, useCallback, useEffect, useMemo } from 'react';
Expand All @@ -26,6 +26,7 @@ import { SPACE_SM } from 'styles/StyleConstants';
import { selectAllSourceDatabaseSchemas } from '../../../slice/selectors';
import { JoinTableProps, StructViewQueryProps } from '../../../slice/types';
import { getTableAllColumns } from '../../../utils';

interface SelectJoinColumnsProps {
structure: StructViewQueryProps;
joinTable: JoinTableProps;
Expand Down Expand Up @@ -117,36 +118,52 @@ const SelectJoinColumns = memo(

return (
<Line key={conditionsIndex}>
<ColumnSelect
dropdownMatchSelectWidth={false}
allowClear
placeholder={t('selectField')}
treeDefaultExpandAll={true}
value={joinTable.conditions?.[conditionsIndex]?.left.slice(-1)}
onChange={columnName => {
allowManage && onChange(columnName || [], 'left', conditionsIndex);
}}
treeData={handleLeftColumn()}
/>
<FormItem
name={'left' + conditionsIndex + joinIndex}
rules={[{ required: true, message: t('selectField') }]}
>
<ColumnSelect
dropdownMatchSelectWidth={false}
allowClear
placeholder={t('selectField')}
treeDefaultExpandAll={true}
value={joinTable.conditions?.[conditionsIndex]?.left.slice(-1)}
onChange={columnName => {
allowManage &&
onChange(columnName || [], 'left', conditionsIndex);
}}
treeData={handleLeftColumn()}
/>
</FormItem>
<Equal>=</Equal>
<ColumnSelect
dropdownMatchSelectWidth={false}
allowClear
placeholder={t('selectField')}
treeDefaultExpandAll={true}
value={joinTable.conditions?.[conditionsIndex]?.right.slice(-1)}
onChange={columnName => {
allowManage && onChange(columnName || [], 'right', conditionsIndex);
}}
treeData={handleRightColumn()}
/>
<FormItem
name={'right' + conditionsIndex + joinIndex}
rules={[{ required: true, message: t('selectField') }]}
>
<ColumnSelect
dropdownMatchSelectWidth={false}
allowClear
placeholder={t('selectField')}
treeDefaultExpandAll={true}
value={joinTable.conditions?.[conditionsIndex]?.right.slice(-1)}
onChange={columnName => {
allowManage &&
onChange(columnName || [], 'right', conditionsIndex);
}}
treeData={handleRightColumn()}
/>
</FormItem>
</Line>
);
},
);

const Line = styled.div``;

const FormItem = styled(Form.Item)`
display: inline-block;
`;

const ColumnSelect = styled(TreeSelect)`
min-width: 120px;
`;
Expand Down
Loading

0 comments on commit 4943fd3

Please sign in to comment.