Skip to content

Commit

Permalink
Diagram: implement Diagram.get_tagged_elements
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-pH committed Jul 15, 2024
1 parent b3739e9 commit 5de19bf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,22 @@ export class Diagram {
}
return newd;
}

/**
* Get all the diagrams that contain a specific tag
* @param tags the tag to filter the diagrams
* @return a list of diagrams
*/
public get_tagged_elements(tags : string | string[] ) : Diagram[] {
if (!Array.isArray(tags)) tags = [tags];
let result = [];

if (this.contain_all_tags(tags)) result.push(this.copy_if_not_mutable());
for (let i = 0; i < this.children.length; i++) {
result = result.concat(this.children[i].get_tagged_elements(tags));
}
return result;
}

/**
* Combine another diagram with this diagram
Expand Down

0 comments on commit 5de19bf

Please sign in to comment.