@@ -67,6 +67,7 @@ require(["prototype"], function(){
67
67
upsXml.prototype = {
68
68
initialize: function()
69
69
{
70
+ this.carriersUpsActiveId = 'carriers_ups_active';
70
71
this.carriersUpsTypeId = 'carriers_ups_type';
71
72
if (!$(this.carriersUpsTypeId)) {
72
73
return;
@@ -94,6 +95,7 @@ require(["prototype"], function(){
94
95
95
96
this.setFormValues();
96
97
Event.observe($(this.carriersUpsTypeId), 'change', this.setFormValues.bind(this));
98
+ Event.observe($(this.carriersUpsActiveId), 'change', this.setFormValues.bind(this));
97
99
},
98
100
updateAllowedMethods: function(originShipmentTitle)
99
101
{
@@ -121,7 +123,7 @@ require(["prototype"], function(){
121
123
freeMethod.insert(option);
122
124
123
125
option = new Element('option', {value:code}).update(originShipment[code]);
124
- if (this.storedUpsType == 'UPS_XML ') {
126
+ if (this.storedUpsType == 'UPS ') {
125
127
if (originShipmentTitle != 'default' || inArray(this.storedAllowedMethods, code)) {
126
128
option.selected = true;
127
129
}
@@ -143,12 +145,13 @@ require(["prototype"], function(){
143
145
setFormValues: function()
144
146
{
145
147
var a;
146
- if ($F(this.carriersUpsTypeId) == 'UPS_XML ') {
148
+ if ($F(this.carriersUpsTypeId) == 'UPS ') {
147
149
for (a = 0; a < this.checkingUpsXmlId.length; a++) {
148
150
$(this.checkingUpsXmlId[a]).removeClassName('required-entry');
149
151
}
150
152
for (a = 0; a < this.checkingUpsId.length; a++) {
151
- $(this.checkingUpsXmlId[a]).addClassName('required-entry');
153
+ $(this.checkingUpsId[a]).addClassName('required-entry');
154
+ this.changeFieldsDisabledState(this.checkingUpsId, a);
152
155
}
153
156
Event.stopObserving($('carriers_ups_origin_shipment'), 'change', this.changeOriginShipment.bind(this));
154
157
showRowArrayElements(this.onlyUpsElements);
@@ -157,9 +160,10 @@ require(["prototype"], function(){
157
160
} else {
158
161
for (a = 0; a < this.checkingUpsXmlId.length; a++) {
159
162
$(this.checkingUpsXmlId[a]).addClassName('required-entry');
163
+ this.changeFieldsDisabledState(this.checkingUpsXmlId, a);
160
164
}
161
165
for (a = 0; a < this.checkingUpsId.length; a++) {
162
- $(this.checkingUpsXmlId [a]).removeClassName('required-entry');
166
+ $(this.checkingUpsId [a]).removeClassName('required-entry');
163
167
}
164
168
Event.observe($('carriers_ups_origin_shipment'), 'change', this.changeOriginShipment.bind(this));
165
169
showRowArrayElements(this.onlyUpsXmlElements);
@@ -171,6 +175,16 @@ require(["prototype"], function(){
171
175
{
172
176
this.originShipmentTitle = key ? key : $F('carriers_ups_origin_shipment');
173
177
this.updateAllowedMethods(this.originShipmentTitle);
178
+ },
179
+ changeFieldsDisabledState: function (fields, key) {
180
+ $(fields[key]).disabled = $F(this.carriersUpsActiveId) !== '1'
181
+ || $(fields[key] + '_inherit') !== null
182
+ && $F(fields[key] + '_inherit') === '1';
183
+
184
+ if ($(fields[key]).next() !== undefined) {
185
+ $(fields[key]).removeClassName('mage-error').next().remove();
186
+ $(fields[key]).removeAttribute('style');
187
+ }
174
188
}
175
189
};
176
190
xml = new upsXml();
0 commit comments