Skip to content

Commit 8fd210d

Browse files
committed
Merge pull request #339 from magento-vanilla/PR
[Vanilla] Bugfixes + Modal Window Widget
2 parents 5cdb1bd + cef7f01 commit 8fd210d

File tree

34 files changed

+839
-435
lines changed

34 files changed

+839
-435
lines changed

app/code/Magento/Backend/view/adminhtml/layout/default.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
99
<head>
1010
<title>Magento Admin</title>
11+
<meta name="viewport" content="width=device-width"/>
1112
<link src="requirejs/require.js"/>
1213
<css src="extjs/resources/css/ext-all.css"/>
1314
<css src="extjs/resources/css/ytheme-magento.css"/>

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function getAfterElementHtml()
132132
'id' => 'add_category_button',
133133
'label' => $newCategoryCaption,
134134
'title' => $newCategoryCaption,
135-
'onclick' => 'jQuery("#new-category").dialog("open")',
135+
'onclick' => 'jQuery("#new-category").trigger("openModal")',
136136
'disabled' => $this->getDisabled(),
137137
]
138138
);

app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
define([
88
'jquery',
99
'jquery/ui',
10+
'Magento_Ui/js/modal/modal',
1011
'mage/translate',
1112
'mage/backend/tree-suggest',
1213
'mage/backend/validation'
@@ -51,53 +52,37 @@ define([
5152
options.errorClass, options.validClass || '');
5253
}
5354
});
54-
55-
this.element.dialog({
55+
this.element.modal({
56+
type: 'slide',
57+
modalClass: 'mage-new-category-dialog form-inline',
5658
title: $.mage.__('Create Category'),
57-
autoOpen: false,
58-
width: '75%',
59-
dialogClass: 'mage-new-category-dialog form-inline',
60-
modal: true,
61-
multiselect: true,
62-
resizable: false,
63-
position: {
64-
my: 'left top',
65-
at: 'center top',
66-
of: 'body'
67-
},
68-
open: function () {
69-
// fix for suggest field - overlapping dialog z-index
70-
$('#new_category_parent-suggest').css('z-index', $.ui.dialog.maxZ + 1);
59+
opened: function () {
7160
var enteredName = $('#category_ids-suggest').val();
61+
7262
$('#new_category_name').val(enteredName);
7363
if (enteredName === '') {
7464
$('#new_category_name').focus();
7565
}
7666
$('#new_category_messages').html('');
77-
$(this).closest('.ui-dialog').addClass('ui-dialog-active');
78-
79-
var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 15;
80-
$(this).closest('.ui-dialog').css('margin-top', topMargin);
8167
},
82-
close: function () {
83-
$('#new_category_name, #new_category_parent-suggest').val('');
68+
closed: function () {
8469
var validationOptions = newCategoryForm.validation('option');
70+
71+
$('#new_category_name, #new_category_parent-suggest').val('');
8572
validationOptions.unhighlight($('#new_category_parent-suggest').get(0),
8673
validationOptions.errorClass, validationOptions.validClass || '');
8774
newCategoryForm.validation('clearError');
8875
$('#category_ids-suggest').focus();
89-
$(this).closest('.ui-dialog').removeClass('ui-dialog-active');
9076
},
9177
buttons: [{
9278
text: $.mage.__('Create Category'),
93-
'class': 'action-primary',
94-
'data-action': 'save',
95-
click: function (event) {
79+
class: 'action-primary',
80+
click: function (e) {
9681
if (!newCategoryForm.valid()) {
9782
return;
9883
}
84+
var thisButton = $(e.currentTarget);
9985

100-
var thisButton = $(event.target).closest('[data-action=save]');
10186
thisButton.prop('disabled', true);
10287
$.ajax({
10388
type: 'POST',
@@ -115,27 +100,25 @@ define([
115100
},
116101
dataType: 'json',
117102
context: $('body')
118-
})
119-
.success(
120-
function (data) {
121-
if (!data.error) {
122-
$('#category_ids-suggest').trigger('selectItem', {
123-
id: data.category.entity_id,
124-
label: data.category.name
125-
});
126-
$('#new_category_name, #new_category_parent-suggest').val('');
127-
$('#category_ids-suggest').val('');
128-
clearParentCategory();
129-
widget.element.dialog('close');
130-
} else {
131-
$('#new_category_messages').html(data.messages);
132-
}
133-
}
134-
)
135-
.complete(
136-
function () {
137-
thisButton.prop('disabled', false);
138-
}
103+
}).success(function (data) {
104+
if (!data.error) {
105+
var $suggest = $('#category_ids-suggest');
106+
107+
$suggest.trigger('selectItem', {
108+
id: data.category.entity_id,
109+
label: data.category.name
110+
});
111+
$('#new_category_name, #new_category_parent-suggest').val('');
112+
$suggest.val('');
113+
clearParentCategory();
114+
widget.element.trigger('closeModal');
115+
} else {
116+
$('#new_category_messages').html(data.messages);
117+
}
118+
}).complete(
119+
function () {
120+
thisButton.prop('disabled', false);
121+
}
139122
);
140123
}
141124
}]

app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,22 @@ define(
5858
return !quote.isVirtual();
5959
},
6060
selectShippingAddress: function() {
61-
var additionalData = {};
62-
var billingAddress = quote.getBillingAddress()();
61+
var additionalFields,
62+
addressData,
63+
additionalData = {},
64+
billingAddress = quote.getBillingAddress()();
65+
6366
if (!billingAddress.customerAddressId || !this.visible()) {
6467
/**
6568
* All the the input fields that are not a part of the address but need to be submitted
6669
* in the same request must have data-scope attribute set
6770
*/
68-
var additionalFields = $('input[data-scope="additionalAddressData"]').serializeArray();
71+
additionalFields = $('input[data-scope="additionalAddressData"]').serializeArray();
6972
additionalFields.forEach(function (field) {
7073
additionalData[field.name] = field.value;
7174
});
7275
}
76+
7377
if (!newAddressSelected()) {
7478
selectShippingAddress(
7579
addressList.getAddressById(this.selectedAddressId()),
@@ -80,23 +84,32 @@ define(
8084
if (this.visible()) {
8185
this.validate();
8286
}
87+
8388
if (!this.source.get('params.invalid')) {
84-
var addressData = this.source.get('shippingAddress');
89+
addressData = this.source.get('shippingAddress');
8590
selectShippingAddress(addressData, this.sameAsBilling(), additionalData);
8691
}
8792
}
8893
},
8994
sameAsBillingClick: function() {
95+
var billingAddress,
96+
shippingAddress,
97+
property;
98+
9099
addressList.isBillingSameAsShipping = !addressList.isBillingSameAsShipping;
100+
91101
if (this.sameAsBilling()) {
92-
var billingAddress = quote.getBillingAddress()();
102+
billingAddress = quote.getBillingAddress()();
103+
93104
if (billingAddress.customerAddressId) {
94105
this.selectedAddressId(billingAddress.customerAddressId);
95106
newAddressSelected(false);
107+
96108
} else {
97109
// copy billing address data to shipping address form if customer uses new address for billing
98-
var shippingAddress = this.source.get('shippingAddress');
99-
for (var property in billingAddress) {
110+
shippingAddress = this.source.get('shippingAddress');
111+
112+
for (property in billingAddress) {
100113
if (billingAddress.hasOwnProperty(property) && shippingAddress.hasOwnProperty(property)) {
101114
if (typeof billingAddress[property] === 'string') {
102115
this.source.set('shippingAddress.' + property, billingAddress[property]);
@@ -105,6 +118,7 @@ define(
105118
}
106119
}
107120
}
121+
108122
this.selectedAddressId(null);
109123
newAddressSelected(true);
110124
}
@@ -113,9 +127,11 @@ define(
113127
},
114128
onAddressChange: function() {
115129
var billingAddress = quote.getBillingAddress();
130+
116131
if (this.selectedAddressId() !== billingAddress().customerAddressId) {
117132
this.sameAsBilling(false);
118133
}
134+
119135
if (this.selectedAddressId() === null) {
120136
newAddressSelected(true);
121137
} else {

app/code/Magento/Cms/view/adminhtml/layout/cms_block_listing.xml

Lines changed: 0 additions & 129 deletions
This file was deleted.

0 commit comments

Comments
 (0)