Skip to content

Commit 722d544

Browse files
Merge pull request #495 from Codeinwp/development
Add support for ChartJS Add alpha color picker for supported charts Fix issue with some options of DataTable Include DataTable charts in block editor Fix issue with import from JSON not working with some sources Add menu and onboarding page Fix issue with frontend action checkboxes Improve UX in advanced settings
2 parents 1231d31 + 6aaa3d2 commit 722d544

File tree

104 files changed

+4794
-734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4794
-734
lines changed

.travis.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
language: php
2-
php:
3-
- '7.1'
4-
- '7.0'
5-
- '5.6'
6-
- '5.5'
7-
- '5.4'
82
sudo: false
3+
dist: trusty
94
matrix:
105
fast_finish: true
116
include:
12-
- php: '5.6'
13-
install: true
14-
before_script: chmod +x bin/wraith.sh
15-
env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
16-
script: "./bin/wraith.sh"
17-
- php: '5.3'
18-
dist: precise
7+
- php: 7.2
8+
- php: 7.1
9+
- php: 7.0
10+
- php: '5.6'
11+
install: true
12+
before_script: chmod +x bin/wraith.sh
13+
env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
14+
script: "./bin/wraith.sh"
15+
- php: 5.5
16+
env: WP_VERSION=5.1
17+
- php: 5.4
18+
env: WP_VERSION=5.1
19+
- php: 5.3
20+
env: WP_VERSION=5.1
21+
dist: precise
1922
allow_failures:
2023
- env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=5
2124
branches:

classes/Visualizer/Gutenberg/Block.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ public function enqueue_gutenberg_scripts() {
7979

8080
// Enqueue the bundled block JS file
8181
wp_enqueue_script( 'handsontable', $handsontableJS );
82-
wp_enqueue_script( 'visualizer-gutenberg-block', $blockPath, array( 'wp-api', 'handsontable' ), $version, true );
82+
wp_enqueue_script( 'visualizer-gutenberg-block', $blockPath, array( 'wp-api', 'handsontable', 'visualizer-datatables', 'moment' ), $version, true );
8383

8484
$type = 'community';
8585

86-
if ( VISUALIZER_PRO ) {
86+
if ( Visualizer_Module::is_pro() ) {
8787
$type = 'pro';
8888
if ( apply_filters( 'visualizer_is_business', false ) ) {
8989
$type = 'developer';
@@ -94,12 +94,14 @@ 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(),
98+
'adminPage' => menu_page_url( 'visualizer', false ),
9799
);
98100
wp_localize_script( 'visualizer-gutenberg-block', 'visualizerLocalize', $translation_array );
99101

100102
// Enqueue frontend and editor block styles
101103
wp_enqueue_style( 'handsontable', $handsontableCSS );
102-
wp_enqueue_style( 'visualizer-gutenberg-block', $stylePath, '', $version );
104+
wp_enqueue_style( 'visualizer-gutenberg-block', $stylePath, array( 'visualizer-datatables' ), $version );
103105
}
104106
/**
105107
* Hook server side rendering into render callback
@@ -194,6 +196,8 @@ public function get_visualizer_data( $post ) {
194196

195197
$data['visualizer-chart-type'] = get_post_meta( $post_id, Visualizer_Plugin::CF_CHART_TYPE, true );
196198

199+
$data['visualizer-chart-library'] = get_post_meta( $post_id, Visualizer_Plugin::CF_CHART_LIBRARY, true );
200+
197201
$data['visualizer-source'] = get_post_meta( $post_id, Visualizer_Plugin::CF_SOURCE, true );
198202

199203
$data['visualizer-default-data'] = get_post_meta( $post_id, Visualizer_Plugin::CF_DEFAULT_DATA, true );
@@ -219,7 +223,7 @@ public function get_visualizer_data( $post ) {
219223
$data['visualizer-chart-schedule'] = $schedule;
220224
}
221225

222-
if ( VISUALIZER_PRO ) {
226+
if ( Visualizer_Module::is_pro() ) {
223227
$permissions = get_post_meta( $post_id, Visualizer_PRO::CF_PERMISSIONS, true );
224228

225229
if ( ! empty( $permissions ) ) {
@@ -250,7 +254,7 @@ public function update_chart_data( $data ) {
250254
apply_filters( 'visualizer_pro_remove_schedule', $data['id'] );
251255
}
252256

253-
if ( VISUALIZER_PRO ) {
257+
if ( Visualizer_Module::is_pro() ) {
254258
update_post_meta( $data['id'], Visualizer_PRO::CF_PERMISSIONS, $data['visualizer-permissions'] );
255259
}
256260

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: 19 additions & 19 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.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/handsontable.js

Lines changed: 4 additions & 4 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/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/ChartRender.js

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*/
44
import { Chart } from 'react-google-charts';
55

6+
import DataTable from './DataTable.js';
7+
68
import merge from 'merge';
79

810
import { compact, formatDate, isValidJSON } from '../utils.js';
@@ -34,13 +36,16 @@ class ChartRender extends Component {
3436
}
3537

3638
render() {
37-
3839
let chart;
3940

4041
let data = formatDate( JSON.parse( JSON.stringify( this.props.chart ) ) );
4142

42-
if ( 0 <= [ 'gauge', 'table', 'timeline' ].indexOf( this.props.chart['visualizer-chart-type']) ) {
43-
chart = startCase( this.props.chart['visualizer-chart-type']);
43+
if ( 0 <= [ 'gauge', 'table', 'timeline', 'dataTable' ].indexOf( this.props.chart['visualizer-chart-type']) ) {
44+
if ( 'dataTable' === data['visualizer-chart-type']) {
45+
chart = data['visualizer-chart-type'];
46+
} else {
47+
chart = startCase( this.props.chart['visualizer-chart-type']);
48+
}
4449
} else {
4550
chart = `${ startCase( this.props.chart['visualizer-chart-type']) }Chart`;
4651
}
@@ -66,17 +71,26 @@ class ChartRender extends Component {
6671
</Toolbar>
6772
</BlockControls>
6873

69-
<Chart
70-
chartType={ chart }
71-
rows={ data['visualizer-data'] }
72-
columns={ data['visualizer-series'] }
73-
options={
74-
isValidJSON( this.props.chart['visualizer-settings'].manual ) ?
75-
merge( compact( this.props.chart['visualizer-settings']), JSON.parse( this.props.chart['visualizer-settings'].manual ) ) :
76-
compact( this.props.chart['visualizer-settings'])
77-
}
78-
height="500px"
79-
/>
74+
{ ( 'dataTable' === chart ) ? (
75+
<DataTable
76+
id={ this.props.id }
77+
rows={ data['visualizer-data'] }
78+
columns={ data['visualizer-series'] }
79+
options={ data['visualizer-settings'] }
80+
/>
81+
) : (
82+
<Chart
83+
chartType={ chart }
84+
rows={ data['visualizer-data'] }
85+
columns={ data['visualizer-series'] }
86+
options={
87+
isValidJSON( this.props.chart['visualizer-settings'].manual ) ?
88+
merge( compact( this.props.chart['visualizer-settings']), JSON.parse( this.props.chart['visualizer-settings'].manual ) ) :
89+
compact( this.props.chart['visualizer-settings'])
90+
}
91+
height="500px"
92+
/>
93+
) }
8094

8195
</Fragment>
8296
}

0 commit comments

Comments
 (0)