@@ -6,11 +6,12 @@ define([
6
6
"jquery" ,
7
7
'Magento_Ui/js/modal/confirm' ,
8
8
'Magento_Ui/js/modal/alert' ,
9
+ 'knockout' ,
9
10
"mage/translate" ,
10
11
"prototype" ,
11
12
"Magento_Catalog/catalog/product/composite/configure" ,
12
13
'Magento_Ui/js/lib/view/utils/async'
13
- ] , function ( jQuery , confirm , alert ) {
14
+ ] , function ( jQuery , confirm , alert , ko ) {
14
15
15
16
window . AdminOrder = new Class . create ( ) ;
16
17
@@ -37,55 +38,59 @@ define([
37
38
this . isOnlyVirtualProduct = false ;
38
39
this . excludedPaymentMethods = [ ] ;
39
40
this . summarizePrice = true ;
41
+ this . areasLoadedFlag = ko . observable ( false ) ;
40
42
jQuery . async ( '#order-items' , ( function ( ) {
41
- this . dataArea = new OrderFormArea ( 'data' , $ ( this . getAreaId ( 'data' ) ) , this ) ;
42
- this . itemsArea = Object . extend ( new OrderFormArea ( 'items' , $ ( this . getAreaId ( 'items' ) ) , this ) , {
43
- addControlButton : function ( button ) {
44
- var controlButtonArea = $ ( this . node ) . select ( '.actions' ) [ 0 ] ;
45
- if ( typeof controlButtonArea != 'undefined' ) {
46
- var buttons = controlButtonArea . childElements ( ) ;
47
- for ( var i = 0 ; i < buttons . length ; i ++ ) {
48
- if ( buttons [ i ] . innerHTML . include ( button . label ) ) {
49
- return ;
43
+ this . areasLoadedFlag . subscribe ( function ( val ) {
44
+ if ( val ) {
45
+ this . dataArea = new OrderFormArea ( 'data' , $ ( this . getAreaId ( 'data' ) ) , this ) ;
46
+ this . itemsArea = Object . extend ( new OrderFormArea ( 'items' , $ ( this . getAreaId ( 'items' ) ) , this ) , {
47
+ addControlButton : function ( button ) {
48
+ var controlButtonArea = $ ( this . node ) . select ( '.actions' ) [ 0 ] ;
49
+ if ( typeof controlButtonArea != 'undefined' ) {
50
+ var buttons = controlButtonArea . childElements ( ) ;
51
+ for ( var i = 0 ; i < buttons . length ; i ++ ) {
52
+ if ( buttons [ i ] . innerHTML . include ( button . label ) ) {
53
+ return ;
54
+ }
55
+ }
56
+ button . insertIn ( controlButtonArea , 'top' ) ;
50
57
}
51
58
}
52
- button . insertIn ( controlButtonArea , 'top' ) ;
53
- }
54
- }
55
- } ) ;
56
-
57
- var searchButton = new ControlButton ( jQuery . mage . __ ( 'Add Products' ) ) ,
58
- searchAreaId = this . getAreaId ( 'search' ) ;
59
- searchButton . onClick = function ( ) {
60
- $ ( searchAreaId ) . show ( ) ;
61
- var el = this ;
62
- window . setTimeout ( function ( ) {
63
- el . remove ( ) ;
64
- } , 10 ) ;
65
- } ;
59
+ } ) ;
66
60
67
- this . dataArea . onLoad = this . dataArea . onLoad . wrap ( function ( proceed ) {
68
- proceed ( ) ;
69
- this . _parent . itemsArea . setNode ( $ ( this . _parent . getAreaId ( 'items' ) ) ) ;
70
- this . _parent . itemsArea . onLoad ( ) ;
71
- } ) ;
61
+ var searchButton = new ControlButton ( jQuery . mage . __ ( 'Add Products' ) ) ,
62
+ searchAreaId = this . getAreaId ( 'search' ) ;
63
+ searchButton . onClick = function ( ) {
64
+ $ ( searchAreaId ) . show ( ) ;
65
+ var el = this ;
66
+ window . setTimeout ( function ( ) {
67
+ el . remove ( ) ;
68
+ } , 10 ) ;
69
+ } ;
70
+
71
+ this . dataArea . onLoad = this . dataArea . onLoad . wrap ( function ( proceed ) {
72
+ proceed ( ) ;
73
+ this . _parent . itemsArea . setNode ( $ ( this . _parent . getAreaId ( 'items' ) ) ) ;
74
+ this . _parent . itemsArea . onLoad ( ) ;
75
+ } ) ;
72
76
73
- this . itemsArea . onLoad = this . itemsArea . onLoad . wrap ( function ( proceed ) {
74
- proceed ( ) ;
75
- if ( $ ( searchAreaId ) && ! $ ( searchAreaId ) . visible ( ) ) {
76
- this . addControlButton ( searchButton ) ;
77
+ this . itemsArea . onLoad = this . itemsArea . onLoad . wrap ( function ( proceed ) {
78
+ proceed ( ) ;
79
+ if ( $ ( searchAreaId ) && ! $ ( searchAreaId ) . visible ( ) ) {
80
+ this . addControlButton ( searchButton ) ;
81
+ }
82
+ } ) ;
83
+ this . areasLoaded ( ) ;
84
+ this . itemsArea . onLoad ( ) ;
77
85
}
78
- } ) ;
79
- this . areasLoaded ( ) ;
80
- this . itemsArea . onLoad ( ) ;
86
+ } , this ) ;
81
87
} ) . bind ( this ) ) ;
82
88
83
89
jQuery ( '#edit_form' )
84
90
. on ( 'submitOrder' , function ( ) {
85
91
jQuery ( this ) . trigger ( 'realOrder' ) ;
86
92
} )
87
93
. on ( 'realOrder' , this . _realSubmit . bind ( this ) ) ;
88
-
89
94
} ,
90
95
91
96
areasLoaded : function ( ) {
0 commit comments