6
6
define ( [
7
7
'underscore' ,
8
8
'jquery' ,
9
+ 'mage/translate' ,
9
10
'Magento_PageBuilder/js/form/provider/conditions-data-processor' ,
10
11
'Magento_Ui/js/form/element/abstract'
11
- ] , function ( _ , $ , conditionsDataProcessor , Abstract ) {
12
+ ] , function ( _ , $ , $t , conditionsDataProcessor , Abstract ) {
12
13
'use strict' ;
13
14
14
15
return Abstract . extend ( {
@@ -29,7 +30,8 @@ define([
29
30
links : {
30
31
value : false
31
32
} ,
32
- url : null
33
+ url : null ,
34
+ valuePlaceholder : $t ( 'of %1 (%2 disabled)' )
33
35
} ,
34
36
35
37
/** @inheritdoc */
@@ -43,7 +45,6 @@ define([
43
45
*
44
46
*/
45
47
updateProductTotals : _ . debounce ( function ( ) {
46
-
47
48
if ( ! this . conditionOption || _ . isEmpty ( this . formData ) ||
48
49
( this . conditionOption === 'sku' && ( ! this . formData [ 'sku' ] || this . formData [ 'sku' ] === '' ) ) ) {
49
50
return ;
@@ -63,10 +64,17 @@ define([
63
64
conditionValue : this . formData [ 'conditions_encoded' ]
64
65
}
65
66
} ) . done ( function ( response ) {
66
- this . totalProductCount = response [ 'total' ] ;
67
- this . totalDisabledProducts = response [ 'disabled' ] ;
68
- this . value ( 'of ' + this . totalProductCount + ' (' + this . totalDisabledProducts + ' disabled)' ) ;
69
- } . bind ( this ) ) ;
67
+ this . totalProductCount ( response [ 'total' ] ) ;
68
+ this . totalDisabledProducts ( response [ 'disabled' ] ) ;
69
+ this . value (
70
+ this . valuePlaceholder
71
+ . replace ( '%1' , this . totalProductCount ( ) )
72
+ . replace ( '%2' , this . totalDisabledProducts ( ) )
73
+ ) ;
74
+ } . bind ( this )
75
+ ) . fail ( ( ) => {
76
+ this . value ( $t ( "An unknown error occurred. Please try again." ) ) ;
77
+ } ) ;
70
78
} , 10 ) ,
71
79
} ) ;
72
80
} ) ;
0 commit comments