Skip to content

Commit 2beef46

Browse files
author
Volodymyr Zaets
committed
Merge remote-tracking branch 'origin/MAGETWO-44195' into PR
2 parents c5ec3cb + 636548d commit 2beef46

File tree

1 file changed

+39
-43
lines changed
  • app/code/Magento/Sales/view/adminhtml/web/order/create

1 file changed

+39
-43
lines changed

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

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ define([
66
"jquery",
77
'Magento_Ui/js/modal/confirm',
88
'Magento_Ui/js/modal/alert',
9-
'knockout',
109
"mage/translate",
1110
"prototype",
1211
"Magento_Catalog/catalog/product/composite/configure",
1312
'Magento_Ui/js/lib/view/utils/async'
14-
], function(jQuery, confirm, alert, ko){
13+
], function(jQuery, confirm, alert){
1514

1615
window.AdminOrder = new Class.create();
1716

@@ -38,52 +37,49 @@ define([
3837
this.isOnlyVirtualProduct = false;
3938
this.excludedPaymentMethods = [];
4039
this.summarizePrice = true;
41-
this.areasLoadedFlag = ko.observable(false);
4240
jQuery.async('#order-items', (function(){
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');
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 ;
5750
}
5851
}
59-
});
52+
button.insertIn(controlButtonArea, 'top');
53+
}
54+
}
55+
});
6056

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

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();
85-
}
86-
}, this);
67+
if (jQuery('#' + this.getAreaId('items')).is(':visible')) {
68+
this.dataArea.onLoad = this.dataArea.onLoad.wrap(function(proceed) {
69+
proceed();
70+
this._parent.itemsArea.setNode($(this._parent.getAreaId('items')));
71+
this._parent.itemsArea.onLoad();
72+
});
73+
74+
this.itemsArea.onLoad = this.itemsArea.onLoad.wrap(function(proceed) {
75+
proceed();
76+
if ($(searchAreaId) && !$(searchAreaId).visible()) {
77+
this.addControlButton(searchButton);
78+
}
79+
});
80+
this.areasLoaded();
81+
this.itemsArea.onLoad();
82+
}
8783
}).bind(this));
8884

8985
jQuery('#edit_form')

0 commit comments

Comments
 (0)