Skip to content

Commit

Permalink
Merge branch 'project_pepe' into mftf
Browse files Browse the repository at this point in the history
  • Loading branch information
lfolco committed Sep 23, 2019
2 parents 9e82e91 + 61d3ffa commit e87d4e6
Show file tree
Hide file tree
Showing 21 changed files with 110 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustry}}" userInput="Apps and Games" stepKey="selectAdvancedReportingIndustry"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingHour}}" userInput="11" stepKey="selectAdvancedReportingHour"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingMinute}}" userInput="11" stepKey="selectAdvancedReportingMinute"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingSeconds}}" userInput="00" stepKey="selectAdvancedReportingSeconds"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingHour}}" userInput="23" stepKey="selectAdvancedReportingHour"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingMinute}}" userInput="59" stepKey="selectAdvancedReportingMinute"/>
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingSeconds}}" userInput="59" stepKey="selectAdvancedReportingSeconds"/>
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSaveConfigButton"/>
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the configuration." stepKey="seeSuccess"/>
</test>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Checkout/etc/frontend/sections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
<action name="checkout/cart/add">
<section name="cart"/>
<section name="directory-data"/>
</action>
<action name="checkout/cart/delete">
<section name="cart"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ define([
});

if (
cartData().website_id !== window.checkout.websiteId &&
cartData().website_id !== undefined
cartData().website_id !== window.checkout.websiteId && cartData().website_id !== undefined ||
cartData().storeId !== window.checkout.storeId && cartData().storeId !== undefined
) {
customerData.reload(['cart'], false);
}
Expand Down
39 changes: 39 additions & 0 deletions app/code/Magento/Customer/Block/SectionNamesProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Customer\Block;

use Magento\Customer\CustomerData\SectionPool;
use Magento\Framework\View\Element\Block\ArgumentInterface;

/**
* ViewModel to get sections names array.
*/
class SectionNamesProvider implements ArgumentInterface
{
/**
* @var SectionPool
*/
private $sectionPool;

/**
* @param SectionPool $sectionPool
*/
public function __construct(
SectionPool $sectionPool
) {
$this->sectionPool = $sectionPool;
}

/**
* Return array of section names based on config.
*
* @return array
*/
public function getSectionNames()
{
return $this->sectionPool->getSectionNames();
}
}
10 changes: 10 additions & 0 deletions app/code/Magento/Customer/CustomerData/SectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ public function getSectionsData(array $sectionNames = null, $forceNewTimestamp =
return $sectionsData;
}

/**
* Return array of section names.
*
* @return array
*/
public function getSectionNames()
{
return array_keys($this->sectionSourceMap);
}

/**
* Get section sources by section names
*
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Customer/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@
<argument name="sectionConfig" xsi:type="object">SectionInvalidationConfigData</argument>
</arguments>
</type>
<type name="Magento\Customer\Block\SectionNamesProvider">
<arguments>
<argument name="sectionConfig" xsi:type="object">SectionInvalidationConfigData</argument>
</arguments>
</type>
<preference for="Magento\Customer\CustomerData\JsLayoutDataProviderPoolInterface"
type="Magento\Customer\CustomerData\JsLayoutDataProviderPool"/>
<type name="Magento\Framework\Webapi\ServiceTypeToEntityTypeMap">
Expand Down
9 changes: 6 additions & 3 deletions app/code/Magento/Customer/view/frontend/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@
</arguments>
</block>
<block name="customer.section.config" class="Magento\Customer\Block\SectionConfig"
template="Magento_Customer::js/section-config.phtml"/>
<block name="customer.customer.data"
class="Magento\Customer\Block\CustomerData"
template="Magento_Customer::js/section-config.phtml">
<arguments>
<argument name="sectionNamesProvider" xsi:type="object">Magento\Customer\Block\SectionNamesProvider</argument>
</arguments>
</block>
<block name="customer.customer.data" class="Magento\Customer\Block\CustomerData"
template="Magento_Customer::js/customer-data.phtml"/>
<block name="customer.data.invalidation.rules" class="Magento\Customer\Block\CustomerScopeData"
template="Magento_Customer::js/customer-data/invalidation-rules.phtml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"baseUrls": <?= /* @noEscape */ $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonEncode(array_unique([
$block->getUrl(null, ['_secure' => true]),
$block->getUrl(null, ['_secure' => false]),
])) ?>
])) ?>,
"sectionNames": <?= /* @noEscape */ $this->helper(\Magento\Framework\Json\Helper\Data::class)
->jsonEncode($block->getData('sectionNamesProvider')->getSectionNames()) ?>
}
}
}
Expand Down
31 changes: 6 additions & 25 deletions app/code/Magento/Customer/view/frontend/web/js/customer-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,30 +198,9 @@ define([
* Customer data initialization
*/
init: function () {
var privateContentVersion = 'private_content_version',
privateContent = $.cookieStorage.get(privateContentVersion),
localPrivateContent = $.localStorage.get(privateContentVersion),
needVersion = 'need_version',
expiredSectionNames = this.getExpiredSectionNames();

if (privateContent &&
!$.cookieStorage.isSet(privateContentVersion) &&
!$.localStorage.isSet(privateContentVersion)
) {
$.cookieStorage.set(privateContentVersion, needVersion);
$.localStorage.set(privateContentVersion, needVersion);
this.reload([], false);
} else if (localPrivateContent !== privateContent) {
if (!$.cookieStorage.isSet(privateContentVersion)) {
privateContent = needVersion;
$.cookieStorage.set(privateContentVersion, privateContent);
}
$.localStorage.set(privateContentVersion, privateContent);
_.each(dataProvider.getFromStorage(storage.keys()), function (sectionData, sectionName) {
buffer.notify(sectionName, sectionData);
});
this.reload([], false);
} else if (expiredSectionNames.length > 0) {
var expiredSectionNames = this.getExpiredSectionNames();

if (expiredSectionNames.length > 0) {
_.each(dataProvider.getFromStorage(storage.keys()), function (sectionData, sectionName) {
buffer.notify(sectionName, sectionData);
});
Expand Down Expand Up @@ -341,7 +320,9 @@ define([
var sectionDataIds,
sectionsNamesForInvalidation;

sectionsNamesForInvalidation = _.contains(sectionNames, '*') ? buffer.keys() : sectionNames;
sectionsNamesForInvalidation = _.contains(sectionNames, '*') ? sectionConfig.getSectionNames() :
sectionNames;

$(document).trigger('customer-data-invalidate', [sectionsNamesForInvalidation]);
buffer.remove(sectionsNamesForInvalidation);
sectionDataIds = $.cookieStorage.get('section_data_ids') || {};
Expand Down
12 changes: 11 additions & 1 deletion app/code/Magento/Customer/view/frontend/web/js/section-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
define(['underscore'], function (_) {
'use strict';

var baseUrls, sections, clientSideSections, canonize;
var baseUrls, sections, clientSideSections, sectionNames, canonize;

/**
* @param {String} url
Expand Down Expand Up @@ -70,6 +70,15 @@ define(['underscore'], function (_) {
return _.contains(clientSideSections, sectionName);
},

/**
* Returns array of section names.
*
* @returns {Array}
*/
getSectionNames: function () {
return sectionNames;
},

/**
* @param {Object} options
* @constructor
Expand All @@ -78,6 +87,7 @@ define(['underscore'], function (_) {
baseUrls = options.baseUrls;
sections = options.sections;
clientSideSections = options.clientSideSections;
sectionNames = options.sectionNames;
}
};
});
3 changes: 3 additions & 0 deletions app/code/Magento/Persistent/etc/frontend/sections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
<action name="persistent/index/unsetCookie">
<section name="persistent"/>
</action>
<action name="customer/account/logout">
<section name="persistent"/>
</action>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
<requiredEntity createDataKey="createConfigProduct"/>
<requiredEntity createDataKey="createConfigChildProduct2"/>
</createData>
<magentoCLI command="config:set customer/online_customers/section_data_lifetime 1"
stepKey="setConfigForCartLifetime"/>
<magentoCLI command="cache:flush" stepKey="flushCache" />
</before>
<after>
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
Expand Down Expand Up @@ -116,6 +119,7 @@
</actionGroup>
<closeTab stepKey="closeTab"/>
<!-- Check cart -->
<wait time="60" stepKey="waitForCartToBeUpdated"/>
<reloadPage stepKey="reloadPage"/>
<waitForPageLoad stepKey="waitForCheckoutPageReload"/>
<click selector="{{StorefrontMiniCartSection.show}}" stepKey="clickMiniCart"/>
Expand Down Expand Up @@ -143,6 +147,7 @@
</actionGroup>
<closeTab stepKey="closeTab2"/>
<!--Check cart-->
<wait time="60" stepKey="waitForCartToBeUpdated2"/>
<reloadPage stepKey="reloadPage2"/>
<waitForPageLoad stepKey="waitForCheckoutPageReload2"/>
<click selector="{{StorefrontMiniCartSection.show}}" stepKey="clickMiniCart2"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<input>select</input>
</mode>
<stores>
<selector>[name="stores[0]"]</selector>
<selector>[name="stores[]"]</selector>
<input>multiselectgrouplist</input>
</stores>
<checkbox_text />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CustomerForm extends Form
*
* @var string
*/
protected $customerAttribute = "[orig-name='%s[]']";
protected $customerAttribute = "[name='%s[]']";

/**
* Validation text message for a field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<selector>input[name='start_at']</selector>
</queue_start_at>
<stores>
<selector>select[name="stores[0]"]</selector>
<selector>select[name="stores[]"]</selector>
<input>multiselectgrouplist</input>
</stores>
<newsletter_subject>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<input>select</input>
</price_rule_type>
<order_statuses>
<selector>[name="order_statuses[0]"]</selector>
<selector>[name="order_statuses[]"]</selector>
<input>multiselect</input>
</order_statuses>
<rules_list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<input>select</input>
</show_order_statuses>
<order_statuses>
<selector>[name="order_statuses[0]"]</selector>
<selector>[name="order_statuses[]"]</selector>
<input>multiselect</input>
</order_statuses>
<show_empty_rows>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<strategy>css selector</strategy>
<fields>
<stores>
<selector>[name="stores[0]"]</selector>
<selector>[name="stores[]"]</selector>
<input>multiselectgrouplist</input>
</stores>
<is_active>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<input>select</input>
</show_order_statuses>
<order_statuses>
<selector>[name="order_statuses[0]"]</selector>
<selector>[name="order_statuses[]"]</selector>
<input>multiselect</input>
</order_statuses>
<show_actual_columns>
Expand Down
45 changes: 0 additions & 45 deletions lib/web/mage/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,6 @@
* @protected
*/
_create: function () {
this._prepareArrayInputs();
this.validate = this.element.validate(this.options);

// ARIA (adding aria-required attribute)
Expand All @@ -1938,50 +1937,6 @@
this._listenFormValidate();
},

/**
* Validation creation.
*
* @protected
*/
_prepareArrayInputs: function () {
/* Store original names for array inputs */
var originalElements = [],
originalSubmitHandler = this.options.submitHandler;

/* For all array inputs, assign index so that validation is proper */
this.element.find('[name$="[]"]').each(function (key, input) {
var originalName, name;

input = $(input);
originalName = input.attr('name');
name = originalName.replace('[]', '[' + key + ']');
$(input).attr('name', name);
$(input).attr('orig-name', originalName);
originalElements.push({
element: $(input),
name: originalName
});
});

if (originalElements.length) {
/**
* Before submitting the actual form, remove the previously assigned indices
* @param {Object} form
*/
this.options.submitHandler = function (form) {
originalElements.forEach(function (element) {
element.element.attr('name', element.name);
element.element.removeAttr('orig-name');
});

console.error(this.submit);

/* Call the originalSubmitHandler if it's a function */
typeof originalSubmitHandler === 'function' ? originalSubmitHandler(form) : form.submit();
};
}
},

/**
* Validation listening.
*
Expand Down
23 changes: 9 additions & 14 deletions lib/web/mage/validation/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,18 @@
'validate-one-checkbox-required-by-name': [
function (value, element, params) {
var checkedCount = 0,
selector,
container,
origNameSelector,
nameSelector;
container;

if (element.type === 'checkbox') {
/* If orig-name attribute is present, use it for validation. Else use name */
origNameSelector = '[orig-name="' + element.getAttribute('orig-name') + '"]';
nameSelector = '[name="' + element.name + '"]';
selector = element.getAttribute('orig-name') ? origNameSelector : nameSelector;
$(selector).each(function () {
if ($(this).is(':checked')) {
checkedCount += 1;

return false;
$('[name="' + element.name + '"]').each(
function () {
if ($(this).is(':checked')) {
checkedCount += 1;

return false;
}
}
});
);
}
container = '#' + params;

Expand Down

0 comments on commit e87d4e6

Please sign in to comment.