Skip to content

Commit

Permalink
Merge branch 'develop' into product-video-PR1
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Miniailo committed Sep 30, 2015
2 parents d71dea3 + 5597840 commit b8ef9bb
Show file tree
Hide file tree
Showing 42 changed files with 577 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ define(
}
});
}
},

getCssClass: function () {
return (this.isCcDetectionEnabled()) ? 'field type detection' : 'field type required';
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@



<!--
/**
* Copyright © 2015 Magento. All rights reserved.
Expand Down Expand Up @@ -61,10 +58,12 @@
</div>
<div>&nbsp;</div>
<!-- /ko -->
<div class="field type required" data-bind="visible: isCcFormShown">
<div data-bind="visible: isCcFormShown, attr: {class: getCssClass()}">
<!-- ko if: (!isCcDetectionEnabled())-->
<label data-bind="attr: {for: getCode() + '_cc_type'}" class="label">
<span><!-- ko i18n: 'Credit Card Type'--><!-- /ko --></span>
</label>
<!-- /ko -->
<div class="control">
<!-- ko if: (!isCcDetectionEnabled())-->
<select name="payment[cc_type]" class="select"
Expand Down Expand Up @@ -153,7 +152,7 @@
<label data-bind="attr: {for: getCode() + '_cc_cid'}" class="label">
<span><!-- ko i18n: 'Card Verification Number'--><!-- /ko --></span>
</label>
<div class="control">
<div class="control _with-tooltip">
<input type="number"
class="input-text cvv"
name="payment[cc_cid]"
Expand Down
52 changes: 51 additions & 1 deletion app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ class AttributeMerger
*/
private $directoryHelper;

/**
* List of codes of countries that must be shown on the top of country list
*
* @var array
*/
private $topCountryCodes;

/**
* @param AddressHelper $addressHelper
* @param Session $customerSession
Expand All @@ -88,6 +95,7 @@ public function __construct(
$this->customerSession = $customerSession;
$this->customerRepository = $customerRepository;
$this->directoryHelper = $directoryHelper;
$this->topCountryCodes = $directoryHelper->getTopCountryCodes();
}

/**
Expand Down Expand Up @@ -177,7 +185,7 @@ protected function getFieldConfig(
? $additionalConfig['sortOrder']
: $attributeConfig['sortOrder'],
'validation' => $this->mergeConfigurationNode('validation', $additionalConfig, $attributeConfig),
'options' => isset($attributeConfig['options']) ? $attributeConfig['options'] : [],
'options' => $this->getFieldOptions($attributeCode, $attributeConfig),
'filterBy' => isset($additionalConfig['filterBy']) ? $additionalConfig['filterBy'] : null,
'customEntry' => isset($additionalConfig['customEntry']) ? $additionalConfig['customEntry'] : null,
'visible' => isset($additionalConfig['visible']) ? $additionalConfig['visible'] : true,
Expand Down Expand Up @@ -318,4 +326,46 @@ protected function getCustomer()
}
return $this->customer;
}

/**
* Retrieve field options from attribute configuration
*
* @param string $attributeCode
* @param array $attributeConfig
* @return array
*/
protected function getFieldOptions($attributeCode, array $attributeConfig)
{
$options = isset($attributeConfig['options']) ? $attributeConfig['options'] : [];
return ($attributeCode == 'country_id') ? $this->orderCountryOptions($options) : $options;
}

/**
* Order country options. Move top countries to the beginning of the list.
*
* @param array $countryOptions
* @return array
*/
protected function orderCountryOptions(array $countryOptions)
{
if (empty($this->topCountryCodes)) {
return $countryOptions;
}

$headOptions = [];
$tailOptions = [[
'value' => 'delimiter',
'label' => '──────────',
'disabled' => true,
]];
foreach ($countryOptions as $countryOption) {
if (empty($countryOption['value']) || in_array($countryOption['value'], $this->topCountryCodes)) {
array_push($headOptions, $countryOption);
} else {
array_push($tailOptions, $countryOption);
}

}
return array_merge($headOptions, $tailOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<item name="grand-total" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/summary/grand-total</item>
<item name="config" xsi:type="array">
<item name="title" xsi:type="string">Grand Total</item>
<item name="title" xsi:type="string">Order Total</item>
<item name="template" xsi:type="string">Magento_Checkout/cart/totals/grand-total</item>
</item>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<script src="Magento_Checkout/js/checkout-loader.js"/>
</head>
<body>
<referenceContainer name="content">
<block class="Magento\Checkout\Block\Onepage" name="checkout.root" template="onepage.phtml" cacheable="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?>
<div class="block discount" id="block-discount" data-mage-init='{"collapsible":{"openedState": "active", "saveState": false}}'>
<div class="title" data-role="title">
<strong id="block-discount-heading" role="heading" aria-level="2"><?php /* @escapeNotVerified */ echo __('Discount Codes') ?></strong>
<strong id="block-discount-heading" role="heading" aria-level="2"><?php /* @escapeNotVerified */ echo __('Apply Discount Code') ?></strong>
</div>
<div class="content" data-role="content" aria-labelledby="block-discount-heading">
<form id="discount-coupon-form"
Expand All @@ -22,16 +22,16 @@
<div class="fieldset coupon<?php strlen($block->getCouponCode()) ? ' applied' : ''?>">
<input type="hidden" name="remove" id="remove-coupon" value="0" />
<div class="field">
<label for="coupon_code" class="label"><span><?php /* @escapeNotVerified */ echo __('Enter your code') ?></span></label>
<label for="coupon_code" class="label"><span><?php /* @escapeNotVerified */ echo __('Enter discount code') ?></span></label>
<div class="control">
<input type="text" class="input-text" id="coupon_code" name="coupon_code" value="<?php echo $block->escapeHtml($block->getCouponCode()) ?>" placeholder="<?php echo $block->escapeHtml(__('Enter your code'));?>" />
<input type="text" class="input-text" id="coupon_code" name="coupon_code" value="<?php echo $block->escapeHtml($block->getCouponCode()) ?>" placeholder="<?php echo $block->escapeHtml(__('Enter discount code'));?>" />
</div>
</div>
<div class="actions-toolbar">
<?php if (!strlen($block->getCouponCode())): ?>
<div class="primary">
<button class="action apply primary" type="button" value="<?php /* @escapeNotVerified */ echo __('Apply Coupon') ?>">
<span><?php /* @escapeNotVerified */ echo __('Apply Coupon') ?></span>
<button class="action apply primary" type="button" value="<?php /* @escapeNotVerified */ echo __('Apply Discount') ?>">
<span><?php /* @escapeNotVerified */ echo __('Apply Discount') ?></span>
</button>
</div>
<?php else: ?>
Expand Down
57 changes: 31 additions & 26 deletions app/code/Magento/Checkout/view/frontend/templates/onepage.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,35 @@

// @codingStandardsIgnoreFile
?>
<div id="checkout" data-bind="scope:'checkout'" class="checkout-container">
<!-- ko template: getTemplate() --><!-- /ko -->
<script type="text/x-magento-init">
{
"#checkout": {
"Magento_Ui/js/core/app": <?php /* @escapeNotVerified */ echo $block->getJsLayout();?>
}
}
</script>
<script>
window.checkoutConfig = <?php /* @escapeNotVerified */ echo \Zend_Json::encode($block->getCheckoutConfig()); ?>;
// Create aliases for customer.js model from customer module
window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
window.customerData = window.checkoutConfig.customerData;
</script>
<script>
require([
'mage/url',
'Magento_Checkout/js/model/step-loader',
'Magento_Ui/js/block-loader'
], function(url, loader, blockLoader) {
loader.registerLoader();
blockLoader("<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('images/loader-1.gif'); ?>");
return url.setBaseUrl('<?php /* @escapeNotVerified */ echo $block->getBaseUrl();?>');
})
</script>
<div id="checkout" data-bind="scope:'checkout'" class="checkout-container">
<div id="checkout-loader" data-role="checkout-loader" class="loading-mask">
<div class="loader">
<img src="<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('images/loader-1.gif'); ?>"
alt="<?php /* @escapeNotVerified */ echo __('Loading...'); ?>"
style="position: absolute;">
</div>
</div>
<!-- ko template: getTemplate() --><!-- /ko -->
<script type="text/x-magento-init">
{
"#checkout": {
"Magento_Ui/js/core/app": <?php /* @escapeNotVerified */ echo $block->getJsLayout();?>
}
}
</script>
<script>
window.checkoutConfig = <?php /* @escapeNotVerified */ echo \Zend_Json::encode($block->getCheckoutConfig()); ?>;
// Create aliases for customer.js model from customer module
window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
window.customerData = window.checkoutConfig.customerData;
</script>
<script>
require([
'mage/url',
'Magento_Ui/js/block-loader'
], function(url, blockLoader) {
blockLoader("<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('images/loader-1.gif'); ?>");
return url.setBaseUrl('<?php /* @escapeNotVerified */ echo $block->getBaseUrl();?>');
})
</script>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ define(
'mage/storage',
'mage/url',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer'
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader'
],
function (quote, urlBuilder, storage, url, errorProcessor, customer) {
function (quote, urlBuilder, storage, url, errorProcessor, customer, fullScreenLoader) {
'use strict';

return function (paymentData, redirectOnSuccess, messageContainer) {
var serviceUrl,
payload;

redirectOnSuccess = redirectOnSuccess === false ? false : true;
redirectOnSuccess = redirectOnSuccess !== false;

/** Checkout for guest and registered customer. */
if (!customer.isLoggedIn()) {
Expand All @@ -39,8 +40,10 @@ define(
billingAddress: quote.billingAddress()
};
}

fullScreenLoader.startLoader();
return storage.post(
serviceUrl, JSON.stringify(payload)
serviceUrl, JSON.stringify(payload), false
).done(
function () {
if (redirectOnSuccess) {
Expand All @@ -50,6 +53,7 @@ define(
).fail(
function (response) {
errorProcessor.process(response, messageContainer);
fullScreenLoader.stopLoader();
}
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ define(
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer'
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader'
],
function (quote, urlBuilder, storage, errorProcessor, customer) {
function (quote, urlBuilder, storage, errorProcessor, customer, fullScreenLoader) {
'use strict';

return function (messageContainer) {
Expand Down Expand Up @@ -39,15 +40,18 @@ define(
billingAddress: quote.billingAddress()
};
}

fullScreenLoader.startLoader();
return storage.post(
serviceUrl, JSON.stringify(payload)
serviceUrl, JSON.stringify(payload), false
).done(
function () {
//do nothing
}
).fail(
function (response) {
errorProcessor.process(response, messageContainer);
fullScreenLoader.stopLoader();
}
);
};
Expand Down
35 changes: 35 additions & 0 deletions app/code/Magento/Checkout/view/frontend/web/js/checkout-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/*jslint browser: true*/
(function () {
'use strict';

var checkInterval;

checkInterval = setInterval(function () {
var checkoutContainer = document.getElementById('checkoutSteps'),
steps,
loaderContainer;

//Return if checkout steps container not loaded
if (!checkoutContainer) {
return;
}

//Checkout steps
steps = checkoutContainer.getElementsByTagName('li');

//Remove loader and clear update interval if content loaded
if (steps && steps.length > 0) {
clearInterval(checkInterval);
loaderContainer = document.getElementById('checkout-loader');

if (loaderContainer && loaderContainer.parentNode) {
loaderContainer.parentNode.removeChild(loaderContainer);
}
}

}, 100);
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/*jshint browser:true jquery:true*/
/*global alert*/
define(
['jquery'],
function ($) {
'use strict';

var containerId = '#checkout';

return {

/**
* Start full page loader action
*/
startLoader: function () {
$(containerId).trigger('processStart');
},

/**
* Stop full page loader action
*/
stopLoader: function () {
$(containerId).trigger('processStop');
}
};
}
);
Loading

0 comments on commit b8ef9bb

Please sign in to comment.