Hook settings up to API preview and fix rangecontrol warning

This commit is contained in:
claudiulodro 2018-02-26 11:58:19 -08:00
parent 2d2702e035
commit 2d6701b107
2 changed files with 21 additions and 5 deletions

View File

@ -97,9 +97,9 @@ var _wp$components = wp.components,
Toolbar = _wp$components.Toolbar,
withAPIData = _wp$components.withAPIData,
Dropdown = _wp$components.Dropdown,
Dashicon = _wp$components.Dashicon;
var RangeControl = InspectorControls.RangeControl,
ToggleControl = InspectorControls.ToggleControl,
Dashicon = _wp$components.Dashicon,
RangeControl = _wp$components.RangeControl;
var ToggleControl = InspectorControls.ToggleControl,
SelectControl = InspectorControls.SelectControl;
@ -562,6 +562,14 @@ var ProductsBlockPreview = withAPIData(function (_ref) {
if (display_setting.length > 1) {
query.attribute_term = display_setting.slice(1).join(',');
}
} else if ('featured' === display) {
query.featured = 1;
} else if ('best_sellers' === display) {
// @todo Not possible in the API yet.
} else if ('best_rated' === display) {
// @todo Not possible in the API yet.
} else if ('on_sale' === display) {
query.on_sale = 1;
}
var query_string = '?';

View File

@ -1,7 +1,7 @@
const { __ } = wp.i18n;
const { registerBlockType, InspectorControls, BlockControls } = wp.blocks;
const { Toolbar, withAPIData, Dropdown, Dashicon } = wp.components;
const { RangeControl, ToggleControl, SelectControl } = InspectorControls;
const { Toolbar, withAPIData, Dropdown, Dashicon, RangeControl } = wp.components;
const { ToggleControl, SelectControl } = InspectorControls;
import { ProductsSpecificSelect } from './views/specific-select.jsx';
import { ProductsCategorySelect } from './views/category-select.jsx';
@ -330,6 +330,14 @@ const ProductsBlockPreview = withAPIData( ( { attributes } ) => {
if ( display_setting.length > 1 ) {
query.attribute_term = display_setting.slice( 1 ).join( ',' );
}
} else if ( 'featured' === display ) {
query.featured = 1;
} else if ( 'best_sellers' === display ) {
// @todo Not possible in the API yet.
} else if ( 'best_rated' === display ) {
// @todo Not possible in the API yet.
} else if ( 'on_sale' === display ) {
query.on_sale = 1;
}
let query_string = '?';