AuthorMetaControl.js
4 years ago
CommentsControl.js
4 years ago
ContentTypeControl.js
4 years ago
DynamicSourceControl.js
4 years ago
ExcerptControl.js
4 years ago
LinkTypeControl.js
4 years ago
PostDateControl.js
4 years ago
PostMetaControl.js
4 years ago
TermsControl.js
4 years ago
DynamicSourceControl.js
46 lines
| 1 | import { __ } from '@wordpress/i18n'; |
| 2 | import SelectPostType from '../components/SelectPostType'; |
| 3 | import PostTypeRecordsSelect from '../../../components/post-type-records-select'; |
| 4 | import SelectSource from '../components/SelectSource'; |
| 5 | |
| 6 | export default ( { dynamicSource, postType, postId, setAttributes, dynamicContentType } ) => { |
| 7 | return ( |
| 8 | <> |
| 9 | <SelectSource |
| 10 | source={ dynamicSource } |
| 11 | onChange={ ( option ) => { |
| 12 | setAttributes( { |
| 13 | dynamicSource: option.value, |
| 14 | postId: '', |
| 15 | postType: 'post', |
| 16 | } ); |
| 17 | } } |
| 18 | dynamicContentType={ dynamicContentType } |
| 19 | /> |
| 20 | |
| 21 | { dynamicSource === 'post-type' && |
| 22 | <> |
| 23 | <SelectPostType |
| 24 | postType={ postType } |
| 25 | onChange={ ( option ) => { |
| 26 | setAttributes( { postType: option.value, postId: '' } ); |
| 27 | } } |
| 28 | /> |
| 29 | |
| 30 | <PostTypeRecordsSelect |
| 31 | postId={ postId } |
| 32 | postType={ postType } |
| 33 | value={ [ postId ] } |
| 34 | id={ 'gblocks-select-post' } |
| 35 | label={ __( 'Select source post', 'generateblocks' ) } |
| 36 | onChange={ ( option ) => { |
| 37 | setAttributes( { postId: option.value } ); |
| 38 | } } |
| 39 | isMulti={ false } |
| 40 | /> |
| 41 | </> |
| 42 | } |
| 43 | </> |
| 44 | ); |
| 45 | }; |
| 46 |