| 1 |
/** |
| 2 |
* External dependencies |
| 3 |
*/ |
| 4 |
import ChartEditor from '../ChartEditor.js'; |
| 5 |
|
| 6 |
/** |
| 7 |
* WordPress dependencies |
| 8 |
*/ |
| 9 |
const { __ } = wp.i18n; |
| 10 |
|
| 11 |
const { |
| 12 |
Component, |
| 13 |
Fragment |
| 14 |
} = wp.element; |
| 15 |
|
| 16 |
const { |
| 17 |
Button, |
| 18 |
Modal, |
| 19 |
PanelBody |
| 20 |
} = wp.components; |
| 21 |
|
| 22 |
class ManualData extends Component { |
| 23 |
constructor() { |
| 24 |
super( ...arguments ); |
| 25 |
|
| 26 |
this.toggleModal = this.toggleModal.bind( this ); |
| 27 |
|
| 28 |
this.state = { |
| 29 |
isOpen: false |
| 30 |
}; |
| 31 |
} |
| 32 |
|
| 33 |
toggleModal() { |
| 34 |
this.setState({ isOpen: ! this.state.isOpen }); |
| 35 |
} |
| 36 |
|
| 37 |
render() { |
| 38 |
return ( |
| 39 |
<Fragment> |
| 40 |
<PanelBody |
| 41 |
title={ __( 'Manual Data' ) } |
| 42 |
initialOpen={ false } |
| 43 |
> |
| 44 |
|
| 45 |
<p>{ __( 'You can manually edit the chart data using a spreadsheet like editor.' ) }</p> |
| 46 |
|
| 47 |
<Button |
| 48 |
isPrimary |
| 49 |
isLarge |
| 50 |
isBusy={ this.state.isOpen } |
| 51 |
onClick={ this.toggleModal } |
| 52 |
> |
| 53 |
{ __( 'View Editor' ) } |
| 54 |
</Button> |
| 55 |
|
| 56 |
</PanelBody> |
| 57 |
|
| 58 |
{ this.state.isOpen && ( |
| 59 |
<Modal |
| 60 |
title={ 'Chart Editor' } |
| 61 |
onRequestClose={ this.toggleModal } |
| 62 |
shouldCloseOnClickOutside={ false } |
| 63 |
> |
| 64 |
<ChartEditor |
| 65 |
chart={ this.props.chart } |
| 66 |
editChartData={ this.props.editChartData } |
| 67 |
toggleModal={ this.toggleModal } |
| 68 |
/> |
| 69 |
</Modal> |
| 70 |
) } |
| 71 |
</Fragment> |
| 72 |
); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
export default ManualData; |
| 77 |
|