PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.5
JetFormBuilder — Dynamic Blocks Form Builder v3.1.5
3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / src / editor / components / base-select-check-radio / from-manual-fields.js
jetformbuilder / assets / src / editor / components / base-select-check-radio Last commit date
custom-template.js 3 years ago from-generators-fields.js 3 years ago from-manual-fields.js 3 years ago from-post-terms-fields.js 3 years ago select-radio-check-placeholder.js 3 years ago select-radio-check.js 3 years ago sources.js 3 years ago
from-manual-fields.js
121 lines
1 const {
2 RepeaterWithState,
3 ActionModal,
4 } = JetFBComponents;
5
6 const {
7 Button,
8 TextControl,
9 } = wp.components;
10
11 const { __ } = wp.i18n;
12 const { useState } = wp.element;
13
14 const addNewOption = {
15 label: '',
16 value: '',
17 calculate: ''
18 };
19
20 function FromManualFields( props ) {
21
22 const [ showManualModal, setShowModal ] = useState( false );
23
24 const {
25 setAttributes,
26 attributes
27 } = props;
28
29
30 const toggleModal = () => {
31 setShowModal( toggle => ! toggle );
32 }
33
34 const onUpdateOptions = items => {
35 /* Remove empty options */
36 const field_options = items.filter( option => {
37 return ( Boolean( option.value ) || Boolean( option.calculate ) );
38 } );
39
40 setAttributes( { field_options } );
41 }
42
43 const itemHeading = ( { currentItem, index } ) => {
44 const leftPart = [ `#${ index + 1 }` ];
45 const rightPart = [];
46
47 if ( currentItem.label ) {
48 rightPart.push( `Label [${ currentItem.label }]` );
49 }
50 if ( currentItem.value ) {
51 rightPart.push( `Value [${ currentItem.value }]` );
52 }
53 if ( currentItem.calculate ) {
54 rightPart.push( `Calculate [${ currentItem.calculate }]` );
55 }
56 leftPart.push( rightPart.join( ' | ' ) )
57
58 return leftPart.join( ' ' );
59 };
60
61 return <React.Fragment key='jet-form/manage-manual-items'>
62 <Button
63 isSecondary
64 onClick={ toggleModal }
65 icon={ 'admin-tools' }
66 style={ {
67 marginBottom: '15px'
68 } }
69 >
70 { __( 'Manage Items' ) }
71 </Button>
72 { showManualModal && <ActionModal
73 title={ 'Edit Manual Options' }
74 onRequestClose={ toggleModal }
75 classNames={ [ 'width-60' ] }
76 >
77 { ( { actionClick, onRequestClose } ) => {
78 return <RepeaterWithState
79 items={ attributes.field_options }
80 onSaveItems={ onUpdateOptions }
81 newItem={ addNewOption }
82 onUnMount={ onRequestClose }
83 isSaveAction={ actionClick }
84 addNewButtonLabel={ __( 'Add New Option' ) }
85 ItemHeading={ itemHeading }
86 >
87 { ( { currentItem, changeCurrentItem } ) => {
88 return <>
89 <TextControl
90 key='manual_label'
91 label={ __( 'Label' ) }
92 value={ currentItem.label }
93 onChange={ newValue => {
94 changeCurrentItem( { label: newValue } );
95 } }
96 />
97 <TextControl
98 key='manual_value'
99 label={ __( 'Value' ) }
100 value={ currentItem.value }
101 onChange={ ( newValue ) => {
102 changeCurrentItem( { value: newValue } );
103 } }
104 />
105 <TextControl
106 key='manual_calculate'
107 label={ __( 'Calculate' ) }
108 value={ currentItem.calculate }
109 onChange={ ( newValue ) => {
110 changeCurrentItem( { calculate: newValue } );
111 } }
112 />
113 </>;
114 } }
115 </RepeaterWithState>
116 } }
117 </ActionModal> }
118 </React.Fragment>;
119 }
120
121 export default FromManualFields;