Skip to content
Snippets Groups Projects
Commit addb46f7 authored by Cristian Partica's avatar Cristian Partica
Browse files

MAGETWO-54785: [GitHub] State/Province field doesn't show as required on the add new address page

- fixing eslint and jscs errors
parent 56804b23
No related merge requests found
...@@ -25,6 +25,10 @@ define([ ...@@ -25,6 +25,10 @@ define([
isMultipleCountriesAllowed: true isMultipleCountriesAllowed: true
}, },
/**
*
* @private
*/
_create: function () { _create: function () {
this._initCountryElement(); this._initCountryElement();
...@@ -43,12 +47,18 @@ define([ ...@@ -43,12 +47,18 @@ define([
}, this)); }, this));
}, },
_initCountryElement: function() { /**
*
* @private
*/
_initCountryElement: function () {
if (this.options.isMultipleCountriesAllowed) { if (this.options.isMultipleCountriesAllowed) {
this.element.parents('div.field').show(); this.element.parents('div.field').show();
this.element.on('change', $.proxy(function (e) { this.element.on('change', $.proxy(function (e) {
this._updateRegion($(e.target).val()); this._updateRegion($(e.target).val());
}, this)); }, this));
if (this.options.isCountryRequired) { if (this.options.isCountryRequired) {
this.element.addClass('required-entry'); this.element.addClass('required-entry');
this.element.parents('div.field').addClass('required'); this.element.parents('div.field').addClass('required');
...@@ -60,6 +70,7 @@ define([ ...@@ -60,6 +70,7 @@ define([
/** /**
* Remove options from dropdown list * Remove options from dropdown list
*
* @param {Object} selectElement - jQuery object for dropdown list * @param {Object} selectElement - jQuery object for dropdown list
* @private * @private
*/ */
...@@ -113,7 +124,7 @@ define([ ...@@ -113,7 +124,7 @@ define([
* @private * @private
*/ */
_clearError: function () { _clearError: function () {
if (this.options.clearError && typeof (this.options.clearError) === 'function') { if (this.options.clearError && typeof this.options.clearError === 'function') {
this.options.clearError.call(this); this.options.clearError.call(this);
} else { } else {
if (!this.options.form) { if (!this.options.form) {
...@@ -131,8 +142,10 @@ define([ ...@@ -131,8 +142,10 @@ define([
$(this.options.postcodeId).removeClass('mage-error').parent().find('[generated]').remove(); $(this.options.postcodeId).removeClass('mage-error').parent().find('[generated]').remove();
} }
}, },
/** /**
* Update dropdown list based on the country selected * Update dropdown list based on the country selected
*
* @param {String} country - 2 uppercase letter for country code * @param {String} country - 2 uppercase letter for country code
* @private * @private
*/ */
...@@ -188,7 +201,7 @@ define([ ...@@ -188,7 +201,7 @@ define([
regionInput.attr('disabled', 'disabled'); regionInput.attr('disabled', 'disabled');
} }
requiredLabel.removeClass('required'); requiredLabel.removeClass('required');
regionInput.removeClass('required-entry') regionInput.removeClass('required-entry');
} }
regionList.removeClass('required-entry').hide(); regionList.removeClass('required-entry').hide();
...@@ -214,10 +227,11 @@ define([ ...@@ -214,10 +227,11 @@ define([
* @private * @private
*/ */
_checkRegionRequired: function (country) { _checkRegionRequired: function (country) {
this.options.isRegionRequired = false;
var self = this; var self = this;
this.options.isRegionRequired = false;
$.each(this.options.regionJson.config.regions_required, function (index, elem) { $.each(this.options.regionJson.config.regions_required, function (index, elem) {
if (elem == country) { if (elem === country) {
self.options.isRegionRequired = true; self.options.isRegionRequired = true;
} }
}); });
......
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