Skip to content

Commit d1e489b

Browse files
committed
Merge branch 'develop' of github.corp.ebay.com:magento2/magento2ce into MAGETWO-38540
2 parents 9bbcd80 + d0e08a2 commit d1e489b

File tree

15 files changed

+239
-130
lines changed

15 files changed

+239
-130
lines changed

app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,8 @@ public function beforeSave($object)
5353
);
5454
}
5555

56-
if ($this->string->substr(
57-
$password,
58-
0,
59-
1
60-
) == ' ' || $this->string->substr(
61-
$password,
62-
$length - 1,
63-
1
64-
) == ' '
65-
) {
66-
throw new LocalizedException(__('The password can\'t begin or end with a space.'));
56+
if (trim($password) != $password) {
57+
throw new LocalizedException(__('The password can not begin or end with a space.'));
6758
}
6859

6960
$object->setPasswordHash($object->hashPassword($password));

app/code/Magento/Customer/view/base/ui_component/customer_form.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@
303303
<item name="validation" xsi:type="array">
304304
<item name="required-entry" xsi:type="boolean">true</item>
305305
</item>
306+
<item name="imports" xsi:type="array">
307+
<item name="default" xsi:type="string">${ $.provider }:data.customer.firstname</item>
308+
</item>
306309
</item>
307310
</argument>
308311
</field>
@@ -325,6 +328,9 @@
325328
<item name="validation" xsi:type="array">
326329
<item name="required-entry" xsi:type="boolean">true</item>
327330
</item>
331+
<item name="imports" xsi:type="array">
332+
<item name="default" xsi:type="string">${ $.provider }:data.customer.lastname</item>
333+
</item>
328334
</item>
329335
</argument>
330336
</field>

app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,31 @@ define([
3232
this._on(events);
3333
},
3434
_updateWishlistData: function(event) {
35-
var dataToAdd = {};
35+
var dataToAdd = {},
36+
isFileUploaded = false;
3637
if (event.handleObj.selector == this.options.qtyInfo) {
3738
this._updateAddToWishlistButton({});
3839
event.stopPropagation();
3940
return;
4041
}
4142
var self = this;
4243
$(event.handleObj.selector).each(function(index, element){
43-
if ($(element).attr('type') == 'text') {
44+
if ($(element).is('input[type=text]')
45+
|| $(element).is('input[type=checkbox]:checked')
46+
|| $(element).is('input[type=radio]:checked')
47+
|| $('#' + element.id + ' option:selected').length
48+
|| $(element).is('textarea')
49+
) {
4450
dataToAdd = $.extend({}, dataToAdd, self._getElementData(element));
4551
return;
4652
}
47-
if ($(element).is(':checked') || $(element).find(':checked').length) {
48-
dataToAdd = $.extend({}, dataToAdd, self._getElementData(element));
53+
if ($(element).is('input[type=file]') && $(element).val()) {
54+
isFileUploaded = true;
4955
}
5056
});
51-
57+
if (isFileUploaded) {
58+
this.bindFormSubmit();
59+
}
5260
this._updateAddToWishlistButton(dataToAdd);
5361
event.stopPropagation();
5462
},
@@ -90,7 +98,9 @@ define([
9098
data[elementName + '[' + option + ']'] = option;
9199
});
92100
} else {
93-
data[elementName] = elementValue;
101+
if (elementValue) {
102+
data[elementName] = elementValue;
103+
}
94104
}
95105
return data;
96106
},
@@ -99,6 +109,23 @@ define([
99109
$.each(dataToRemove, function(key, value) {
100110
delete params.data[key];
101111
});
112+
},
113+
bindFormSubmit: function() {
114+
var self = this;
115+
$('[data-action="add-to-wishlist"]').on('click', function(event) {
116+
event.stopPropagation();
117+
event.preventDefault();
118+
119+
var element = $('input[type=file]' + self.options.customOptionsInfo),
120+
params = $(event.currentTarget).data('post'),
121+
form = $(element).closest('form'),
122+
action = params.action;
123+
if (params.data.uenc) {
124+
action += 'uenc/' + params.data.uenc;
125+
}
126+
127+
$(form).attr('action', action).submit();
128+
});
102129
}
103130
});
104131

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\GiftMessage\Test\Block\Cart;
8+
9+
use Magento\GiftMessage\Test\Fixture\GiftMessage;
10+
use Magento\Mtf\Block\Form;
11+
12+
/**
13+
* Class GiftOptions
14+
* Add gift options on checkout cart order level
15+
*/
16+
class GiftOptions extends Form
17+
{
18+
/**
19+
* Selector for gift message on order form
20+
*
21+
* @var string
22+
*/
23+
protected $giftMessageOrderForm = ".gift-message fieldset";
24+
25+
/**
26+
* Allow gift message on order level
27+
*
28+
* @var string
29+
*/
30+
protected $allowGiftOptions = '.title';
31+
32+
/**
33+
* Selector for apply Gift Message button on item
34+
*
35+
* @var string
36+
*/
37+
protected $giftMessageOrderButton = ".action-update";
38+
39+
/**
40+
* Selector for Gift Message Summary
41+
*
42+
* @var string
43+
*/
44+
protected $giftMessageSummary = ".gift-message-summary";
45+
46+
/**
47+
* Fill gift message form on order level
48+
*
49+
* @param GiftMessage $giftMessage
50+
* @return void
51+
*/
52+
public function fillGiftMessageOrder(GiftMessage $giftMessage)
53+
{
54+
/** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
55+
if ($giftMessage->getAllowGiftMessagesForOrder() === 'Yes') {
56+
$this->_rootElement->find($this->allowGiftOptions)->click();
57+
$giftMessageForm = $this->blockFactory->create(
58+
'Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm',
59+
['element' => $this->_rootElement->find($this->giftMessageOrderForm)]
60+
);
61+
$giftMessageForm->fill($giftMessage);
62+
$this->_rootElement->find($this->giftMessageOrderButton)->click();
63+
$this->waitForElementVisible($this->giftMessageSummary);
64+
}
65+
}
66+
}

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Message/Inline/GiftMessageForm.php renamed to dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/GiftOptions/GiftMessageForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\GiftMessage\Test\Block\Message\Inline;
7+
namespace Magento\GiftMessage\Test\Block\Cart\GiftOptions;
88

99
use Magento\Mtf\Block\Form;
1010

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Message/Inline/GiftMessageForm.xml renamed to dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/GiftOptions/GiftMessageForm.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<mapping strict="0">
99
<fields>
1010
<sender>
11-
<selector>[id^='gift-message'][name$='[from]']</selector>
11+
<selector>[id='gift-message-whole-from']</selector>
1212
</sender>
1313
<recipient>
14-
<selector>[id^='gift-message'][name$='[to]']</selector>
14+
<selector>[id='gift-message-whole-to']</selector>
1515
</recipient>
1616
<message>
17-
<selector>[id^='gift-message'][name$='[message]']</selector>
17+
<selector>[id='gift-message-whole-message']</selector>
1818
</message>
1919
</fields>
2020
</mapping>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\GiftMessage\Test\Block\Cart\Item;
8+
9+
use Magento\GiftMessage\Test\Fixture\GiftMessage;
10+
use Magento\Mtf\Block\Form;
11+
use Magento\Mtf\Client\Locator;
12+
13+
/**
14+
* Add gift options on checkout cart item level
15+
*/
16+
class GiftOptions extends Form
17+
{
18+
/**
19+
* Selector for gift message on item form
20+
*
21+
* @var string
22+
*/
23+
protected $giftMessageItemForm = '//div[@class="gift-message"]//fieldset[ancestor::tbody[contains(.,"%s")]]';
24+
25+
/**
26+
* Allow Gift Options for items
27+
*
28+
* @var string
29+
*/
30+
protected $allowGiftOptions = '//a[contains(@class,"action-gift")][ancestor::tbody[contains(.,"%s")]]';
31+
32+
/**
33+
* Selector for apply Gift Message button on order
34+
*
35+
* @var string
36+
*/
37+
protected $giftMessageItemButton = ".action-update";
38+
39+
/**
40+
* Selector for Gift Message Summary
41+
*
42+
* @var string
43+
*/
44+
protected $giftMessageSummary = '//div[@class="gift-message-summary"][ancestor::tbody[contains(.,"%s")]]';
45+
46+
/**
47+
* Fill gift message form on item level
48+
*
49+
* @param GiftMessage $giftMessage
50+
* @param array $products
51+
* @return void
52+
*/
53+
public function fillGiftMessageItem(GiftMessage $giftMessage, $products = [])
54+
{
55+
/** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
56+
if ($giftMessage->getAllowGiftOptionsForItems() === 'Yes') {
57+
foreach ($products as $product) {
58+
if ($product->getIsVirtual() !== 'Yes') {
59+
$this->_rootElement->find(
60+
sprintf($this->allowGiftOptions, $product->getName()),
61+
Locator::SELECTOR_XPATH
62+
)->click();
63+
$giftMessageForm = $this->blockFactory->create(
64+
'Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm',
65+
[
66+
'element' => $this->_rootElement->find(
67+
sprintf($this->giftMessageItemForm, $product->getName()),
68+
Locator::SELECTOR_XPATH
69+
)
70+
]
71+
);
72+
$giftMessageForm->fill($giftMessage);
73+
$this->_rootElement->find($this->giftMessageItemButton)->click();
74+
$this->waitForElementVisible(
75+
sprintf($this->giftMessageSummary, $product->getName()),
76+
Locator::SELECTOR_XPATH
77+
);
78+
}
79+
}
80+
}
81+
}
82+
}

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Message/Inline.php

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

0 commit comments

Comments
 (0)