Skip to content

Commit 6f1c1df

Browse files
Merge branch 'development' of https://github.com/codeinwp/visualizer into issue-524
2 parents a46543f + 1ebad13 commit 6f1c1df

29 files changed

+665
-260
lines changed

.distignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ vendor/phpoffice/phpexcel/unitTests
2424
cypress
2525
docker-compose.travis.yml
2626
cypress.env.json.template
27-
cypress.json
27+
cypress.json
28+
.github

.github/ISSUE_TEMPLATE/Bug_report.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Bug report
3+
about: Report a bug so we can get to squashing it.
4+
5+
---
6+
7+
### Description:
8+
<!-- Describe the bug in a clear and concise way. -->
9+
10+
### How to reproduce:
11+
<!-- Describe the steps needed to reproduce this. -->
12+
1.
13+
2.
14+
3.
15+
16+
### Expected behaviour:
17+
18+
### Current behaviour:
19+
20+
### Reference:
21+
<!-- Screenshots and links that show the bug -->
22+
23+
### Technical info
24+
* WordPress version: x.x.x
25+
* Plugin version: x.x.x
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Feature request
3+
about: Suggest a feature that we can implement.
4+
5+
---
6+
7+
### Description:
8+
<!-- Describe the requested feature in a clear and concise way. -->
9+
10+
### Alternatives:
11+
<!-- If we don't implement this feature, what would be the best alternatives to achieve the same functionality? -->

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11

2+
### v3.4.3 - 2020-05-04
3+
**Changes:**
4+
* [Feat] Improved chart creation UX
5+
* [Feat] New option to control the number of charts per page in the Charts Library
6+
* [Feat] New option for filtering/ordering charts in the Charts Library
7+
* [Feat] Support for custom codes for the boolean data type in Table charts
8+
* [Fix] Support for displaying apostrophes in charts
9+
* [Fix] Visualizer button layout in the Classic block
10+
* [Fix] Bulk activation of plugin aborts activation of subsequent plugins
11+
212
### v3.4.2 - 2020-02-17
313
**Changes:**
414
* New Cypress tests for the Gutenberg block

classes/Visualizer/Gutenberg/build/block.js

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

classes/Visualizer/Gutenberg/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"react": "16.4.1",
1919
"react-google-charts": "^3.0.8",
2020
"react-json-editor-ajrm": "^2.5.8",
21+
"sprintf-js": "^1.1.2",
2122
"uuid": "^3.3.3"
2223
},
2324
"devDependencies": {

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,18 @@ class DataTables extends Component {
4646

4747
initDataTable( tableColumns, tableRow ) {
4848
const settings = this.props.options;
49-
5049
const columns = tableColumns.map( ( i, index ) => {
5150
let type = i.type;
5251

5352
switch ( i.type ) {
54-
case 'number':
55-
type = 'num';
56-
break;
57-
case 'date':
58-
case 'datetime':
59-
case 'timeofday':
60-
type = 'date';
61-
break;
53+
case 'number':
54+
type = 'num';
55+
break;
56+
case 'date':
57+
case 'datetime':
58+
case 'timeofday':
59+
type = 'date';
60+
break;
6261
}
6362

6463
return {
@@ -125,7 +124,6 @@ class DataTables extends Component {
125124
break;
126125
case 'num':
127126
const parts = [ '', '', '', '', '' ];
128-
129127
if ( settings.series[index].format.thousands ) {
130128
parts[0] = settings.series[index].format.thousands;
131129
}
@@ -143,7 +141,19 @@ class DataTables extends Component {
143141
}
144142
renderer = jQuery.fn.dataTable.render.number( ...parts );
145143
break;
146-
}
144+
case 'boolean':
145+
jQuery.fn.dataTable.render.extra = function( data, type, row ) {
146+
if ( ( true === data || 'true' === data ) && '' !== settings.series[index].format.truthy ) {
147+
return settings.series[index].format.truthy.replace( /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '' );
148+
}
149+
if ( ( false === data || 'false' === data ) && '' !== settings.series[index].format.falsy ) {
150+
return settings.series[index].format.falsy.replace( /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '' );
151+
}
152+
return data;
153+
};
154+
renderer = jQuery.fn.dataTable.render.extra;
155+
break;
156+
}
147157

148158
return renderer;
149159
}

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class ColumnSettings extends Component {
4545

4646
const series = this.props.chart['visualizer-series'];
4747

48+
const type = this.props.chart['visualizer-chart-type'];
49+
4850
return (
4951
<PanelBody
5052
title={ __( 'Column Settings' ) }
@@ -169,6 +171,36 @@ class ColumnSettings extends Component {
169171
</Fragment>
170172
) }
171173

174+
{ ( 'boolean' === series[i].type ) && ( 'dataTable' === type ) && (
175+
<Fragment>
176+
<TextControl
177+
label={ __( 'Truthy value' ) }
178+
help= { __( 'Provide the HTML entity code for the value the table should display when the value of the column is true. e.g. tick mark (Code: &#10004;) instead of true' ) }
179+
value={ settings.series[i].format ? settings.series[i].format.truthy : '' }
180+
onChange={ e => {
181+
if ( ! settings.series[i].truthy ) {
182+
settings.series[i].truthy = {};
183+
}
184+
settings.series[i].format.truthy = e;
185+
this.props.edit( settings );
186+
} }
187+
/>
188+
<TextControl
189+
label={ __( 'Falsy value' ) }
190+
help= { __( 'Provide the HTML entity code for the value the table should display when the value of the column is false. e.g. cross mark (Code: &#10006;) instead of false' ) }
191+
value={ settings.series[i].format ? settings.series[i].format.falsy : '' }
192+
onChange={ e => {
193+
if ( ! settings.series[i].falsy ) {
194+
settings.series[i].falsy = {};
195+
}
196+
settings.series[i].format.falsy = e;
197+
this.props.edit( settings );
198+
} }
199+
/>
200+
201+
</Fragment>
202+
) }
203+
172204
</PanelBody>
173205
);
174206
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class FrontendActions extends Component {
3131
render() {
3232

3333
const settings = this.props.chart['visualizer-settings'];
34+
const type = this.props.chart['visualizer-chart-type'];
3435

3536
return (
3637
<PanelBody
@@ -111,6 +112,25 @@ class FrontendActions extends Component {
111112
} }
112113
/>
113114

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+
114134
</Fragment>
115135

116136
) }

classes/Visualizer/Gutenberg/src/Editor.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const {
2929
ButtonGroup,
3030
Dashicon,
3131
Placeholder,
32+
Notice,
3233
Spinner
3334
} = wp.components;
3435

@@ -78,11 +79,20 @@ class Editor extends Component {
7879

7980
// Fetch review again if block loaded after saving.
8081
if ( this.props.attributes.id ) {
81-
let result = await apiFetch({ path: `wp/v2/visualizer/${this.props.attributes.id}` });
82-
83-
this.setState({
84-
chart: result['chart_data']
85-
});
82+
let result = await apiFetch({ path: `wp/v2/visualizer/${this.props.attributes.id}` }).catch( function( error ) {
83+
});
84+
85+
if ( result ) {
86+
this.setState({
87+
chart: result['chart_data']
88+
});
89+
} else {
90+
91+
// if the chart is not found.
92+
this.setState({
93+
route: 'error'
94+
});
95+
}
8696
}
8797
}
8898

@@ -92,6 +102,7 @@ class Editor extends Component {
92102
});
93103

94104
let result = await apiFetch({ path: `wp/v2/visualizer/${id}` });
105+
console.log( 'getChart', id, result );
95106

96107
this.setState({
97108
route: 'chartSelect',
@@ -297,6 +308,7 @@ class Editor extends Component {
297308
});
298309

299310
let result = await apiFetch({ path: `wp/v2/visualizer/${id}` });
311+
console.log( 'getChartData', id, result );
300312

301313
let chart = { ...this.state.chart };
302314

@@ -406,6 +418,18 @@ class Editor extends Component {
406418
}
407419

408420
render() {
421+
if ( 'error' === this.state.route ) {
422+
return (
423+
<Notice
424+
status="error"
425+
isDismissible={ false }
426+
>
427+
<Dashicon icon="chart-pie" />
428+
{ __( 'This chart is not available; it might have been deleted. Please delete this block and resubmit your chart.' ) }
429+
</Notice>
430+
);
431+
}
432+
409433
if ( 'renderChart' === this.state.route && null !== this.state.chart ) {
410434
return (
411435
<ChartRender

0 commit comments

Comments
 (0)