Skip to content

Commit 1431628

Browse files
pquernerPascal Quernerkiatng
authored
Allowed system config of type "serialized array" to <depend> on another field (OpenMage#3307)
Co-authored-by: Pascal Querner <[email protected]> Co-authored-by: Ng Kiat Siong <[email protected]>
1 parent 2f606b9 commit 1431628

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

js/mage/adminhtml/form.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,12 @@ FormElementDependenceController.prototype = {
496496
}
497497
return result;
498498
},
499-
499+
hideElem : function(ele) {
500+
ele.hide();
501+
},
502+
showElem : function(ele) {
503+
ele.show();
504+
},
500505
/**
501506
* Define whether target element should be toggled and show/hide its row
502507
*
@@ -507,8 +512,16 @@ FormElementDependenceController.prototype = {
507512
*/
508513
trackChange : function(e, idTo, valuesFrom)
509514
{
515+
let upLevels = this._config.levels_up;
516+
let ele;
510517
if (!$(idTo)) {
511-
return;
518+
idTo = 'row_' + idTo;
519+
ele = $(idTo);
520+
if (!ele) {
521+
return;
522+
}
523+
} else {
524+
ele = $(idTo).up(upLevels);
512525
}
513526

514527
// define whether the target should show up
@@ -536,22 +549,22 @@ FormElementDependenceController.prototype = {
536549
// toggle target row
537550
if (shouldShowUp) {
538551
var currentConfig = this._config;
539-
$(idTo).up(this._config.levels_up).select('input', 'select', 'td').each(function (item) {
552+
ele.select('input', 'select', 'td').each(function (item) {
540553
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
541554
if ((!item.type || item.type != 'hidden') && !($(item.id+'_inherit') && $(item.id+'_inherit').checked)
542555
&& !(currentConfig.can_edit_price != undefined && !currentConfig.can_edit_price)) {
543556
item.disabled = false;
544557
}
545558
});
546-
$(idTo).up(this._config.levels_up).show();
559+
this.showElem(ele);
547560
} else {
548-
$(idTo).up(this._config.levels_up).select('input', 'select', 'td').each(function (item){
561+
ele.select('input', 'select', 'td', 'div').each(function (item){
549562
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
550563
if ((!item.type || item.type != 'hidden') && !($(item.id+'_inherit') && $(item.id+'_inherit').checked)) {
551564
item.disabled = true;
552565
}
553566
});
554-
$(idTo).up(this._config.levels_up).hide();
567+
this.hideElem(ele);
555568
}
556569
}
557570
};

0 commit comments

Comments
 (0)