Skip to content

Commit

Permalink
Merge pull request #305 from KateOrient/feature/fix-tree-element-search
Browse files Browse the repository at this point in the history
Fix issue with tree element search
  • Loading branch information
KateOrient authored Dec 27, 2023
2 parents 63bd205 + 6da52dc commit 6a6ed75
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/common/services/treeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import _ from 'lodash';
const TREEPATH = '/StructTreeRoot';

const getIdStringsFromContext = (treeName, context) => {
return context
.split(TREEPATH)[1]
.match(/\(\d+ \d+ \S+ \S+ \S+\)/g)
const pathItems = context.split('/');
if (`/${pathItems[pathItems.length - 1]}`.startsWith(TREEPATH)) {
return null;
}
return (context.split(TREEPATH)[1].match(/\(\d+ \d+ \S+ \S+ \S+\)/g) || [])
.filter((idStr, index) => {
if (index === 0) return !idStr.includes(treeName);
return true;
Expand All @@ -30,6 +32,9 @@ const setRulesTreeIds = (tree, rules) => {
return checks.map(check => {
if (check.context.includes(TREEPATH)) {
const idStrings = getIdStringsFromContext(tree.name, check.context);
if (idStrings === null) {
return { ...check, treeId: null };
}
const treeId = findIdByObjNumbers(tree, idStrings.reverse());
return { ...check, treeId: treeId };
}
Expand Down

0 comments on commit 6a6ed75

Please sign in to comment.