Skip to content

Commit

Permalink
[refactor] GH-5 Cells renderers in a single file
Browse files Browse the repository at this point in the history
  • Loading branch information
amivanoff committed Aug 10, 2021
1 parent 1a161ed commit deaeb54
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 223 deletions.
28 changes: 0 additions & 28 deletions src/cells/AntdBooleanCell.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions src/cells/AntdButtonCell.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/cells/AntdCellHorizontalLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { get } from 'lodash-es';

import { Idx } from '../util/layout';

export const AntdHorizontalLayoutRenderer: React.FC<DispatchCellProps> = ({ viewElement, view, data, schema }) => {
export const AntdCellHorizontalLayoutRenderer: React.FC<DispatchCellProps> = ({ viewElement, view, data, schema }) => {
//const layout = viewElement as Layout;
const Render: React.FC<DispatchCellProps & Idx> = ({ idx, schema, viewElement, view, data, enabled, form }) => {
const options = viewElement.options || {};
Expand Down Expand Up @@ -54,4 +54,4 @@ export const AntdHorizontalLayoutRenderer: React.FC<DispatchCellProps> = ({ view
);
};

export const antdHorizontalLayoutTester: RankedTester = rankWith(2, uiTypeIs('CellHorizontalLayout'));
export const antdCellHorizontalLayoutTester: RankedTester = rankWith(2, uiTypeIs('CellHorizontalLayout'));
28 changes: 0 additions & 28 deletions src/cells/AntdCellRateWidget.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions src/cells/AntdEnumCell.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions src/cells/AntdImageCell.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/cells/AntdNumberCell.tsx

This file was deleted.

125 changes: 125 additions & 0 deletions src/cells/AntdSimpleCells.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/********************************************************************************
* Copyright (c) 2020 Agentlab and others.
*
* This program and the accompanying materials are made available under the
* terms of the GNU General Public License v. 3.0 which is available at
* https://www.gnu.org/licenses/gpl-3.0.html.
*
* SPDX-License-Identifier: GPL-3.0-only
********************************************************************************/
import { get } from 'lodash-es';

import React from 'react';
import { Button, Card, Image, Row, Col, Rate } from 'antd';

import {
rankWith,
RankedTester,
isBooleanControl,
isDateTimeControl,
isEnumControl,
isIntegerControl,
isNumberControl,
isStringControl,
uiTypeIs,
} from '../testers';
import { withStoreToCellProps } from '../util/ContextToProps';

import { AntdCheckbox } from '../antd-controls/AntdCheckbox';
import { AntdInputDate } from '../antd-controls/AntdInputDate';
import { AntdInputNumber } from '../antd-controls/AntdInputNumber';
import { AntdInputText } from '../antd-controls/AntdInputText';
import { AntdSelect } from '../antd-controls/AntdSelect';
import { CellRenderer } from './CellRenderer';

import './cell.css';

/**
* AntdBooleanCell
*/
export const AntdBooleanCell = (props: any) => {
return <CellRenderer Cell={AntdCheckbox} {...props} />;
};
export const antdBooleanCellTester: RankedTester = rankWith(2, isBooleanControl);
export const AntdBooleanCellWithStore = withStoreToCellProps(AntdBooleanCell);

/**
* AntdButtonCell
*/
export const AntdButtonCell = (props: any) => {
const options = props.uiOptions;
return (
<Button size={'small'} style={options.style}>
{options.label}
</Button>
);
};
export const antdButtonCellTester: RankedTester = rankWith(2, uiTypeIs('Button'));
export const AntdButtonCellWithStore = withStoreToCellProps(AntdButtonCell);

/**
* AntdEnumCell
*/
export const AntdEnumCell = (props: any /*: EnumCellProps & WithClassname*/) => <AntdSelect {...props} />;
export const antdEnumCellTester: RankedTester = rankWith(2, isEnumControl);
export const AntdEnumCellWithStore = withStoreToCellProps(AntdEnumCell);

/**
* AntdNumberCell & AntdIntegerCell
*/
export const AntdNumberCell = (props: any) => {
return <CellRenderer Cell={AntdInputNumber} {...props} />;
};

export const antdIntegerCellTester: RankedTester = rankWith(2, isIntegerControl);
export const AntdIntegerCellWithStore = withStoreToCellProps(AntdNumberCell);

export const antdNumberCellTester: RankedTester = rankWith(2, isNumberControl);
export const AntdNumberCellWithStore = withStoreToCellProps(AntdNumberCell);

/**
* AntdImageCell
*/
export const AntdImageCell = (props: any) => {
const { data } = props;
return <Image style={{ height: '100%', width: '100%' }} src={data[0]} />;
};
export const antdImageCellTester: RankedTester = rankWith(2, uiTypeIs('ImageCell'));
export const AntdImageCellWithStore = withStoreToCellProps(AntdImageCell);

/**
* AntdRateCell
*/
export const AntdRateCell = (props: any /*: EnumCellProps & WithClassname*/) => {
return (
<React.Fragment>
<Rate
style={{ fontSize: '14px', color: 'rgb(255,140,0)', marginTop: '7px' }}
allowHalf
disabled
defaultValue={props.data}
/>
<span style={{ padding: '4px', fontSize: '12px', fontWeight: 500 }}>{`(${props.data})`}</span>
</React.Fragment>
);
};
export const antdRateCellTester: RankedTester = rankWith(5, uiTypeIs('Rate'));
export const AntdRateCellWithStore = withStoreToCellProps(AntdRateCell);

/**
* AntdTextCell
*/
export const AntdTextCell = (props: any) => {
return <CellRenderer Cell={AntdInputText} {...props} />;
};
export const antdTextCellTester: RankedTester = rankWith(1, isStringControl);
export const AntdTextCellWithStore = withStoreToCellProps(AntdTextCell);

/**
* AntdTimeCell
*/
export const AntdTimeCell = (props: any) => {
return <CellRenderer Cell={AntdInputDate} {...props} />;
};
export const antdTimeCellTester: RankedTester = rankWith(2, isDateTimeControl);
export const AntdTimeCellWithStore = withStoreToCellProps(AntdTimeCell);
28 changes: 0 additions & 28 deletions src/cells/AntdTextCell.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions src/cells/AntdTimeCell.tsx

This file was deleted.

Loading

0 comments on commit deaeb54

Please sign in to comment.