Skip to content

Commit 2a70b82

Browse files
author
Oleksii Korshenko
authored
Merge pull request #250 from magento-frontend/PR
Fixed Issues: - MAGETWO-54186: Problem with js validation when adding product to shopping cart - MAGETWO-47553: Customer account info form is broken if middle name attribute is visible - MAGETWO-55279: XSD for view.xml is too strict - MAGETWO-53533: Gift Wrapping price field is broken in Admin page
2 parents 92143fe + a57fb41 commit 2a70b82

File tree

13 files changed

+223
-36
lines changed

13 files changed

+223
-36
lines changed

app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
</div>
4141
</div>
4242
<?php endif; ?>
43+
<?php if ($block->isRedirectToCartEnabled()) : ?>
4344
<script type="text/x-magento-init">
4445
{
4546
"#product_addtocart_form": {
@@ -49,11 +50,11 @@
4950
}
5051
}
5152
</script>
52-
<?php if (!$block->isRedirectToCartEnabled()) : ?>
53+
<?php else : ?>
5354
<script type="text/x-magento-init">
5455
{
5556
"#product_addtocart_form": {
56-
"catalogAddToCart": {}
57+
"Magento_Catalog/js/validate-product": {}
5758
}
5859
}
5960
</script>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright © 2016 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'jquery',
7+
'mage/mage',
8+
'Magento_Catalog/product/view/validation',
9+
'catalogAddToCart'
10+
], function ($) {
11+
'use strict';
12+
13+
$.widget('mage.productValidate', {
14+
options: {
15+
bindSubmit: false,
16+
radioCheckboxClosest: '.nested'
17+
},
18+
19+
/**
20+
* Uses Magento's validation widget for the form object.
21+
* @private
22+
*/
23+
_create: function () {
24+
var bindSubmit = this.options.bindSubmit;
25+
26+
this.element.validation({
27+
radioCheckboxClosest: this.options.radioCheckboxClosest,
28+
29+
/**
30+
* Uses catalogAddToCart widget as submit handler.
31+
* @param {Object} form
32+
* @returns {Boolean}
33+
*/
34+
submitHandler: function (form) {
35+
var jqForm = $(form).catalogAddToCart({
36+
bindSubmit: bindSubmit
37+
});
38+
39+
jqForm.catalogAddToCart('submitForm', jqForm);
40+
41+
return false;
42+
}
43+
});
44+
}
45+
});
46+
47+
return $.mage.productValidate;
48+
});

app/code/Magento/Customer/Setup/CustomerSetup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function getDefaultEntities()
166166
],
167167
'prefix' => [
168168
'type' => 'static',
169-
'label' => 'Prefix',
169+
'label' => 'Name Prefix',
170170
'input' => 'text',
171171
'required' => false,
172172
'sort_order' => 30,
@@ -202,7 +202,7 @@ public function getDefaultEntities()
202202
],
203203
'suffix' => [
204204
'type' => 'static',
205-
'label' => 'Suffix',
205+
'label' => 'Name Suffix',
206206
'input' => 'text',
207207
'required' => false,
208208
'sort_order' => 70,
@@ -350,7 +350,7 @@ public function getDefaultEntities()
350350
'attributes' => [
351351
'prefix' => [
352352
'type' => 'static',
353-
'label' => 'Prefix',
353+
'label' => 'Name Prefix',
354354
'input' => 'text',
355355
'required' => false,
356356
'sort_order' => 10,
@@ -386,7 +386,7 @@ public function getDefaultEntities()
386386
],
387387
'suffix' => [
388388
'type' => 'static',
389-
'label' => 'Suffix',
389+
'label' => 'Name Suffix',
390390
'input' => 'text',
391391
'required' => false,
392392
'sort_order' => 50,

app/code/Magento/Customer/Setup/InstallSchema.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
100100
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
101101
40,
102102
['nullable' => true, 'default' => null],
103-
'Prefix'
103+
'Name Prefix'
104104
)->addColumn(
105105
'firstname',
106106
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
@@ -124,7 +124,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
124124
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
125125
40,
126126
['nullable' => true, 'default' => null],
127-
'Suffix'
127+
'Name Suffix'
128128
)->addColumn(
129129
'dob',
130130
\Magento\Framework\DB\Ddl\Table::TYPE_DATE,
@@ -308,7 +308,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
308308
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
309309
40,
310310
['nullable' => true, 'default' => null],
311-
'Prefix'
311+
'Name Prefix'
312312
)->addColumn(
313313
'region',
314314
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
@@ -332,7 +332,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
332332
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
333333
40,
334334
['nullable' => true, 'default' => null],
335-
'Suffix'
335+
'Name Suffix'
336336
)->addColumn(
337337
'telephone',
338338
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,

app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class NameTest extends \PHPUnit_Framework_TestCase
4444

4545
const INVALID_ATTRIBUTE_CODE = 'invalid attribute code';
4646

47-
const PREFIX_STORE_LABEL = 'Prefix';
47+
const PREFIX_STORE_LABEL = 'Name Prefix';
4848

4949
/**#@-*/
5050

app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function testSendNewAccountEmailWithoutStoreId()
198198
'firstname' => 'FirstName',
199199
'lastname' => 'LastName',
200200
'middlename' => 'MiddleName',
201-
'prefix' => 'Prefix',
201+
'prefix' => 'Name Prefix',
202202
]);
203203
$this->_model->sendNewAccountEmail('registered');
204204
}

app/design/adminhtml/Magento/backend/Magento_GiftWrapping/web/css/source/_module.less

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,76 @@
8282
}
8383
}
8484
}
85+
86+
//
87+
// Stores -> Other Settings -> Gift wrapping (create/edit)
88+
// _____________________________________________
89+
// TODO UI: remove after page build on ui-components
90+
91+
[class*='adminhtml-giftwrapping-'] {
92+
.field-base_price {
93+
.admin__field-control {
94+
max-width: @field-size__s;
95+
}
96+
97+
.admin__control-addon {
98+
> .addafter {
99+
&:extend(.admin__addon-prefix all);
100+
.lib-vendor-prefix-flex-basis(auto);
101+
.lib-vendor-prefix-flex-grow(0);
102+
.lib-vendor-prefix-flex-shrink(0);
103+
position: relative;
104+
z-index: 1;
105+
}
106+
107+
[class*='admin__control-'][class] {
108+
& ~ .addafter:last-child {
109+
padding-left: 1rem;
110+
position: static !important;
111+
z-index: 0;
112+
113+
> * {
114+
position: relative;
115+
vertical-align: top;
116+
z-index: 1;
117+
}
118+
}
119+
120+
& ~ .addafter:last-child:before {
121+
&:extend(.abs-form-control-pattern);
122+
bottom: 0;
123+
box-sizing: border-box;
124+
content: '';
125+
left: 0;
126+
position: absolute;
127+
top: 0;
128+
width: 100%;
129+
z-index: -1;
130+
}
131+
132+
&[disabled] ~ .addafter:last-child:before {
133+
&:extend(.abs-form-control-pattern[disabled]);
134+
}
135+
136+
&:focus ~ .addafter:last-child:before {
137+
&:extend(.abs-form-control-pattern:focus);
138+
}
139+
140+
&:hover ~ .addafter:last-child:before {
141+
&:extend(.abs-form-control-pattern:hover);
142+
}
143+
}
144+
}
145+
}
146+
147+
.field-image {
148+
.admin__field-control {
149+
padding-top: .8rem;
150+
151+
> a {
152+
display: inline-block;
153+
vertical-align: middle;
154+
}
155+
}
156+
}
157+
}

app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,25 @@
8787
}
8888
}
8989

90+
// Full name fieldset
91+
.fieldset {
92+
.fullname {
93+
&.field {
94+
> .label {
95+
&:extend(.abs-visually-hidden all);
96+
97+
+ .control {
98+
width: 100%;
99+
}
100+
}
101+
}
102+
103+
.field {
104+
&:extend(.abs-add-clearfix all);
105+
}
106+
}
107+
}
108+
90109
//
91110
// My account
92111
// ---------------------------------------------
@@ -400,18 +419,23 @@
400419
}
401420
}
402421

403-
.form-create-account {
404-
.fieldset-fullname {
405-
.fields {
406-
.field {
422+
// Full name fieldset
423+
.fieldset {
424+
.fullname {
425+
.field {
426+
.label {
427+
.lib-css(margin, @form-field-type-label-inline__margin);
428+
.lib-css(padding, @form-field-type-label-inline__padding);
429+
.lib-css(text-align, @form-field-type-label-inline__align);
430+
.lib-css(width, @form-field-type-label-inline__width);
431+
box-sizing: border-box;
407432
float: left;
408-
margin: 0 @indent__s @indent__s 0;
409433
}
410-
}
411434

412-
.field-name-prefix,
413-
.field-name-suffix {
414-
width: 50px;
435+
.control {
436+
.lib-css(width, @form-field-type-control-inline__width);
437+
float: left;
438+
}
415439
}
416440
}
417441
}

app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@
9595
}
9696
}
9797

98+
// Full name fieldset
99+
.fieldset {
100+
.fullname {
101+
> .label {
102+
&:extend(.abs-visually-hidden all);
103+
}
104+
}
105+
}
106+
98107
.box-billing-address,
99108
.box-shipping-address,
100109
.box-information,
@@ -349,9 +358,15 @@
349358
.form-create-account {
350359
.fieldset-fullname {
351360
.fields {
361+
display: table;
362+
width: 100%;
363+
352364
.field {
353-
float: left;
354-
margin: 0 @indent__s @indent__s 0;
365+
display: table-cell;
366+
367+
+ .field {
368+
padding-left: @indent__s;
369+
}
355370
}
356371
}
357372

@@ -441,7 +456,7 @@
441456
}
442457

443458
.form-address-edit {
444-
.fieldset {
459+
> .fieldset {
445460
&:extend(.abs-blocks-2columns all);
446461
}
447462
}

dev/tests/integration/testsuite/Magento/Customer/Block/Widget/NameTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function testToHtmlSimpleName()
4848
$this->assertContains('title="Last Name"', $html);
4949
$this->assertContains('value="Doe"', $html);
5050
$this->assertNotContains('title="Middle Name/Initial"', $html);
51-
$this->assertNotContains('title="Prefix"', $html);
52-
$this->assertNotContains('title="Suffix"', $html);
51+
$this->assertNotContains('title="Name Prefix"', $html);
52+
$this->assertNotContains('title="Name Suffix"', $html);
5353
}
5454

5555
/**
@@ -84,9 +84,9 @@ public function testToHtmlFancyName()
8484
$this->assertContains('value="Doe"', $html);
8585
$this->assertContains('title="Middle Name/Initial"', $html);
8686
$this->assertContains('value="Roe"', $html);
87-
$this->assertContains('title="Prefix"', $html);
87+
$this->assertContains('title="Name Prefix"', $html);
8888
$this->assertContains('value="Dr."', $html);
89-
$this->assertContains('title="Suffix"', $html);
89+
$this->assertContains('title="Name Suffix"', $html);
9090
$this->assertContains('value="Ph.D."', $html);
9191
}
9292
}

lib/internal/Magento/Framework/Config/Test/Unit/XsdTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public function testInvalidXmlFile($xsdFile, $invalidXmlFile, $expectedErrorsQty
3838
*/
3939
public function invalidXmlFileDataProvider()
4040
{
41-
return [['view.xsd', 'view_invalid.xml', 1], ['theme.xsd', 'theme_invalid.xml', 1]];
41+
return [['view.xsd', 'view_invalid.xml', 8], ['theme.xsd', 'theme_invalid.xml', 1]];
4242
}
4343
}

lib/internal/Magento/Framework/Config/Test/Unit/_files/view_invalid.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,21 @@
1010
<var name="var1">Value1</var>
1111
<var name="var1">Value1</var><!-- duplicate var name -->
1212
</vars>
13+
<media>
14+
<images module="Magento_Catalog">
15+
<!-- Valid image type values -->
16+
<image id="test" type="valid"/>
17+
<image id="test" type="valid_image"/>
18+
<image id="test" type="valid_image_type"/>
19+
<!-- Invalid image type values -->
20+
<image id="test" type="_invalid_image_type"/>
21+
<image id="test" type="invalid-image"/>
22+
<image id="test" type="Invalid"/>
23+
<image id="test" type="invalid_"/>
24+
<image id="test" type="invalid__image"/>
25+
<image id="test" type="i"/>
26+
<image id="test" type="?invalid"/>
27+
<image id="test" type="123"/>
28+
</images>
29+
</media>
1330
</view>

0 commit comments

Comments
 (0)