blob: e8d0fc253660289b97ef6f4d7f9d7680026dffdd (
plain)
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
|
import React from 'react';
import FontAwesome from 'react-fontawesome';
import store from 'sdc-app/AppStore.js';
import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js';
class ListEditorItem extends React.Component {
static propTypes = {
onSelect: React.PropTypes.func,
onDelete: React.PropTypes.func,
onEdit: React.PropTypes.func,
children: React.PropTypes.node,
isReadOnlyMode: React.PropTypes.bool
}
render() {
let {onDelete, onSelect, onEdit, children, isReadOnlyMode} = this.props;
let isAbilityToDelete = isReadOnlyMode === undefined ? true : !isReadOnlyMode;
return (
<div className='list-editor-item-view'>
<div className='list-editor-item-view-content' onClick={onSelect}>
{children}
</div>
<div className='list-editor-item-view-controller'>
{onEdit && <FontAwesome name='sliders' onClick={() => this.onClickedItem(onEdit)}/>}
{onDelete && isAbilityToDelete && <FontAwesome name='trash-o' onClick={() => this.onClickedItem(onDelete)}/>}
</div>
</div>
);
}
onClickedItem(callBackFunc) {
if(typeof callBackFunc === 'function') {
let {isCheckedOut} = this.props;
if (isCheckedOut === false) {
store.dispatch({
type: NotificationConstants.NOTIFY_ERROR,
data: {title: 'Error', msg: 'This item is checkedin/submitted, Click Check Out to continue'}
});
}
else {
callBackFunc();
}
}
}
}
export default ListEditorItem;
|