Skip to content

Commit de0e966

Browse files
Merge branch 'development' of https://github.com/codeinwp/visualizer into issue-268-pro
2 parents 53d87e8 + 5644800 commit de0e966

File tree

11 files changed

+195
-34
lines changed

11 files changed

+195
-34
lines changed

bin/wp-init.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,30 @@ echo "Sleeping for $sleep_time..."
1818
sleep $sleep_time
1919

2020
# install WP
21-
docker exec $args visualizer_wordpress wp --quiet core install --url="http://$wp_host:8888/" --admin_user="wordpress" --admin_password="wordpress" --admin_email="[email protected]" --title="test" --skip-email
21+
docker exec $args visualizer_wordpress wp --allow-root core install --url="http://$wp_host:8888/" --admin_user="wordpress" --admin_password="wordpress" --admin_email="[email protected]" --title="test" --skip-email
2222

23-
# install required external plugins
23+
# update core
2424
docker exec $args visualizer_wordpress chown -R www-data:www-data /var/www/html/
25-
docker exec $args visualizer_wordpress wp plugin install classic-editor --activate
26-
27-
# so that debug.log is created
2825
docker exec $args visualizer_wordpress chmod 0777 -R /var/www/html/wp-content
26+
docker exec $args visualizer_wordpress wp --allow-root core update
27+
docker exec $args visualizer_wordpress wp --allow-root core update-db
28+
29+
# install required external plugins
30+
docker exec $args visualizer_wordpress wp plugin install classic-editor --activate
2931

3032
# install visualizer free
3133
docker exec $args visualizer_wordpress git clone https://github.com/Codeinwp/visualizer /var/www/html/wp-content/plugins/visualizer
3234

3335
# activate
34-
docker exec $args visualizer_wordpress wp --quiet plugin activate visualizer
36+
docker exec $args visualizer_wordpress wp --allow-root plugin activate visualizer
3537

3638
# set this constant so that the license is not checked
37-
docker exec $args visualizer_wordpress wp --quiet config set TI_UNIT_TESTING true --raw
39+
docker exec $args visualizer_wordpress wp --allow-root config set TI_UNIT_TESTING true --raw
3840

3941
# set this constant so that the specific hooks are loaded
40-
docker exec $args visualizer_wordpress wp --quiet config set TI_CYPRESS_TESTING true --raw
42+
docker exec $args visualizer_wordpress wp --allow-root config set TI_CYPRESS_TESTING true --raw
4143

4244
# debugging
43-
docker exec $args visualizer_wordpress wp --quiet config set WP_DEBUG true --raw
44-
docker exec $args visualizer_wordpress wp --quiet config set WP_DEBUG_LOG true --raw
45-
docker exec $args visualizer_wordpress wp --quiet config set WP_DEBUG_DISPLAY false --raw
46-
45+
docker exec $args visualizer_wordpress wp --allow-root config set WP_DEBUG true --raw
46+
docker exec $args visualizer_wordpress wp --allow-root config set WP_DEBUG_LOG true --raw
47+
docker exec $args visualizer_wordpress wp --allow-root config set WP_DEBUG_DISPLAY false --raw

classes/Visualizer/Gutenberg/build/block.js

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class ChartSelect extends Component {
112112

113113
<PanelButton
114114
label={ __( 'Advanced Options' ) }
115+
className="visualizer-advanced-options"
115116
icon="admin-tools"
116117
onClick={ () => this.setState({ route: 'showAdvanced' }) }
117118
/>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import RowCellSettings from './Sidebar/RowCellSettings.js';
2020
import ComboSettings from './Sidebar/ComboSettings.js';
2121
import SeriesSettings from './Sidebar/SeriesSettings.js';
2222
import SlicesSettings from './Sidebar/SlicesSettings.js';
23+
import BubbleSettings from './Sidebar/BubbleSettings.js';
2324
import ColumnSettings from './Sidebar/ColumnSettings.js';
2425
import LayoutAndChartArea from './Sidebar/LayoutAndChartArea.js';
2526
import FrontendActions from './Sidebar/FrontendActions.js';
@@ -113,10 +114,15 @@ class Sidebar extends Component {
113114
<ComboSettings chart={ this.props.chart } edit={ this.props.edit } />
114115
) }
115116

116-
{ ( -1 >= [ 'timeline', 'gauge', 'geo', 'pie', 'dataTable' ].indexOf( type ) ) && (
117+
{ ( -1 >= [ 'timeline', 'bubble', 'gauge', 'geo', 'pie', 'dataTable' ].indexOf( type ) ) && (
117118
<SeriesSettings chart={ this.props.chart } edit={ this.props.edit } />
118119
) }
119120

121+
{ ( 0 <= [ 'bubble' ].indexOf( type ) ) && (
122+
<BubbleSettings chart={ this.props.chart } edit={ this.props.edit } />
123+
) }
124+
125+
120126
{ ( 0 <= [ 'pie' ].indexOf( type ) ) && (
121127
<SlicesSettings chart={ this.props.chart } edit={ this.props.edit } />
122128
) }
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
const { __ } = wp.i18n;
5+
6+
const { Component } = wp.element;
7+
8+
const { ColorPalette } = wp.blockEditor || wp.editor;
9+
10+
import { isChecked } from '../../utils.js';
11+
12+
const {
13+
CheckboxControl,
14+
BaseControl,
15+
PanelBody,
16+
TextControl
17+
} = wp.components;
18+
19+
class BubbleSettings extends Component {
20+
constructor() {
21+
super( ...arguments );
22+
}
23+
24+
componentDidMount() {
25+
26+
}
27+
28+
render() {
29+
30+
const settings = this.props.chart['visualizer-settings'];
31+
32+
return (
33+
<PanelBody
34+
title={ __( 'Bubble Settings' ) }
35+
initialOpen={ false }
36+
className="visualizer-advanced-panel"
37+
>
38+
39+
<TextControl
40+
label={ __( 'Opacity' ) }
41+
help={ __( 'The default opacity of the bubbles, where 0.0 is fully transparent and 1.0 is fully opaque.' ) }
42+
type="number"
43+
min="0"
44+
max="1"
45+
step="0.1"
46+
value={ settings.bubble.opacity }
47+
onChange={ e => {
48+
if ( ! settings.bubble ) {
49+
settings.bubble = {};
50+
}
51+
settings.bubble.opacity = e;
52+
this.props.edit( settings );
53+
} }
54+
/>
55+
56+
<BaseControl
57+
label={ __( 'Stroke Color' ) }
58+
>
59+
<ColorPalette
60+
value={ settings.bubble.stroke }
61+
onChange={ e => {
62+
if ( ! settings.bubble ) {
63+
settings.bubble = {};
64+
}
65+
settings.bubble.stroke = e;
66+
this.props.edit( settings );
67+
} }
68+
/>
69+
</BaseControl>
70+
71+
<CheckboxControl
72+
label={ __( 'Sort Bubbles by Size' ) }
73+
help={ __( 'If checked, sorts the bubbles by size so the smaller bubbles appear above the larger bubbles. If unchecked, bubbles are sorted according to their order in the table.' ) }
74+
checked={ isChecked( settings, 'sortBubblesBySize' ) }
75+
onChange={ e => {
76+
settings.sortBubblesBySize = e;
77+
this.props.edit( settings );
78+
} }
79+
/>
80+
81+
<TextControl
82+
label={ __( 'Size (max)' ) }
83+
help={ __( 'The size value (as appears in the chart data) to be mapped to sizeAxis.maxSize. Larger values will be cropped to this value.' ) }
84+
type="number"
85+
step="1"
86+
value={ settings.sizeAxis.maxValue }
87+
onChange={ e => {
88+
if ( ! settings.sizeAxis ) {
89+
settings.sizeAxis = {};
90+
}
91+
settings.sizeAxis.maxValue = e;
92+
this.props.edit( settings );
93+
} }
94+
/>
95+
96+
<TextControl
97+
label={ __( 'Size (min)' ) }
98+
help={ __( 'The size value (as appears in the chart data) to be mapped to sizeAxis.minSize. Smaller values will be cropped to this value.' ) }
99+
type="number"
100+
step="1"
101+
value={ settings.sizeAxis.minValue }
102+
onChange={ e => {
103+
if ( ! settings.sizeAxis ) {
104+
settings.sizeAxis = {};
105+
}
106+
settings.sizeAxis.minValue = e;
107+
this.props.edit( settings );
108+
} }
109+
/>
110+
111+
</PanelBody>
112+
);
113+
}
114+
}
115+
116+
export default BubbleSettings;

classes/Visualizer/Gutenberg/src/Components/Sidebar/GeneralSettings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class GeneralSettings extends Component {
230230
</PanelBody>
231231
) }
232232

233-
{ ( -1 >= [ 'table', 'gauge', 'geo', 'dataTable' ].indexOf( type ) ) && (
233+
{ ( -1 >= [ 'table', 'gauge', 'geo', 'dataTable', 'timeline' ].indexOf( type ) ) && (
234234
<PanelBody
235235
title={ __( 'Tooltip' ) }
236236
className="visualizer-inner-sections"

classes/Visualizer/Gutenberg/src/Editor.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,18 @@ class Editor extends Component {
401401
fieldName = 'slices';
402402
}
403403

404-
Object.keys( data['visualizer-settings'][fieldName])
405-
.map( i => {
406-
if ( data['visualizer-settings'][fieldName][i] !== undefined ) {
407-
if ( data['visualizer-settings'][fieldName][i].temp !== undefined ) {
408-
delete data['visualizer-settings'][fieldName][i].temp;
409-
}
410-
}
411-
}
412-
);
404+
// no series for bubble and timeline charts.
405+
if ( -1 >= [ 'bubble', 'timeline' ].indexOf( data['visualizer-chart-type']) ) {
406+
Object.keys( data['visualizer-settings'][fieldName])
407+
.map( i => {
408+
if ( data['visualizer-settings'][fieldName][i] !== undefined ) {
409+
if ( data['visualizer-settings'][fieldName][i].temp !== undefined ) {
410+
delete data['visualizer-settings'][fieldName][i].temp;
411+
}
412+
}
413+
}
414+
);
415+
}
413416

414417
apiRequest({ path: `/visualizer/v1/update-chart?id=${ this.props.attributes.id }`, method: 'POST', data: data }).then(
415418
( data ) => {
@@ -568,6 +571,7 @@ class Editor extends Component {
568571
<Button
569572
isDefault
570573
isLarge
574+
className="visualizer-bttn-done"
571575
onClick={ () => {
572576
this.setState({ route: 'renderChart' });
573577
this.props.setAttributes({ route: 'renderChart' });
@@ -578,6 +582,7 @@ class Editor extends Component {
578582
<Button
579583
isPrimary
580584
isLarge
585+
className="visualizer-bttn-save"
581586
isBusy={ 'updateChart' === this.state.isLoading }
582587
disabled={ 'updateChart' === this.state.isLoading }
583588
onClick={ this.updateChart }

classes/Visualizer/Gutenberg/src/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,8 @@ export const CSVToArray = ( strData, strDelimiter ) => {
9292

9393
return ( arrData );
9494
};
95+
96+
97+
export const isChecked = ( settings, param ) => {
98+
return true === settings[param] || 'true' === settings[param] || '1' === settings[param] || 1 === settings[param];
99+
};

classes/Visualizer/Render/Sidebar/Type/GoogleCharts/Bubble.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function _renderBubbleSettings() {
8181
self::_renderColorPickerItem(
8282
esc_html__( 'Stroke Color', 'visualizer' ),
8383
'bubble[stroke]',
84-
isset( $this->bubble[ $index ]['stroke'] ) ? $this->bubble[ $index ]['stroke'] : null,
84+
isset( $this->bubble['stroke'] ) ? $this->bubble['stroke'] : null,
8585
null
8686
);
8787

@@ -90,7 +90,7 @@ protected function _renderBubbleSettings() {
9090
'sortBubblesBySize',
9191
$this->sortBubblesBySize ? 1 : 0,
9292
1,
93-
esc_html__( 'If true, sorts the bubbles by size so the smaller bubbles appear above the larger bubbles. If false, bubbles are sorted according to their order in the DataTable.', 'visualizer' )
93+
esc_html__( 'If checked, sorts the bubbles by size so the smaller bubbles appear above the larger bubbles. If unchecked, bubbles are sorted according to their order in the table.', 'visualizer' )
9494
);
9595

9696
self::_renderTextItem(

cypress/integration/free-gutenberg.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ describe('Test Free - gutenberg', function() {
1616
it('Verify insertion of charts', function() {
1717
cy.visit('/post-new.php');
1818

19-
// get rid of that irritating popup
20-
cy.get('.nux-dot-tip__disable').click();
19+
cy.clear_welcome();
2120

2221
var charts = [];
2322
for(var i = 1; i <= parseInt(Cypress.env('chart_types').free); i++){
@@ -34,16 +33,36 @@ describe('Test Free - gutenberg', function() {
3433
});
3534

3635
// see the block has the correct elements.
37-
cy.get('div[data-type="visualizer/chart"]').should('have.length', (i + 1));
36+
cy.get('div[data-type="visualizer/chart"]').should('have.length', (i + 2));
3837

3938
cy.get('div[data-type="visualizer/chart"]:nth-child(' + (i + 1) + ')').then( ($block) => {
39+
// 2 rows - create and insert
4040
cy.wrap($block).find('.visualizer-settings__content-option').should('have.length', 2);
41+
42+
// click insert
4143
cy.wrap($block).find('.visualizer-settings__content-option').last().click({force:true});
4244

45+
// insert chart
4346
cy.wrap($block).find('.visualizer-settings .visualizer-settings__charts-single:nth-child(' + (i + 1) + ') .visualizer-settings__charts-controls').click();
47+
4448
cy.wrap($block).find('.visualizer-settings .visualizer-settings__chart').should('have.length', 1);
49+
50+
// chart and footer divs
4551
cy.wrap($block).find('.visualizer-settings .visualizer-settings__chart > div').should('have.length', 2);
52+
53+
// 2 buttons, one of them "done"
4654
cy.wrap($block).find('.visualizer-settings .components-button-group button').should('have.length', 2);
55+
cy.wrap($block).find('.visualizer-settings .components-button-group button.visualizer-bttn-done').should('have.length', 1);
56+
57+
// click advanced options
58+
cy.get('.visualizer-advanced-options button.components-button').click({force:true});
59+
60+
// done button disappears, save button appears
61+
cy.wrap($block).find('.visualizer-settings .components-button-group button.visualizer-bttn-done').should('have.length', 0);
62+
cy.wrap($block).find('.visualizer-settings .components-button-group button.visualizer-bttn-save').should('have.length', 1);
63+
64+
// click save button
65+
cy.wrap($block).find('.visualizer-settings .components-button-group button.visualizer-bttn-save').click({force:true});
4766
});
4867
});
4968
});

0 commit comments

Comments
 (0)