forked from SolidOS/solid-panes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtableViewPane.js
More file actions
51 lines (45 loc) · 1.68 KB
/
tableViewPane.js
File metadata and controls
51 lines (45 loc) · 1.68 KB
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
// Format an array of RDF statements as an HTML table.
//
// This can operate in one of three modes: when the class of object is given
// or when the source document from which data is taken is given,
// or if a prepared query object is given.
// (In principle it could operate with neither class nor document
// given but typically
// there would be too much data.)
// When the tableClass is not given, it looks for common classes in the data,
// and gives the user the option.
//
// 2008 Written, Ilaria Liccardi
// 2014 core functionality now in common/table.js -timbl
// ///////////////////////////////////////////////////////////////////
// Table view pane -- view of a class as a table of properties of class members
import * as UI from 'solid-ui-jss'
export const tableViewPane = {
icon: UI.icons.originalIconBase + 'table.png',
name: 'tableOfClass',
label: function (subject, context) {
const store = context.session.store
// if (!store.holds(subject, UI.ns.rdf('type'),UI.ns.rdfs('Class'))) return null
if (!store.any(undefined, UI.ns.rdf('type'), subject)) {
return null
}
const n = store.statementsMatching(undefined, UI.ns.rdf('type'), subject)
.length
if (n === 0) {
// None, suppress pane
return null
}
if (n > 15) {
// @@ At the moment this pane can be slow with too many @@ fixme by using limits
return null
}
return UI.utils.label(subject) + ' table'
},
render: function (subject, context) {
const myDocument = context.dom
const div = myDocument.createElement('div')
div.setAttribute('class', 'tablePane')
div.appendChild(UI.table(myDocument, { tableClass: subject }))
return div
}
}