Skip to content

Commit 9bbcee3

Browse files
Merge pull request #696 from contactashish13/issue-267-pro
Last column options disappear after editing the column in the GB block
2 parents 1ebad13 + ed41b2b commit 9bbcee3

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

classes/Visualizer/Gutenberg/build/block.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.

classes/Visualizer/Gutenberg/src/Editor.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class Editor extends Component {
102102
});
103103

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

107106
this.setState({
108107
route: 'chartSelect',
@@ -308,7 +307,6 @@ class Editor extends Component {
308307
});
309308

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

313311
let chart = { ...this.state.chart };
314312

@@ -323,10 +321,11 @@ class Editor extends Component {
323321
});
324322
}
325323

326-
editChartData( chartData, type ) {
324+
editChartData( chartData, source ) {
327325
let chart = { ...this.state.chart };
328326
let series = [];
329327
let settings = { ...chart['visualizer-settings'] };
328+
let type = chart['visualizer-chart-type'];
330329
chartData[0].map( ( i, index ) => {
331330
series[index] = {
332331
label: i,
@@ -339,17 +338,17 @@ class Editor extends Component {
339338
let map = series;
340339
let fieldName = 'series';
341340

342-
if ( 'pie' === chart['visualizer-chart-type']) {
341+
if ( 'pie' === type ) {
343342
map = chartData;
344343
fieldName = 'slices';
345344
}
346345

347346
map.map( ( i, index ) => {
348-
if ( 'pie' !== chart['visualizer-chart-type'] && 0 === index ) {
347+
if ( 'pie' !== type && 0 === index ) {
349348
return;
350349
}
351350

352-
const seriesIndex = 'pie' !== chart['visualizer-chart-type'] ? index - 1 : index;
351+
const seriesIndex = 'pie' !== type ? index - 1 : index;
353352

354353
if ( settings[fieldName][seriesIndex] === undefined ) {
355354
settings[fieldName][seriesIndex] = {};
@@ -358,11 +357,11 @@ class Editor extends Component {
358357
});
359358

360359
settings[fieldName] = settings[fieldName].filter( ( i, index ) => {
361-
const length = 'pie' !== chart['visualizer-chart-type'] ? map.length - 1 : map.length;
360+
const length = -1 >= [ 'pie', 'tabular', 'dataTable' ].indexOf( type ) ? map.length - 1 : map.length;
362361
return index < length;
363362
});
364363

365-
chart['visualizer-source'] = type;
364+
chart['visualizer-source'] = source;
366365
chart['visualizer-default-data'] = 0;
367366
chart['visualizer-data'] = chartData;
368367
chart['visualizer-series'] = series;

0 commit comments

Comments
 (0)