Skip to content

Commit

Permalink
Merge remote-tracking branch 'magento2/develop' into MPI-PR-bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
viktym committed Sep 27, 2016
2 parents c4eab33 + 8007ad1 commit ca6bdeb
Show file tree
Hide file tree
Showing 66 changed files with 959 additions and 296 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ public function execute()
return $this->ajaxRequestResponse($category, $resultPage);
}

$resultPageTitle = $categoryId ? $category->getName() . ' (ID: ' . $categoryId . ')' : __('Categories');
$resultPage->setActiveMenu('Magento_Catalog::catalog_categories');
$resultPage->getConfig()->getTitle()->prepend(__('Categories'));
$resultPage->getConfig()->getTitle()->prepend($categoryId ? $category->getName() : __('Categories'));
$resultPage->getConfig()->getTitle()->prepend($resultPageTitle);
$resultPage->addBreadcrumb(__('Manage Catalog Categories'), __('Manage Categories'));

$block = $resultPage->getLayout()->getBlock('catalog.wysiwyg.js');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ public function save(\Magento\Catalog\Api\Data\ProductAttributeInterface $attrib
$attribute->setFrontendInput($existingModel->getFrontendInput());

if (is_array($attribute->getFrontendLabels())) {
$frontendLabel[0] = $existingModel->getDefaultFrontendLabel();
$defaultFrontendLabel = $attribute->getDefaultFrontendLabel();
$frontendLabel[0] = !empty($defaultFrontendLabel)
? $defaultFrontendLabel
: $existingModel->getDefaultFrontendLabel();
foreach ($attribute->getFrontendLabels() as $item) {
$frontendLabel[$item->getStoreId()] = $item->getLabel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Magento\Catalog\Model\Product\Attribute\Repository;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Eav\Api\Data\AttributeFrontendLabelInterface;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -288,4 +289,42 @@ public function testSaveDoesNotSaveAttributeOptionsIfOptionsAreAbsentInPayload()

$this->model->save($attributeMock);
}

public function testSaveSavesDefaultFrontendLabelIfItIsPresentInPayload()
{
$labelMock = $this->getMock(AttributeFrontendLabelInterface::class);
$labelMock->expects($this->any())->method('getStoreId')->willReturn(1);
$labelMock->expects($this->any())->method('getLabel')->willReturn('Store Scope Label');

$attributeId = 1;
$attributeCode = 'existing_attribute_code';
$attributeMock = $this->getMock(Attribute::class, [], [], '', false);
$attributeMock->expects($this->any())->method('getAttributeCode')->willReturn($attributeCode);
$attributeMock->expects($this->any())->method('getAttributeId')->willReturn($attributeId);
$attributeMock->expects($this->any())->method('getDefaultFrontendLabel')->willReturn('Default Label');
$attributeMock->expects($this->any())->method('getFrontendLabels')->willReturn([$labelMock]);
$attributeMock->expects($this->any())->method('getOptions')->willReturn([]);


$existingModelMock = $this->getMock(Attribute::class, [], [], '', false);
$existingModelMock->expects($this->any())->method('getAttributeId')->willReturn($attributeId);
$existingModelMock->expects($this->any())->method('getAttributeCode')->willReturn($attributeCode);

$this->eavAttributeRepositoryMock->expects($this->any())
->method('get')
->with(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode)
->willReturn($existingModelMock);

$attributeMock->expects($this->once())
->method('setDefaultFrontendLabel')
->with(
[
0 => 'Default Label',
1 => 'Store Scope Label'
]
);
$this->attributeResourceMock->expects($this->once())->method('save')->with($attributeMock);

$this->model->save($attributeMock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@
},

submit : function() {
var i, child, newNode;

if( TreePanels.root.firstChild == TreePanels.root.lastChild ) {
return;
}
Expand All @@ -221,6 +223,7 @@

if( editSet.currentNode && editSet.currentNode.attributes.cls == 'folder' ) {
TreePanels.root.removeChild(editSet.currentNode);

for( i in editSet.currentNode.childNodes ) {
if( editSet.currentNode.childNodes[i].id ) {
child = editSet.currentNode.childNodes[i];
Expand All @@ -231,12 +234,20 @@
}
}
}

editSet.req.removeGroups[editSet.currentNode.id] = editSet.currentNode.id;
editSet.currentNode = false;
}
},

SystemNodesExists : function(currentNode) {
if (!currentNode) {
alert({
content: '<?php echo $block->escapeJs(__('Please select a node.')) ?>'
});
return;
}

for (i in currentNode.childNodes) {
if (currentNode.childNodes[i].id) {
child = editSet.currentNode.childNodes[i];
Expand All @@ -253,31 +264,40 @@

addGroup : function() {
prompt({
title: "<?php /* @escapeNotVerified */ echo __('Add New Group') ?>",
content: "<?php /* @escapeNotVerified */ echo __('Please enter a new group name.') ?>",
value: "",
validation: true,
validationRules: ['required-entry'],
attributesForm: {
novalidate: 'novalidate',
action: ''
},
attributesField: {
name: 'name',
'data-validate': '{required:true}',
maxlength: '255'
},
actions: {
confirm: function (group_name) {
group_name = group_name.strip();
if( group_name == '' ) {
self.addGroup();
} else if( group_name != false && group_name != null && group_name != '' ) {

if (!editSet.validateGroupName(group_name, 0)) {
return;
}

var newNode = new Ext.tree.TreeNode({
text : group_name.escapeHTML(),
cls : 'folder',
allowDrop : true,
allowDrag : true
});
TreePanels.root.appendChild(newNode);
newNode.addListener('beforemove', editSet.groupBeforeMove);
newNode.addListener('beforeinsert', editSet.groupBeforeInsert);
newNode.addListener('beforeappend', editSet.groupBeforeInsert);
newNode.addListener('click', editSet.register);

if (!editSet.validateGroupName(group_name, 0)) {
return;
}

var newNode = new Ext.tree.TreeNode({
text : group_name.escapeHTML(),
cls : 'folder',
allowDrop : true,
allowDrag : true
});

TreePanels.root.appendChild(newNode);
newNode.addListener('beforemove', editSet.groupBeforeMove);
newNode.addListener('beforeinsert', editSet.groupBeforeInsert);
newNode.addListener('beforeappend', editSet.groupBeforeInsert);
newNode.addListener('click', editSet.register);
}
}
});
Expand All @@ -302,7 +322,7 @@
}
for (var i=0; i < TreePanels.root.childNodes.length; i++) {
if (TreePanels.root.childNodes[i].text.toLowerCase() == name.toLowerCase() && TreePanels.root.childNodes[i].id != exceptNodeId) {
errorText = '<?php /* @escapeNotVerified */ echo __('An attribute group named "/name/" already exists".') ?>';
errorText = '<?php /* @escapeNotVerified */ echo __('An attribute group named "/name/" already exists.') ?>';
alert({
content: errorText.replace("/name/",name)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ define([
'jquery',
'underscore',
'uiRegistry',
'jquery/ui'
'jquery/ui',
'mage/translate'
], function ($, _, registry) {
'use strict';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ define([
'jquery',
'Magento_Ui/js/lib/validation/utils',
'Magento_Ui/js/form/element/abstract',
'Magento_Ui/js/lib/validation/validator'
'Magento_Ui/js/lib/validation/validator',
'mage/translate'
], function ($, utils, Abstract, validator) {
'use strict';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
*/
define([
'uiComponent',
'Magento_Customer/js/customer-data'
'Magento_Customer/js/customer-data',
'mage/translate'
], function (Component, customerData) {
'use strict';

var sidebarInitialized = false;

function initSidebar() {
if (sidebarInitialized) {
return ;
return;
}
sidebarInitialized = true;
require([
'jquery',
'mage/mage'
], function ($) {
/*eslint-disable max-len*/
$('[data-role=compare-products-sidebar]').mage('compareItems', {
"removeConfirmMessage": $.mage.__(
"Are you sure you want to remove this item from your Compare Products list?"
),
"removeSelector": "#compare-items a.action.delete",
"clearAllConfirmMessage": $.mage.__(
"Are you sure you want to remove all items from your Compare Products list?"
),
"clearAllSelector": "#compare-clear-all"
'removeConfirmMessage': $.mage.__('Are you sure you want to remove this item from your Compare Products list?'),
'removeSelector': '#compare-items a.action.delete',
'clearAllConfirmMessage': $.mage.__('Are you sure you want to remove all items from your Compare Products list?'),
'clearAllSelector': '#compare-clear-all'
});

/*eslint-enable max-len*/
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define([], function () {

return {
email: addressData.email,
countryId: (addressData.country_id) ? addressData.country_id : window.checkoutConfig.defaultCountryId,
countryId: addressData['country_id'] || addressData.countryId || window.checkoutConfig.defaultCountryId,
regionId: regionId,
regionCode: (addressData.region) ? addressData.region.region_code : null,
region: (addressData.region) ? addressData.region.region : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ define(
'../action/select-shipping-address',
'./postcode-validator',
'mage/translate',
'uiRegistry'
'uiRegistry',
'Magento_Checkout/js/model/quote'
],
function (
$,
Expand All @@ -22,7 +23,8 @@ define(
selectShippingAddress,
postcodeValidator,
$t,
uiRegistry
uiRegistry,
quote
) {
'use strict';

Expand All @@ -41,7 +43,7 @@ define(
* @param {Object} validator
*/
registerValidator: function (carrier, validator) {
if (checkoutConfig.activeCarriers.indexOf(carrier) != -1) {
if (checkoutConfig.activeCarriers.indexOf(carrier) !== -1) {
validators.push(validator);
}
},
Expand Down Expand Up @@ -174,6 +176,7 @@ define(
address;

if (this.validateAddressData(addressFlat)) {
addressFlat = $.extend(true, {}, quote.shippingAddress(), addressFlat);
address = addressConverter.formAddressDataToQuoteAddress(addressFlat);
selectShippingAddress(address);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/view/frontend/web/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ define([

if (msg) {
alert({
content: $.mage.__(msg)
content: msg
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ define([
'jquery',
'ko',
'underscore',
'sidebar'
'sidebar',
'mage/translate'
], function (Component, customerData, $, ko, _) {
'use strict';

Expand Down Expand Up @@ -68,9 +69,7 @@ define([
'qty': ':input.cart-item-qty',
'button': ':button.update-cart-item'
},
'confirmMessage': $.mage.__(
'Are you sure you would like to remove this item from the shopping cart?'
)
'confirmMessage': $.mage.__('Are you sure you would like to remove this item from the shopping cart?')
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ require([
'jquery',
'mage/template',
'jquery/file-uploader',
'domReady!'
'domReady!',
'mage/translate'
], function ($, mageTemplate) {
$('#<?php echo $block->getHtmlId() ?> .fileupload').fileupload({
dataType: 'json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ define([
'jquery',
'Magento_Ui/js/core/app',
'underscore',
'notification'
'notification',
'mage/translate'
], function (Component, $, bootstrap, _) {
'use strict';

Expand Down Expand Up @@ -221,9 +222,7 @@ define([

if (data.items.length) {
this.productsModal.notification('add', {
message: $.mage.__(
'Choose a new product to delete and replace the current product configuration.'
),
message: $.mage.__('Choose a new product to delete and replace the current product configuration.'),
messageContainer: this.gridSelector
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ define([
this.setNotificationMessage();
},
setNotificationMessage: function () {
/*eslint-disable max-len*/
var msg = $.mage.__('When you remove or add an attribute, we automatically update all configurations and you will need to recreate current configurations manually.');

/*eslint-enable max-len*/

if (this.mode === 'edit') {
this.wizard.setNotificationMessage($.mage.__('When you remove or add an attribute, we automatically ' +
'update all configurations and you will need to recreate current configurations manually.'));
this.wizard.setNotificationMessage(msg);
}
},
doSelectSavedAttributes: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ require([
'mage/template',
'jquery/file-uploader',
'mage/mage',
'prototype'
'prototype',
'mage/translate'
], function(jQuery, registry, mageTemplate){
registry.get('downloadable', function (Downloadable) {
var linkTemplate = '<tr>'+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ require([
'uiRegistry',
'mage/template',
'jquery/file-uploader',
'prototype'
'prototype',
'mage/translate'
], function (jQuery, registry, mageTemplate) {
registry.get('downloadable', function (Downloadable) {
var sampleTemplate = '<tr>'+
Expand Down
Loading

0 comments on commit ca6bdeb

Please sign in to comment.