Skip to content

Commit

Permalink
Adding Default Selects
Browse files Browse the repository at this point in the history
  • Loading branch information
bcameron1231 committed Aug 8, 2024
1 parent 75b5592 commit d3a6c0e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/graph/taxonomy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,28 @@ export class _TermSet extends _GraphInstance<ITermStoreType.Set> {
*/
public async getAllChildrenAsTree(): Promise<IOrderedTermInfo[]> {

const visitor = async (source: { children(): Promise<ITermStoreType.Term[]> }, parent: IOrderedTermInfo[]) => {

const children = await source.children();

const visitor = async (source: ITerm | ITermSet, parent: IOrderedTermInfo[]) => {
const children = await source.children.select('id', 'descriptions', 'createdDateTime','labels', 'lastModifiedDateTime')();
for (let i = 0; i < children.length; i++) {

const child = children[i];

const orderedTerm: Partial<IOrderedTermInfo> = {
children: <IOrderedTermInfo[]>[],
defaultLabel: child.labels.find(l => l.isDefault).name,
...child,
};

parent.push(<any>orderedTerm);

await visitor(this.getTermById(child.id), <any>orderedTerm.children);
}
};

const tree: IOrderedTermInfo[] = [];

await visitor(this, tree);
await visitor(<any>this, tree);

return tree;
}
Expand Down

0 comments on commit d3a6c0e

Please sign in to comment.