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 / package / block-conditions / store / reducer.js
jetformbuilder / assets / src / package / block-conditions / store Last commit date
actions.js 2 years ago constants.js 2 years ago dispatchers.js 2 years ago index.js 2 years ago reducer.js 2 years ago selectors.js 2 years ago
reducer.js
81 lines
1 import dispatchers from './dispatchers';
2 import humanReadablePreset from '../../preset/helpers/humanReadablePreset';
3
4 const {
5 select,
6 } = wp.data;
7 const {
8 __,
9 } = wp.i18n;
10
11 const emptyCondition = function ( condition ) {
12 const operatorOptions = select( 'jet-forms/block-conditions' ).
13 getOperator( condition?.operator );
14
15 if ( !operatorOptions ) {
16 return '';
17 }
18 const field = condition?.field || '(no field)';
19
20 return [
21 `<code>${ field }</code>`,
22 operatorOptions.label,
23 ].join( ' ' );
24 };
25
26 const DEFAULT_STATE = {
27 functions: [],
28 operators: [],
29 conditionReaders: {
30 default: function ( condition ) {
31 const operatorOptions = select( 'jet-forms/block-conditions' ).
32 getOperator( condition?.operator );
33
34 if ( !operatorOptions ) {
35 return '';
36 }
37 const field = condition?.field || '(no field)';
38 const value = (
39 humanReadablePreset( condition.value, 'b' ) || '(no value)'
40 );
41
42 return [
43 `<code>${ field }</code>`,
44 operatorOptions.label,
45 `<code>${ value }</code>`,
46 ].join( ' ' );
47 },
48 empty: emptyCondition,
49 not_empty: emptyCondition,
50 render_state: function ( condition ) {
51 const states = (
52 condition?.render_state ?? []
53 ).map(
54 current => `<code>${ current }</code>`,
55 );
56
57 const label = 1 === states.length
58 ? __( 'Is render state', 'jet-form-builder' )
59 : __(
60 'One of the render states',
61 'jet-form-builder',
62 );
63
64 return [
65 label,
66 states.join( ', ' ),
67 ].join( ': ' );
68 },
69 },
70 renderStates: [],
71 };
72
73 export default function ( state = DEFAULT_STATE, action ) {
74 const callback = dispatchers[ action?.type ];
75
76 if ( callback ) {
77 return callback( state, action );
78 }
79
80 return state;
81 }