Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes system config dependencies for multiselect fields #317

Merged
merged 1 commit into from
Nov 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions js/mage/adminhtml/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,19 @@ FormElementDependenceController.prototype = {
levels_up : 1 // how many levels up to travel when toggling element
},

getSelectValues : function(select) {
var result = [];
var options = select && select.options;
var opt;
for (var i = 0, iLen = options.length; i < iLen; i++) {
opt = options[i];
if (opt.selected) {
result.push(opt.value);
}
}
return result;
}

/**
* Define whether target element should be toggled and show/hide its row
*
Expand All @@ -529,13 +542,20 @@ FormElementDependenceController.prototype = {
var shouldShowUp = true;
for (var idFrom in valuesFrom) {
var from = $(idFrom);
if (valuesFrom[idFrom] instanceof Array) {
if (!from || valuesFrom[idFrom].indexOf(from.value) == -1) {
if (from.tagName === 'SELECT' && from.className.indexOf('multiselect') > -1) {
var elementValues = this.getSelectValues(from);
if (!from || elementValues.indexOf(valuesFrom[idFrom]) <= -1) {
shouldShowUp = false;
}
} else {
if (!from || from.value != valuesFrom[idFrom]) {
shouldShowUp = false;
if (valuesFrom[idFrom] instanceof Array) {
if (!from || valuesFrom[idFrom].indexOf(from.value) == -1) {
shouldShowUp = false;
}
} else {
if (!from || from.value != valuesFrom[idFrom]) {
shouldShowUp = false;
}
}
}
}
Expand Down