Skip to content

Commit

Permalink
Merge pull request #339 from magento-vanilla/PR
Browse files Browse the repository at this point in the history
[Vanilla] Bugfixes + Modal Window Widget
  • Loading branch information
guz-anton committed Jun 5, 2015
2 parents 5cdb1bd + cef7f01 commit 8fd210d
Show file tree
Hide file tree
Showing 34 changed files with 839 additions and 435 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Backend/view/adminhtml/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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">
<head>
<title>Magento Admin</title>
<meta name="viewport" content="width=device-width"/>
<link src="requirejs/require.js"/>
<css src="extjs/resources/css/ext-all.css"/>
<css src="extjs/resources/css/ytheme-magento.css"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function getAfterElementHtml()
'id' => 'add_category_button',
'label' => $newCategoryCaption,
'title' => $newCategoryCaption,
'onclick' => 'jQuery("#new-category").dialog("open")',
'onclick' => 'jQuery("#new-category").trigger("openModal")',
'disabled' => $this->getDisabled(),
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
define([
'jquery',
'jquery/ui',
'Magento_Ui/js/modal/modal',
'mage/translate',
'mage/backend/tree-suggest',
'mage/backend/validation'
Expand Down Expand Up @@ -51,53 +52,37 @@ define([
options.errorClass, options.validClass || '');
}
});

this.element.dialog({
this.element.modal({
type: 'slide',
modalClass: 'mage-new-category-dialog form-inline',
title: $.mage.__('Create Category'),
autoOpen: false,
width: '75%',
dialogClass: 'mage-new-category-dialog form-inline',
modal: true,
multiselect: true,
resizable: false,
position: {
my: 'left top',
at: 'center top',
of: 'body'
},
open: function () {
// fix for suggest field - overlapping dialog z-index
$('#new_category_parent-suggest').css('z-index', $.ui.dialog.maxZ + 1);
opened: function () {
var enteredName = $('#category_ids-suggest').val();

$('#new_category_name').val(enteredName);
if (enteredName === '') {
$('#new_category_name').focus();
}
$('#new_category_messages').html('');
$(this).closest('.ui-dialog').addClass('ui-dialog-active');

var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 15;
$(this).closest('.ui-dialog').css('margin-top', topMargin);
},
close: function () {
$('#new_category_name, #new_category_parent-suggest').val('');
closed: function () {
var validationOptions = newCategoryForm.validation('option');

$('#new_category_name, #new_category_parent-suggest').val('');
validationOptions.unhighlight($('#new_category_parent-suggest').get(0),
validationOptions.errorClass, validationOptions.validClass || '');
newCategoryForm.validation('clearError');
$('#category_ids-suggest').focus();
$(this).closest('.ui-dialog').removeClass('ui-dialog-active');
},
buttons: [{
text: $.mage.__('Create Category'),
'class': 'action-primary',
'data-action': 'save',
click: function (event) {
class: 'action-primary',
click: function (e) {
if (!newCategoryForm.valid()) {
return;
}
var thisButton = $(e.currentTarget);

var thisButton = $(event.target).closest('[data-action=save]');
thisButton.prop('disabled', true);
$.ajax({
type: 'POST',
Expand All @@ -115,27 +100,25 @@ define([
},
dataType: 'json',
context: $('body')
})
.success(
function (data) {
if (!data.error) {
$('#category_ids-suggest').trigger('selectItem', {
id: data.category.entity_id,
label: data.category.name
});
$('#new_category_name, #new_category_parent-suggest').val('');
$('#category_ids-suggest').val('');
clearParentCategory();
widget.element.dialog('close');
} else {
$('#new_category_messages').html(data.messages);
}
}
)
.complete(
function () {
thisButton.prop('disabled', false);
}
}).success(function (data) {
if (!data.error) {
var $suggest = $('#category_ids-suggest');

$suggest.trigger('selectItem', {
id: data.category.entity_id,
label: data.category.name
});
$('#new_category_name, #new_category_parent-suggest').val('');
$suggest.val('');
clearParentCategory();
widget.element.trigger('closeModal');
} else {
$('#new_category_messages').html(data.messages);
}
}).complete(
function () {
thisButton.prop('disabled', false);
}
);
}
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,22 @@ define(
return !quote.isVirtual();
},
selectShippingAddress: function() {
var additionalData = {};
var billingAddress = quote.getBillingAddress()();
var additionalFields,
addressData,
additionalData = {},
billingAddress = quote.getBillingAddress()();

if (!billingAddress.customerAddressId || !this.visible()) {
/**
* All the the input fields that are not a part of the address but need to be submitted
* in the same request must have data-scope attribute set
*/
var additionalFields = $('input[data-scope="additionalAddressData"]').serializeArray();
additionalFields = $('input[data-scope="additionalAddressData"]').serializeArray();
additionalFields.forEach(function (field) {
additionalData[field.name] = field.value;
});
}

if (!newAddressSelected()) {
selectShippingAddress(
addressList.getAddressById(this.selectedAddressId()),
Expand All @@ -80,23 +84,32 @@ define(
if (this.visible()) {
this.validate();
}

if (!this.source.get('params.invalid')) {
var addressData = this.source.get('shippingAddress');
addressData = this.source.get('shippingAddress');
selectShippingAddress(addressData, this.sameAsBilling(), additionalData);
}
}
},
sameAsBillingClick: function() {
var billingAddress,
shippingAddress,
property;

addressList.isBillingSameAsShipping = !addressList.isBillingSameAsShipping;

if (this.sameAsBilling()) {
var billingAddress = quote.getBillingAddress()();
billingAddress = quote.getBillingAddress()();

if (billingAddress.customerAddressId) {
this.selectedAddressId(billingAddress.customerAddressId);
newAddressSelected(false);

} else {
// copy billing address data to shipping address form if customer uses new address for billing
var shippingAddress = this.source.get('shippingAddress');
for (var property in billingAddress) {
shippingAddress = this.source.get('shippingAddress');

for (property in billingAddress) {
if (billingAddress.hasOwnProperty(property) && shippingAddress.hasOwnProperty(property)) {
if (typeof billingAddress[property] === 'string') {
this.source.set('shippingAddress.' + property, billingAddress[property]);
Expand All @@ -105,6 +118,7 @@ define(
}
}
}

this.selectedAddressId(null);
newAddressSelected(true);
}
Expand All @@ -113,9 +127,11 @@ define(
},
onAddressChange: function() {
var billingAddress = quote.getBillingAddress();

if (this.selectedAddressId() !== billingAddress().customerAddressId) {
this.sameAsBilling(false);
}

if (this.selectedAddressId() === null) {
newAddressSelected(true);
} else {
Expand Down
129 changes: 0 additions & 129 deletions app/code/Magento/Cms/view/adminhtml/layout/cms_block_listing.xml

This file was deleted.

Loading

0 comments on commit 8fd210d

Please sign in to comment.