Improved handling of tag targeting

This commit is contained in:
Stefan Zermatten
2022-07-24 15:22:07 +02:00
parent 82879aaa60
commit 1da2d319fb

View File

@@ -1,4 +1,4 @@
import { get, intersection, difference } from 'lodash';
import { get, intersection, difference, union } from 'lodash';
const linkDependenciesByType = {
action: linkAction,
@@ -144,16 +144,18 @@ function linkEffects(dependencyGraph, prop, computation){
// Returns an array of IDs of the properties the effect targets
function getEffectTagTargets(effect, computation){
const targets = getTargetListFromTags(effect.targetTags, computation);
const notIds = [];
let targets = getTargetListFromTags(effect.targetTags, computation);
let notIds = [];
if (effect.extraTags){
effect.extraTags.forEach(ex => {
if (ex.operation === 'OR'){
targets.push(...getTargetListFromTags(ex.tags, computation));
if (ex.operation === 'OR') {
targets = union(targets, getTargetListFromTags(ex.tags, computation));
} else if (ex.operation === 'NOT'){
ex.tags.forEach(tag => {
const idList = computation.propsWithTag[tag];
if (idList) notIds.push(...computation.propsWithTag[tag])
if (idList) {
notIds = union(notIds, computation.propsWithTag[tag]);
}
});
}
});