Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Jun 8, 2023
2 parents b478bde + 1431628 commit e3d1626
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions js/mage/adminhtml/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,12 @@ FormElementDependenceController.prototype = {
}
return result;
},

hideElem : function(ele) {
ele.hide();
},
showElem : function(ele) {
ele.show();
},
/**
* Define whether target element should be toggled and show/hide its row
*
Expand All @@ -507,8 +512,16 @@ FormElementDependenceController.prototype = {
*/
trackChange : function(e, idTo, valuesFrom)
{
let upLevels = this._config.levels_up;
let ele;
if (!$(idTo)) {
return;
idTo = 'row_' + idTo;
ele = $(idTo);
if (!ele) {
return;
}
} else {
ele = $(idTo).up(upLevels);
}

// define whether the target should show up
Expand Down Expand Up @@ -536,22 +549,22 @@ FormElementDependenceController.prototype = {
// toggle target row
if (shouldShowUp) {
var currentConfig = this._config;
$(idTo).up(this._config.levels_up).select('input', 'select', 'td').each(function (item) {
ele.select('input', 'select', 'td').each(function (item) {
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
if ((!item.type || item.type != 'hidden') && !($(item.id+'_inherit') && $(item.id+'_inherit').checked)
&& !(currentConfig.can_edit_price != undefined && !currentConfig.can_edit_price)) {
item.disabled = false;
}
});
$(idTo).up(this._config.levels_up).show();
this.showElem(ele);
} else {
$(idTo).up(this._config.levels_up).select('input', 'select', 'td').each(function (item){
ele.select('input', 'select', 'td', 'div').each(function (item){
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
if ((!item.type || item.type != 'hidden') && !($(item.id+'_inherit') && $(item.id+'_inherit').checked)) {
item.disabled = true;
}
});
$(idTo).up(this._config.levels_up).hide();
this.hideElem(ele);
}
}
};
Expand Down

0 comments on commit e3d1626

Please sign in to comment.