Fix the multiple storage backends incompatibility testing

Fixes the areComponentsMutuallyExclusive method to work properly

Change-Id: I11ea9608fdb02e2f1d3c4523f18733f7b7d5c50d
Closes-Bug: 1526969
This commit is contained in:
Anton Zemlyanov 2015-12-17 15:11:32 +03:00
parent ec723ce89b
commit f337a81945
1 changed files with 9 additions and 9 deletions

View File

@ -124,16 +124,16 @@ function($, _, i18n, React, Backbone, utils, models, componentMixins, dialogs, c
$(React.findDOMNode(this)).find('input:enabled').first().focus();
},
areComponentsMutuallyExclusive: function(components) {
var componentIndex = {};
_.each(components, (component) => {
componentIndex[component.id] = component;
});
return _.any(components, (component) => {
return _.any(component.get('incompatible'), (incompatible) => {
return componentIndex[incompatible.component.id];
});
if (components.length <= 1) {
return false;
}
var allComponentsExclusive = _.all(components, (component) => {
var peerIds = _.pluck(_.reject(components, {id: component.id}), 'id');
var incompatibleIds = _.pluck(_.pluck(component.get('incompatible'), 'component'), 'id');
// peerIds should be subset of incompatibleIds to have exclusiveness property
return peerIds.length == _.intersection(peerIds, incompatibleIds).length;
});
return allComponentsExclusive;
},
processRestrictions: function(paneComponents, types, stopList = []) {
this.processIncompatible(paneComponents, types, stopList);