Skip to content

Commit f4c5adc

Browse files
committed
Added DataTable
Added proper integration for DataTable.
1 parent ac99b97 commit f4c5adc

File tree

14 files changed

+143
-38
lines changed

14 files changed

+143
-38
lines changed

classes/Visualizer/Gutenberg/Block.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public function enqueue_gutenberg_scripts() {
9494
'isPro' => $type,
9595
'proTeaser' => Visualizer_Plugin::PRO_TEASER_URL,
9696
'absurl' => VISUALIZER_ABSURL,
97+
'charts' => Visualizer_Module_Admin::_getChartTypesLocalized()
9798
);
9899
wp_localize_script( 'visualizer-gutenberg-block', 'visualizerLocalize', $translation_array );
99100

classes/Visualizer/Gutenberg/build/block.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/Visualizer/Gutenberg/build/block.js

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
66.3 KB
Loading

classes/Visualizer/Gutenberg/build/handsontable.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
66.3 KB
Loading

classes/Visualizer/Gutenberg/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"eslint-config-wordpress": "^2.0.0",
3434
"eslint-loader": "^2.1.1",
3535
"eslint-plugin-react": "^7.11.1",
36+
"file-loader": "^4.0.0",
3637
"mini-css-extract-plugin": "^0.4.4",
3738
"node-sass": "^4.10.0",
3839
"postcss-loader": "^3.0.0",

classes/Visualizer/Gutenberg/src/Components/Charts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class Charts extends Component {
145145
}) }
146146
</div>
147147

148-
{ ! chartsLoaded && (
148+
{ ! chartsLoaded && 5 < charts.length && (
149149
<Button
150150
isPrimary
151151
isLarge
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import classnames from 'classnames';
5+
6+
/**
7+
* WordPress dependencies
8+
*/
9+
const { startCase } = lodash;
10+
11+
const { __ } = wp.i18n;
12+
13+
const { apiFetch } = wp;
14+
15+
const {
16+
Component,
17+
Fragment
18+
} = wp.element;
19+
20+
const {
21+
Button,
22+
Dashicon,
23+
Placeholder,
24+
Spinner
25+
} = wp.components;
26+
27+
class CreateCharts extends Component {
28+
constructor() {
29+
super( ...arguments );
30+
}
31+
32+
render() {
33+
34+
return (
35+
<div className="visualizer-settings__charts">
36+
<div className="visualizer-settings__charts-grid">
37+
38+
{ Object.keys( visualizerLocalize.charts ).map( i => {
39+
return (
40+
<div className="visualizer-settings__charts-single">
41+
<div className="visualizer-settings__charts-title">
42+
{ visualizerLocalize.charts[i].name }
43+
</div>
44+
45+
<div
46+
className={ classnames(
47+
'visualizer-settings__create-charts',
48+
`type-box-${ i }`
49+
) }
50+
>
51+
</div>
52+
53+
<div
54+
className="visualizer-settings__charts-controls"
55+
title={ __( 'Insert Chart' ) }
56+
57+
>
58+
<Dashicon icon="upload"></Dashicon>
59+
</div>
60+
</div>
61+
);
62+
}) }
63+
64+
</div>
65+
</div>
66+
);
67+
}
68+
}
69+
70+
export default CreateCharts;

classes/Visualizer/Gutenberg/src/Components/DataTable.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ class DataTables extends Component {
9696
dataRenderer( data, type, index ) {
9797
const settings = this.props.options;
9898

99+
if ( undefined === settings.series[index]) {
100+
return data;
101+
}
102+
99103
if ( 'date' === type || 'datetime' === type || 'timeofday' === type ) {
100104
if ( settings.series[index].format && settings.series[index].format.from && settings.series[index].format.to ) {
101105
return $.fn.dataTable.render.moment( settings.series[index].format.from, settings.series[index].format.to );
@@ -107,23 +111,23 @@ class DataTables extends Component {
107111
if ( 'num' === type ) {
108112
const parts = [ '', '', '', '', '' ];
109113

110-
if ( '' !== typeof settings.series[index].format.thousands ) {
114+
if ( settings.series[index].format.thousands ) {
111115
parts[0] = settings.series[index].format.thousands;
112116
}
113117

114-
if ( '' !== typeof settings.series[index].format.decimal ) {
118+
if ( settings.series[index].format.decimal ) {
115119
parts[1] = settings.series[index].format.decimal;
116120
}
117121

118-
if ( '' !== typeof settings.series[index].format.precision ) {
122+
if ( settings.series[index].format.precision ) {
119123
parts[2] = settings.series[index].format.precision;
120124
}
121125

122-
if ( '' !== typeof settings.series[index].format.prefix ) {
126+
if ( settings.series[index].format.prefix ) {
123127
parts[3] = settings.series[index].format.prefix;
124128
}
125129

126-
if ( '' !== typeof settings.series[index].format.suffix ) {
130+
if ( settings.series[index].format.suffix ) {
127131
parts[4] = settings.series[index].format.suffix;
128132
}
129133

0 commit comments

Comments
 (0)