blob: 66bc75a5401c0c9ad3e97498b4472301761224f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { generateUrl } from '@nextcloud/router'
import { GROUP_ALL_CONTACTS } from '../models/constants.ts'
export const getChart = (list, parent, nodes = []) => {
if (!nodes.length) {
nodes.push(list.find(node => node.nodeId === parent))
}
const children = list.filter(node => {
return node.parentNodeId === parent
})
children.forEach(node => {
nodes.push(node)
getChart(list, node.nodeId, nodes)
})
return nodes
}
export const transformNode = (contact) => {
return {
nodeId: contact.uid,
key: contact.key,
parentNodeId: contact.managersName,
fullName: contact.displayName,
org: contact.org,
photoUrl: `${contact.url}?photo`,
title: contact.title,
link: generateUrl(`apps/contacts/${GROUP_ALL_CONTACTS}/${contact.key}`),
expanded: !contact.managersName,
}
}
|