-
Notifications
You must be signed in to change notification settings - Fork 42
/
tabbedPane.ts
58 lines (50 loc) · 1.76 KB
/
tabbedPane.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* Tabbed view of anything
**
** data-driven
**
*/
import { DataBrowserContext, PaneDefinition } from 'pane-registry'
import { NamedNode } from 'rdflib'
import { icons, ns, tabs, widgets } from 'solid-ui'
const TabbedPane: PaneDefinition = {
icon: icons.iconBase + 'noun_688606.svg',
name: 'tabbed',
audience: [ns.solid('PowerUser')],
// Does the subject deserve this pane?
label: (subject, context) => {
const kb = context.session.store
const typeURIs = kb.findTypeURIs(subject)
if (ns.meeting('Cluster').uri in typeURIs) {
return 'Tabbed'
}
return null
},
render: (subject, context) => {
const dom = context.dom
const store = context.session.store
const div = dom.createElement('div')
;(async () => {
// @@ TODO Remove castings...
await ((store as any).fetcher.load as any)(subject)
div.appendChild(tabs.tabWidget({
dom,
subject,
predicate: store.any(subject, ns.meeting('predicate')) || ns.meeting('toolList'),
ordered: true,
orientation: store.anyValue(subject, ns.meeting('orientation')) || 0,
renderMain: (containerDiv, item) => {
containerDiv.innerHTML = ''
const table = containerDiv.appendChild(context.dom.createElement('table'))
;(context.getOutliner(context.dom) as any).GotoSubject(item, true, null, false, undefined, table)
},
renderTab: (containerDiv, item) => {
const predicate = context.session.store.the(subject, ns.meeting('predicate'))
containerDiv.appendChild(widgets.personTR(context.dom, predicate, item, {}))
},
backgroundColor: store.anyValue(subject, ns.ui('backgroundColor')) || '#ddddcc'
}))
})()
return div
}
}
export default TabbedPane