@@ -13,7 +13,8 @@ define([
13
13
var serializer = new ConditionsDataNormalizer ( ) ;
14
14
15
15
return function ( data , attribute ) {
16
- var pairs = { } ;
16
+ var pairs = { } ,
17
+ conditions = '' ;
17
18
18
19
/*
19
20
* The Condition Rule Tree is not a UI component and doesn't provide good data.
@@ -33,27 +34,25 @@ define([
33
34
/*
34
35
* Add pairs in case conditions source is not rules configurator
35
36
*/
36
- if ( data . condition_option !== 'condition' ) {
37
- var conditionOperator = data [ data . condition_option + '-condition_operator' ]
38
- ? data [ data . condition_option + '-condition_operator' ]
39
- : "==" ;
40
- var conditionValue = typeof data [ data . condition_option ] === 'string'
41
- ? data [ data . condition_option ] . trim ( )
42
- : '' ;
43
- pairs [ 'parameters[' + attribute + '][1--1][operator]' ] = conditionOperator ;
44
- pairs [ 'parameters[' + attribute + '][1--1][type]' ] = "Magento\\CatalogWidget\\Model\\Rule\\Condition\\Product" ;
45
- pairs [ 'parameters[' + attribute + '][1][aggregator]' ] = "all" ;
46
- pairs [ 'parameters[' + attribute + '][1][new_child]' ] = "" ;
47
- pairs [ 'parameters[' + attribute + '][1][type]' ] = "Magento\\CatalogWidget\\Model\\Rule\\Condition\\Combine" ;
48
- pairs [ 'parameters[' + attribute + '][1][value]' ] = "1" ;
49
- pairs [ 'parameters[' + attribute + '][1--1][attribute]' ] = data . condition_option ;
50
- pairs [ 'parameters[' + attribute + '][1--1][value]' ] = conditionValue ;
37
+ if ( data [ 'condition_option' ] !== 'condition' ) {
38
+ pairs [ 'parameters[' + attribute + '][1--1][operator]' ] = data [ data [ 'condition_option' ] + '-condition_operator' ] ?
39
+ data [ data [ 'condition_option' ] + '-condition_operator' ] :
40
+ '==' ;
41
+ pairs [ 'parameters[' + attribute + '][1--1][type]' ] = 'Magento\\CatalogWidget\\Model\\Rule\\Condition\\Product' ;
42
+ pairs [ 'parameters[' + attribute + '][1][aggregator]' ] = 'all' ;
43
+ pairs [ 'parameters[' + attribute + '][1][new_child]' ] = '' ;
44
+ pairs [ 'parameters[' + attribute + '][1][type]' ] = 'Magento\\CatalogWidget\\Model\\Rule\\Condition\\Combine' ;
45
+ pairs [ 'parameters[' + attribute + '][1][value]' ] = '1' ;
46
+ pairs [ 'parameters[' + attribute + '][1--1][attribute]' ] = data [ 'condition_option' ] ;
47
+ pairs [ 'parameters[' + attribute + '][1--1][value]' ] = _ . isString ( data [ data [ 'condition_option' ] ] ) ?
48
+ data [ data [ 'condition_option' ] ] . trim ( ) :
49
+ '' ;
51
50
}
52
51
53
52
if ( ! _ . isEmpty ( pairs ) ) {
54
- var conditions = JSON . stringify ( serializer . normalize ( pairs ) . parameters [ attribute ] ) ;
53
+ conditions = JSON . stringify ( serializer . normalize ( pairs ) . parameters [ attribute ] ) ;
55
54
data [ 'conditions_encoded' ] = conditions ;
56
- objectUtils . nested ( data , attribute , conditions ) ;
55
+ objectUtils . nested ( data , attribute , conditions ) ;
57
56
}
58
57
} ;
59
58
} ) ;
0 commit comments