PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.1
JetFormBuilder — Dynamic Blocks Form Builder v3.1.1
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 / blocks / controls / default-meta.js
jetformbuilder / assets / src / editor / blocks / controls Last commit date
default-meta.js 2 years ago fields-map.js 2 years ago placeholder.js 2 years ago
default-meta.js
107 lines
1 const {
2 Button,
3 TextControl,
4 } = wp.components;
5
6 const { __ } = wp.i18n;
7
8 class JetDefaultMetaControl extends wp.element.Component {
9
10 constructor( props ) {
11 super( props );
12
13 this.addNewOption = this.addNewOption.bind( this );
14 }
15
16 getDefaultMeta() {
17 if ( ! this.props.defaultMeta ) {
18 return [];
19 }
20 return Array.from( this.props.defaultMeta );
21 }
22
23
24 addNewOption() {
25 const items = this.getDefaultMeta();
26
27 items.push( {
28 key: '',
29 value: '',
30 } );
31
32 this.props.onChange( items );
33 }
34
35 removeOption( index ) {
36 const items = this.getDefaultMeta();
37 items.splice( index, 1 );
38
39 this.props.onChange( items );
40 }
41
42 onChangeValue( { value, name, id } ) {
43
44 const items = Array.from( this.props.defaultMeta );
45 items[ id ][ name ] = value;
46
47 this.props.onChange( items );
48 }
49
50 /* eslint-disable jsx-a11y/no-onchange */
51 render() {
52
53 return <div
54 className="jet-user-fields-map__list"
55 >
56 { this.getDefaultMeta().map( ( currentItem, index ) => {
57 return <div
58 className="jet-user-meta__row"
59 key={ 'jet-form-builder-repeater-item-' + index }
60 >
61 <div className='repeater-item-column jet-margin-bottom-wrapper'>
62 <TextControl
63 key='meta_key'
64 label={ __( 'Meta Key', 'jet-form-builder' ) }
65 value={ currentItem.key }
66 onChange={ ( newValue ) => {
67 this.onChangeValue( {
68 value: newValue,
69 name: 'key',
70 id: index
71 } );
72 } }
73 />
74 <TextControl
75 key='meta_value'
76 label={ __( 'Meta Value', 'jet-form-builder' ) }
77 value={ currentItem.value }
78 onChange={ ( newValue ) => {
79 this.onChangeValue( {
80 value: newValue,
81 name: 'value',
82 id: index
83 } );
84 } }
85 />
86 </div>
87 <div className='repeater-item-column'>
88 <Button
89 icon="dismiss"
90 label="Remove"
91 onClick={ () => this.removeOption( index ) }
92 />
93 </div>
94 </div>
95 } ) }
96 <Button
97 className='button-add-option'
98 isSecondary
99 onClick={ this.addNewOption }
100 >
101 { __( 'Add New Option' ) }
102 </Button>
103 </div>;
104 }
105 }
106
107 export default JetDefaultMetaControl;