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