Skip to content

Commit

Permalink
feat(tableCell): add showValue and hideValue for display cell
Browse files Browse the repository at this point in the history
  • Loading branch information
juanlopez1 authored and navarroaxel committed Feb 22, 2018
1 parent c1a6d40 commit 6eb0567
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 167 deletions.
11 changes: 9 additions & 2 deletions src/Table/TableCell.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import React from 'react';
import {Text} from 'react-native';
import {Col} from '@indec/react-native-commons';
import {at} from 'lodash';
import {at, isFunction} from 'lodash';

import columnPropType from './columnPropType';
import datumPropType from './datumPropType';
import styles from './styles';

const TableCell = ({datum, column}) => {
const {componentClass: Comp} = column;
const {componentClass: Comp, showValue, hideValue} = column;
let visible = isFunction(showValue) ? showValue(datum) : true;
if (isFunction(hideValue) && hideValue(datum)) {
visible = false;
}
if (!visible) {
return <Col/>;
}
return Comp ? (
<Col>
<Comp column={column} datum={datum}/>
Expand Down
2 changes: 2 additions & 0 deletions src/Table/columnPropType.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export default PropTypes.shape({
id: PropTypes.number.isRequired,
label: PropTypes.string.isRequired,
field: PropTypes.string.isRequired,
showValue: PropTypes.func,
hideValue: PropTypes.func,
componentClass: PropTypes.oneOfType([
PropTypes.func,
PropTypes.instanceOf(Component)
Expand Down
Loading

0 comments on commit 6eb0567

Please sign in to comment.