Skip to content
Snippets Groups Projects
Commit 98e7951b authored by Oleksandr Miroshnichenko's avatar Oleksandr Miroshnichenko
Browse files

8410: Custom Checkout Step and Shipping Step are Highlighted

parent a0b5460f
Branches
No related merge requests found
...@@ -66,7 +66,7 @@ define([ ...@@ -66,7 +66,7 @@ define([
* @param {*} sortOrder * @param {*} sortOrder
*/ */
registerStep: function (code, alias, title, isVisible, navigate, sortOrder) { registerStep: function (code, alias, title, isVisible, navigate, sortOrder) {
var hash; var hash, active;
if ($.inArray(code, this.validCodes) !== -1) { if ($.inArray(code, this.validCodes) !== -1) {
throw new DOMException('Step code [' + code + '] already registered in step navigator'); throw new DOMException('Step code [' + code + '] already registered in step navigator');
...@@ -87,6 +87,12 @@ define([ ...@@ -87,6 +87,12 @@ define([
navigate: navigate, navigate: navigate,
sortOrder: sortOrder sortOrder: sortOrder
}); });
active = this.getActiveItemIndex();
steps.each(function (elem, index) {
if (active !== index) {
elem.isVisible(false);
}
});
this.stepCodes.push(code); this.stepCodes.push(code);
hash = window.location.hash.replace('#', ''); hash = window.location.hash.replace('#', '');
...@@ -111,10 +117,14 @@ define([ ...@@ -111,10 +117,14 @@ define([
getActiveItemIndex: function () { getActiveItemIndex: function () {
var activeIndex = 0; var activeIndex = 0;
steps.sort(this.sortItems).forEach(function (element, index) { steps.sort(this.sortItems).some(function (element, index) {
if (element.isVisible()) { if (element.isVisible()) {
activeIndex = index; activeIndex = index;
return true;
} }
return false;
}); });
return activeIndex; return activeIndex;
......
...@@ -46,22 +46,8 @@ define([ ...@@ -46,22 +46,8 @@ define([
/** @inheritdoc */ /** @inheritdoc */
initialize: function () { initialize: function () {
var self = this;
this._super(); this._super();
checkoutDataResolver.resolvePaymentMethod(); checkoutDataResolver.resolvePaymentMethod();
//If some step is active this step will become inactive.
if (stepNavigator.steps()) {
stepNavigator.steps().some(function (element) {
if (element.isVisible()) {
self.isVisible(false);
return true;
}
});
}
stepNavigator.registerStep( stepNavigator.registerStep(
'payment', 'payment',
null, null,
......
...@@ -82,17 +82,6 @@ define([ ...@@ -82,17 +82,6 @@ define([
this._super(); this._super();
if (!quote.isVirtual()) { if (!quote.isVirtual()) {
//If some step is active this step will become inactive.
if (stepNavigator.steps()) {
stepNavigator.steps().some(function (element) {
if (element.isVisible()) {
self.visible(false);
return true;
}
});
}
stepNavigator.registerStep( stepNavigator.registerStep(
'shipping', 'shipping',
'', '',
......
...@@ -42,7 +42,7 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) { ...@@ -42,7 +42,7 @@ define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) {
'Magento_Checkout/js/action/select-shipping-method': jasmine.createSpy(), 'Magento_Checkout/js/action/select-shipping-method': jasmine.createSpy(),
'Magento_Checkout/js/model/shipping-rate-registry': jasmine.createSpy(), 'Magento_Checkout/js/model/shipping-rate-registry': jasmine.createSpy(),
'Magento_Checkout/js/action/set-shipping-information': jasmine.createSpy(), 'Magento_Checkout/js/action/set-shipping-information': jasmine.createSpy(),
'Magento_Checkout/js/model/step-navigator': jasmine.createSpyObj('navigator', ['registerStep', 'steps']), 'Magento_Checkout/js/model/step-navigator': jasmine.createSpyObj('navigator', ['registerStep']),
'Magento_Ui/js/modal/modal': jasmine.createSpy('modal').and.returnValue(modalStub), 'Magento_Ui/js/modal/modal': jasmine.createSpy('modal').and.returnValue(modalStub),
'Magento_Checkout/js/model/checkout-data-resolver': jasmine.createSpyObj( 'Magento_Checkout/js/model/checkout-data-resolver': jasmine.createSpyObj(
'dataResolver', 'dataResolver',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment