-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathEntityListItemExpandable.js
More file actions
105 lines (96 loc) · 2.62 KB
/
EntityListItemExpandable.js
File metadata and controls
105 lines (96 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { palette } from 'styled-theme';
import { injectIntl } from 'react-intl';
import Component from 'components/styled/Component';
import Icon from 'components/Icon';
import messages from './messages';
const Styled = styled(Component)`
display: none;
@media (min-width: ${(props) => props.theme && props.theme.breakpoints ? props.theme.breakpoints.small : '769px'}) {
display: table-cell;
text-align: center;
cursor: pointer;
width:${(props) => props.colWidth * 100}%;
border-right: 3px solid ${palette('light', 0)};
vertical-align: middle;
padding: 5px 10px;
}
@media print {
border: none;
display: table-cell;
vertical-align: middle;
text-align: center;
width:${(props) => props.colWidth * 100}%;
}
`;
const IconWrap = styled.span`
display: inline-block;
color: ${palette('dark', 2)};
top: -4px;
position: relative;
`;
const Count = styled.span`
display: inline-block;
color: ${palette('dark', 2)};
padding: 0 8px;
font-size: 1.5em;
@media print {
font-size: ${(props) => props.theme.sizes.print.larger};
}
`;
const Info = styled.div`
color: ${(props) => props.palette ? palette(props.palette, 0) : palette('text', 1)};
font-weight: bold;
`;
class EntityListItemExpandable extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
render() {
const {
count,
onClick,
dates,
colWidth,
column,
intl,
} = this.props;
const { type, icon } = column;
const info = [];
if (dates) {
if (dates.due) {
info.push({
label: intl && intl.formatMessage(messages.due, { total: dates.due }),
});
}
if (dates.overdue) {
info.push({
style: type,
label: intl && intl.formatMessage(messages.overdue, { total: dates.overdue }),
});
}
}
return (
<Styled colWidth={colWidth} onClick={onClick}>
<IconWrap>
<Icon name={icon} text iconRight />
</IconWrap>
<Count type={type} count={count}>{count}</Count>
{info
&& info.map((infoItem, i) => (<Info key={i} palette={infoItem.style}>{infoItem.label}</Info>))
}
</Styled>
);
}
}
EntityListItemExpandable.propTypes = {
column: PropTypes.object,
count: PropTypes.number,
onClick: PropTypes.func,
colWidth: PropTypes.number,
dates: PropTypes.object,
intl: PropTypes.object.isRequired,
};
EntityListItemExpandable.defaultProps = {
count: 0,
};
export default injectIntl(EntityListItemExpandable);