File tree Expand file tree Collapse file tree 3 files changed +76
-1
lines changed
Catalog/view/adminhtml/web/js/components/disable-on-option
LayeredNavigation/view/adminhtml/ui_component
dev/tests/js/jasmine/tests/app/code/Magento/Catalog/adminhtml/js/disable-on-option Expand file tree Collapse file tree 3 files changed +76
-1
lines changed Original file line number Diff line number Diff line change @@ -8,5 +8,37 @@ define([
8
8
] , function ( Element , strategy ) {
9
9
'use strict' ;
10
10
11
- return Element . extend ( strategy ) ;
11
+ var comp = Element . extend ( strategy ) . extend ( {
12
+
13
+ defaults : {
14
+ listens : {
15
+ disabled : 'updateValueForDisabledField' ,
16
+ visible : 'updateValueForDisabledField'
17
+ }
18
+ } ,
19
+
20
+ /**
21
+ * {@inheritdoc }
22
+ */
23
+ initialize : function ( ) {
24
+ this . _super ( ) ;
25
+ this . updateValueForDisabledField ( ) ;
26
+
27
+ return this ;
28
+ } ,
29
+
30
+ /**
31
+ * Set element value to O(No) if element is invisible and disabled
32
+ * Set element value to initialValue if element becomes visible and enable
33
+ */
34
+ updateValueForDisabledField : function ( ) {
35
+ if ( ! this . disabled ( ) && this . visible ( ) ) {
36
+ this . set ( 'value' , this . initialValue ) ;
37
+ } else {
38
+ this . set ( 'value' , 0 ) ;
39
+ }
40
+ }
41
+ } ) ;
42
+
43
+ return comp . extend ( strategy ) ;
12
44
} ) ;
Original file line number Diff line number Diff line change 48
48
<notice translate =" true" >Can be used only with catalog input type Dropdown, Multiple Select and Price.</notice >
49
49
<label translate =" true" >Use in Search Results Layered Navigation</label >
50
50
<dataScope >is_filterable_in_search</dataScope >
51
+ <imports >
52
+ <link name =" visible" >${ $.parentName}:visible</link >
53
+ </imports >
51
54
</settings >
52
55
<formElements >
53
56
<checkbox >
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright © Magento, Inc. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+
6
+ define ( [ 'Magento_Catalog/js/components/disable-on-option/yesno' ] , function ( YesNo ) {
7
+ 'use strict' ;
8
+
9
+ var model ;
10
+
11
+ describe ( 'Magento_Catalog/js/components/disable-on-option/yesno' , function ( ) {
12
+ beforeEach ( function ( ) {
13
+ model = new YesNo ( {
14
+ name : 'dynamic_rows' ,
15
+ dataScope : '' ,
16
+ value : 12 ,
17
+ visible : true ,
18
+ disabled : false
19
+
20
+ } ) ;
21
+ } ) ;
22
+
23
+ it ( 'Verify initial value' , function ( ) {
24
+ expect ( model . get ( 'value' ) ) . toBe ( 12 ) ;
25
+ } ) ;
26
+ it ( 'Verify value when element becomes invisible' , function ( ) {
27
+ model . set ( 'visible' , false ) ;
28
+ expect ( model . get ( 'value' ) ) . toBe ( 0 ) ;
29
+ } ) ;
30
+ it ( 'Verify value when element becomes disabled' , function ( ) {
31
+ model . set ( 'disabled' , false ) ;
32
+ expect ( model . get ( 'value' ) ) . toBe ( 12 ) ;
33
+ } ) ;
34
+ it ( 'Verify value when element becomes invisable and disabled' , function ( ) {
35
+ model . set ( 'disabled' , true ) ;
36
+ model . set ( 'visible' , false ) ;
37
+ expect ( model . get ( 'value' ) ) . toBe ( 0 ) ;
38
+ } ) ;
39
+ } ) ;
40
+ } ) ;
You can’t perform that action at this time.
0 commit comments