/** * WordPress dependencies */ import { __ } from '@wordpress/i18n' import {InspectorControls, ColorPalette,} from '@wordpress/block-editor'; import {PanelBody, Panel, SelectControl, ToggleControl, TextControl, FormTokenField } from '@wordpress/components'; /** * Internal dependencies */ import giveDonorWallOptions from '../data/options'; import ColumnSelector from '../../components/column-selector'; import ToggleOptions from '../../components/toggle'; import './style.scss' import Toggle from "../../components/toggle"; /** * Render Inspector Controls */ const Inspector = ( { attributes, setAttributes } ) => { const { donorsPerPage, ids, formID, categories, tags, orderBy, order, columns, avatarSize, showAvatar, showName, showCompanyName, onlyComments, showForm, showTotal, showComments, showAnonymous, commentLength, readMoreText, loadMoreText, toggleOptions, filterOptions, color, showTimestamp, showTributes } = attributes; const saveSetting = ( name, value ) => { setAttributes( { [ name ]: value, } ); }; const getAsArray = value => { if (Array.isArray(value)) { return value; } // Backward compatibility if (formIDs.indexOf(',')) { return value.split(','); } return [value]; }; const filterValue = () => { if(filterOptions === 'categories'){ return <> saveSetting('categories', value)} value={getAsArray(categories)}/>

{__('Type the name of your category to add it to the list. Only forms within the categories you choose will be displayed in this grid.', 'give')}

} else if (filterOptions === 'tags'){ return <> saveSetting('tags', value)}/>

{__('Type the name of your tag to add it to the list. Only forms with these tags you choose will be displayed in this grid.', 'give')}

} else if (filterOptions === 'ids'){ return <> saveSetting('ids', value)}/>

{__('By default, all donors will display. Use this setting to restrict the donor wall to only display certain donors. Use a comma-separated list of donor IDs.', 'give')}

} else if (filterOptions === 'formID' ){ return <> saveSetting('formID', value)}/>

{__('Type the ID of your form to add it to the list. Only forms with these IDs you choose will be displayed in this grid.', 'give')}

} }; return ( saveSetting('columns', value)} help={__('Controls how many columns of the Form Grid appear. All sizes will adjust responsively to the space available. The maximum number allowed per row is 4', 'give')} /> saveSetting( 'columns', value ) } /> saveSetting( 'toggleOptions', value ) } selected={toggleOptions}/> {toggleOptions === 'donorInfo' ? <> saveSetting( 'showName', value ) } /> saveSetting( 'showCompanyName', value ) } /> saveSetting( 'showAnonymous', value ) } /> saveSetting( 'showAvatar', value ) } /> saveSetting( 'avatarSize', value ) } /> : <> saveSetting( 'showForm', value ) } /> saveSetting( 'showTotal', value ) } /> saveSetting( 'showTimestamp', value ) } /> { !!window.Give_Tribute && saveSetting( 'showTributes', value ) } />} saveSetting( 'showComments', value ) } /> saveSetting( 'onlyComments', value ) } /> saveSetting( 'commentLength', value ) } /> saveSetting( 'readMoreText', value ) } /> } saveSetting( 'orderBy', value ) } /> saveSetting( 'order', value ) } /> saveSetting( 'filterOptions', value ) } /> {filterValue(filterOptions)} saveSetting( 'donorsPerPage', value ) } help={ __('How many donors should show up on the initial page load?', 'give' ) } /> saveSetting( 'loadMoreText', value ) } /> setAttributes( { color: value } )} /> ); }; export default Inspector;