Skip to content

Commit

Permalink
Merge pull request #1534 from tomusborne/bug/query-per-page
Browse files Browse the repository at this point in the history
Improve post_per_page UX
  • Loading branch information
tomusborne authored Nov 28, 2024
2 parents cb4b42b + 0d73df6 commit 17b3cec
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions src/blocks/query/components/ControlBuilder.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ToggleControl, Button, Tooltip, ComboboxControl } from '@wordpress/components';
import { ToggleControl, Button, Tooltip, ComboboxControl, TextControl } from '@wordpress/components';
import { sprintf, __ } from '@wordpress/i18n';

import { isArray, isObject } from 'lodash';

import {
CategoriesSelect,
TagsSelect,
DebouncedTextControl,
} from '@components';
import { SelectPostType, SelectPost, MultiSelect, SelectUser } from '@edge22/components';
import { Control } from '@edge22/styles-builder';

import { TaxonomyParameterControl } from './TaxonomyParameterControl';
import { DateQueryControl } from './DateQueryControl';
Expand All @@ -23,24 +23,53 @@ function ControlComponent( props ) {

switch ( props?.type ) {
case 'text':
return <Control { ...standardProps } as={ TextControl } />;
case 'number':
return <DebouncedTextControl { ...standardProps } />;
return (
<TextControl
{ ...standardProps }
value={ standardProps.value }
type="number"
min="-1"
onChange={ ( newValue ) => {
if ( parseInt( newValue, 10 ) < -1 ) {
standardProps.onChange( -1 );
return;
}

standardProps.onChange( newValue );
} }
/>
);
case 'postTypeSelect':
return <SelectPostType { ...standardProps } />;
case 'select':
return <ComboboxControl { ...standardProps } />;
case 'multiSelect':
return <MultiSelect { ...standardProps } />;
case 'authorsSelect':
return <SelectUser multiple={ true } currentLabel={ __( 'Current author', 'generateblocks' ) } { ...standardProps } />;
return (
<SelectUser
{ ...standardProps }
multiple={ true }
currentLabel={ __( 'Current author', 'generateblocks' ) }
/>
);
case 'categoriesSelect':
return <CategoriesSelect { ...standardProps } />;
case 'tagsSelect':
return <TagsSelect { ...standardProps } />;
case 'taxonomySelect':
return <TaxonomyParameterControl postType={ postType } { ...standardProps } />;
case 'includePosts':
return <SelectPost includeCurrent={ false } multiple={ true } postType={ postType } { ...standardProps } />;
return (
<SelectPost
{ ...standardProps }
includeCurrent={ false }
multiple={ true }
postType={ postType }
/>
);
case 'excludePosts':
return <SelectPost multiple={ true } postType={ postType } { ...standardProps } />;
case 'dateQuery':
Expand Down

0 comments on commit 17b3cec

Please sign in to comment.