PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.7.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.7.0
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / classes / Visualizer / Gutenberg / src / Components / Sidebar / FrontendActions.js

FrontendActions.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.7.0, at classes/Visualizer/Gutenberg/src/Components/Sidebar/FrontendActions.js

144 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 const { __ } = wp.i18n;
5
6 const {
7 Component,
8 Fragment
9 } = wp.element;
10
11 const {
12 CheckboxControl,
13 PanelBody
14 } = wp.components;
15
16 class FrontendActions extends Component {
17 constructor() {
18 super( ...arguments );
19 }
20
21 componentDidMount() {
22 const settings = this.props.chart['visualizer-settings'];
23
24 if ( settings.actions === undefined ) {
25 settings.actions = [];
26 }
27
28 this.props.edit( settings );
29 }
30
31 render() {
32
33 const settings = this.props.chart['visualizer-settings'];
34 const type = this.props.chart['visualizer-chart-type'];
35
36 return (
37 <PanelBody
38 title={ __( 'Frontend Actions' ) }
39 initialOpen={ false }
40 className="visualizer-advanced-panel"
41 >
42
43 { ( settings.actions !== undefined &&
44
45 <Fragment>
46
47 <CheckboxControl
48 label={ __( 'Print' ) }
49 help={ __( 'To enable printing the data.' ) }
50 checked={ ( 0 <= settings.actions.indexOf( 'print' ) ) }
51 onChange={ e => {
52 if ( 0 <= settings.actions.indexOf( 'print' ) ) {
53 const index = settings.actions.indexOf( 'print' );
54 if ( -1 !== index ) {
55 settings.actions.splice( index, 1 );
56 }
57 } else {
58 settings.actions.push( 'print' );
59 }
60 this.props.edit( settings );
61 } }
62 />
63
64 <CheckboxControl
65 label={ __( 'CSV' ) }
66 help={ __( 'To enable downloading the data as a CSV.' ) }
67 checked={ ( 0 <= settings.actions.indexOf( 'csv;application/csv' ) ) }
68 onChange={ e => {
69 if ( 0 <= settings.actions.indexOf( 'csv;application/csv' ) ) {
70 const index = settings.actions.indexOf( 'csv;application/csv' );
71 if ( -1 !== index ) {
72 settings.actions.splice( index, 1 );
73 }
74 } else {
75 settings.actions.push( 'csv;application/csv' );
76 }
77 this.props.edit( settings );
78 } }
79 />
80
81 <CheckboxControl
82 label={ __( 'Excel' ) }
83 help={ __( 'To enable downloading the data as an Excel spreadsheet.' ) }
84 checked={ ( 0 <= settings.actions.indexOf( 'xls;application/vnd.ms-excel' ) ) }
85 onChange={ e => {
86 if ( 0 <= settings.actions.indexOf( 'xls;application/vnd.ms-excel' ) ) {
87 const index = settings.actions.indexOf( 'xls;application/vnd.ms-excel' );
88 if ( -1 !== index ) {
89 settings.actions.splice( index, 1 );
90 }
91 } else {
92 settings.actions.push( 'xls;application/vnd.ms-excel' );
93 }
94 this.props.edit( settings );
95 } }
96 />
97
98 <CheckboxControl
99 label={ __( 'Copy' ) }
100 help={ __( 'To enable copying the data to the clipboard.' ) }
101 checked={ ( 0 <= settings.actions.indexOf( 'copy' ) ) }
102 onChange={ e => {
103 if ( 0 <= settings.actions.indexOf( 'copy' ) ) {
104 const index = settings.actions.indexOf( 'copy' );
105 if ( -1 !== index ) {
106 settings.actions.splice( index, 1 );
107 }
108 } else {
109 settings.actions.push( 'copy' );
110 }
111 this.props.edit( settings );
112 } }
113 />
114
115 { ( -1 >= [ 'dataTable', 'tabular', 'gauge', 'table' ].indexOf( type ) ) && (
116 <CheckboxControl
117 label={ __( 'Download Image' ) }
118 help={ __( 'To download the chart as an image.' ) }
119 checked={ ( 0 <= settings.actions.indexOf( 'image' ) ) }
120 onChange={ e => {
121 if ( 0 <= settings.actions.indexOf( 'image' ) ) {
122 const index = settings.actions.indexOf( 'image' );
123 if ( -1 !== index ) {
124 settings.actions.splice( index, 1 );
125 }
126 } else {
127 settings.actions.push( 'image' );
128 }
129 this.props.edit( settings );
130 } }
131 />
132 ) }
133
134 </Fragment>
135
136 ) }
137
138 </PanelBody>
139 );
140 }
141 }
142
143 export default FrontendActions;
144