Skip to content

Commit 0b27a0c

Browse files
committed
MAGETWO-44195: "Add Products By SKU" button disappears during order creation from Admin
1 parent 24abff1 commit 0b27a0c

File tree

2 files changed

+45
-42
lines changed
  • app/code/Magento
    • Catalog/view/adminhtml/web/catalog/product/composite
    • Sales/view/adminhtml/web/order/create

2 files changed

+45
-42
lines changed

app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ define([
77
"jquery/ui",
88
"mage/translate",
99
"prototype",
10-
'Magento_Ui/js/modal/modal'
10+
'Magento_Ui/js/modal/modal',
11+
'domReady!'
1112
], function(jQuery){
1213

1314
window.ProductConfigure = Class.create();
@@ -761,8 +762,5 @@ define([
761762
}
762763
};
763764

764-
jQuery(document).ready(function(){
765-
productConfigure = new ProductConfigure();
766-
});
767-
765+
productConfigure = new ProductConfigure();
768766
});

app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ define([
66
"jquery",
77
'Magento_Ui/js/modal/confirm',
88
'Magento_Ui/js/modal/alert',
9+
'knockout',
910
"mage/translate",
1011
"prototype",
1112
"Magento_Catalog/catalog/product/composite/configure",
1213
'Magento_Ui/js/lib/view/utils/async'
13-
], function(jQuery, confirm, alert){
14+
], function(jQuery, confirm, alert, ko){
1415

1516
window.AdminOrder = new Class.create();
1617

@@ -37,55 +38,59 @@ define([
3738
this.isOnlyVirtualProduct = false;
3839
this.excludedPaymentMethods = [];
3940
this.summarizePrice = true;
41+
this.areasLoadedFlag = ko.observable(false);
4042
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');
5057
}
5158
}
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+
});
6660

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+
});
7276

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();
7785
}
78-
});
79-
this.areasLoaded();
80-
this.itemsArea.onLoad();
86+
}, this);
8187
}).bind(this));
8288

8389
jQuery('#edit_form')
8490
.on('submitOrder', function(){
8591
jQuery(this).trigger('realOrder');
8692
})
8793
.on('realOrder', this._realSubmit.bind(this));
88-
8994
},
9095

9196
areasLoaded: function(){

0 commit comments

Comments
 (0)