Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions classes/Visualizer/Gutenberg/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private function __construct() {
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_gutenberg_scripts' ) );
add_action( 'init', array( $this, 'register_block_type' ) );
add_action( 'rest_api_init', array( $this, 'register_rest_endpoints' ) );
add_filter( 'rest_visualizer_query', array( $this, 'add_rest_query_vars' ), 9, 2 );
}

/**
Expand Down Expand Up @@ -413,4 +414,15 @@ public function get_permission_data( $data ) {
return $options;
}

/**
* Filter Rest Query
*/
public function add_rest_query_vars( $args, \WP_REST_Request $request ) {
if ( isset( $request['meta_key'] ) && isset( $request['meta_value'] ) ) {
$args['meta_key'] = $request->get_param( 'meta_key' );
$args['meta_value'] = $request->get_param( 'meta_value' );
$args['meta_compare'] = '!=';
}
return $args;
}
}
2 changes: 1 addition & 1 deletion classes/Visualizer/Gutenberg/build/block.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 13 additions & 19 deletions classes/Visualizer/Gutenberg/build/block.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions classes/Visualizer/Gutenberg/build/handsontable.js

Large diffs are not rendered by default.

Binary file not shown.
3 changes: 2 additions & 1 deletion classes/Visualizer/Gutenberg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"merge": "^1.2.1",
"react": "16.4.1",
"react-google-charts": "^3.0.8",
"react-json-editor-ajrm": "^2.5.8"
"react-json-editor-ajrm": "^2.5.8",
"uuid": "^3.3.3"
},
"devDependencies": {
"@babel/core": "^7.1.6",
Expand Down
4 changes: 2 additions & 2 deletions classes/Visualizer/Gutenberg/src/Components/Charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Charts extends Component {
async componentDidMount() {

// Fetch review again if block loaded after saving.
let result = await apiFetch({ path: 'wp/v2/visualizer/?per_page=6' });
let result = await apiFetch({ path: 'wp/v2/visualizer/?per_page=6&meta_key=visualizer-chart-library&meta_value=ChartJS' });
this.setState({ charts: result });
}

Expand All @@ -56,7 +56,7 @@ class Charts extends Component {

this.setState({ isBusy: true });

let result = await apiFetch({ path: `wp/v2/visualizer/?per_page=6&offset=${ offset }` });
let result = await apiFetch({ path: `wp/v2/visualizer/?per_page=6&meta_key=visualizer-chart-library&meta_value=ChartJS&offset=${ offset }` });

if ( 6 > result.length ) {
chartsLoaded = true;
Expand Down
70 changes: 0 additions & 70 deletions classes/Visualizer/Gutenberg/src/Components/CreateCharts.js

This file was deleted.

56 changes: 34 additions & 22 deletions classes/Visualizer/Gutenberg/src/Components/DataTable.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import uuidv4 from 'uuid';

/**
* WordPress dependencies
*/
Expand All @@ -14,6 +19,7 @@ class DataTables extends Component {
this.dataRenderer = this.dataRenderer.bind( this );

this.table;
this.uniqueId = uuidv4();
}

componentDidMount() {
Expand All @@ -28,12 +34,12 @@ class DataTables extends Component {
if ( this.props !== prevProps ) {
if ( this.props.options.responsive_bool !== prevProps.options.responsive_bool ) {
if ( 'true' === prevProps.options.responsive_bool ) {
document.getElementById( `dataTable-instances-${ this.props.id }` ).classList.remove( 'collapsed' );
document.getElementById( `dataTable-instances-${ this.props.id }-${ this.uniqueId }` ).classList.remove( 'collapsed' );
}
}

this.table.destroy();
document.getElementById( `dataTable-instances-${ this.props.id }` ).innerHTML = '';
document.getElementById( `dataTable-instances-${ this.props.id }-${ this.uniqueId }` ).innerHTML = '';
this.initDataTable( this.props.columns, this.props.rows );
}
}
Expand Down Expand Up @@ -73,7 +79,7 @@ class DataTables extends Component {
return row;
});

this.table = jQuery( `#dataTable-instances-${ this.props.id }` ).DataTable({
this.table = jQuery( `#dataTable-instances-${ this.props.id }-${ this.uniqueId }` ).DataTable({
destroy: true,
data: data,
columns: columns,
Expand Down Expand Up @@ -144,28 +150,34 @@ class DataTables extends Component {
<Fragment>
{ settings.customcss && (
<style>
{ `#dataTable-instances-${ this.props.id } tr.odd {
${ settings.customcss.oddTableRow.color ? `color: ${ settings.customcss.oddTableRow.color } !important;` : '' }
${ settings.customcss.oddTableRow['background-color'] ? `background-color: ${ settings.customcss.oddTableRow['background-color'] } !important;` : '' }
${ settings.customcss.oddTableRow.transform ? `transform: rotate( ${ settings.customcss.oddTableRow.transform }deg ) !important;` : '' }
}

#dataTable-instances-${ this.props.id } tr.even {
${ settings.customcss.evenTableRow.color ? `color: ${ settings.customcss.evenTableRow.color } !important;` : '' }
${ settings.customcss.evenTableRow['background-color'] ? `background-color: ${ settings.customcss.evenTableRow['background-color'] } !important;` : '' }
${ settings.customcss.evenTableRow.transform ? `transform: rotate( ${ settings.customcss.evenTableRow.transform }deg ) !important;` : '' }
}

#dataTable-instances-${ this.props.id } tr td,
#dataTable-instances-${ this.props.id }_wrapper tr th {
${ settings.customcss.tableCell.color ? `color: ${ settings.customcss.tableCell.color } !important;` : '' }
${ settings.customcss.tableCell['background-color'] ? `background-color: ${ settings.customcss.tableCell['background-color'] } !important;` : '' }
${ settings.customcss.tableCell.transform ? `transform: rotate( ${ settings.customcss.tableCell.transform }deg ) !important;` : '' }
}` }
{ settings.customcss.oddTableRow && (
`#dataTable-instances-${ this.props.id }-${ this.uniqueId } tr.odd {
${ settings.customcss.oddTableRow.color ? `color: ${ settings.customcss.oddTableRow.color } !important;` : '' }
${ settings.customcss.oddTableRow['background-color'] ? `background-color: ${ settings.customcss.oddTableRow['background-color'] } !important;` : '' }
${ settings.customcss.oddTableRow.transform ? `transform: rotate( ${ settings.customcss.oddTableRow.transform }deg ) !important;` : '' }
}`
)}

{ settings.customcss.evenTableRow && (
`#dataTable-instances-${ this.props.id }-${ this.uniqueId } tr.even {
${ settings.customcss.evenTableRow.color ? `color: ${ settings.customcss.evenTableRow.color } !important;` : '' }
${ settings.customcss.evenTableRow['background-color'] ? `background-color: ${ settings.customcss.evenTableRow['background-color'] } !important;` : '' }
${ settings.customcss.evenTableRow.transform ? `transform: rotate( ${ settings.customcss.evenTableRow.transform }deg ) !important;` : '' }
}`
)}

{ settings.customcss.tableCell && (
`#dataTable-instances-${ this.props.id }-${ this.uniqueId } tr td,
#dataTable-instances-${ this.props.id }-${ this.uniqueId }_wrapper tr th {
${ settings.customcss.tableCell.color ? `color: ${ settings.customcss.tableCell.color } !important;` : '' }
${ settings.customcss.tableCell['background-color'] ? `background-color: ${ settings.customcss.tableCell['background-color'] } !important;` : '' }
${ settings.customcss.tableCell.transform ? `transform: rotate( ${ settings.customcss.tableCell.transform }deg ) !important;` : '' }
}`
)}
</style>
) }

<table id={ `dataTable-instances-${ this.props.id }` }></table>
<table id={ `dataTable-instances-${ this.props.id }-${ this.uniqueId }` }></table>
</Fragment>
);
}
Expand Down
Loading