forked from SolidOS/solid-panes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilder.js
More file actions
63 lines (50 loc) · 1.98 KB
/
builder.js
File metadata and controls
63 lines (50 loc) · 1.98 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
52
53
54
55
56
57
58
59
60
61
62
63
/* Pane builder
**
** This modules builds a pane from a RDF description.
** See also: the Fresnel language.
*/
// UI.panes.metaPane
module.exports = {
icon: UI.icons.originalIconBase + 'rdf_flyer.24.gif', // @@ fix
name: 'dynmaic', // @@ fix
label: function(subject) {
var t, nt, ts = rdf.findTypesNT(subject);
ps ={};
for (nt in ts) {
t = kb.fromNT(nt);
ps = ps.concat(kb.each(t, UI.ns.ui('formDefinition')));
}
for (var i=0; i <ps.length; i++) {
if (UI.panes.index[ps[i].uri] == undefined) { // New one
var pane = {}; // Internal tabulator object
var p = ps[i]; // The pane definition on the web
pane.definition = p;
pane.render = UI.panes.metaPane.render; // ie below
pane.icon = image = kb.any(p, UI.ns.ui('icon'));
pane.label = kb.any(p, UI.ns.ui('icon'));
if (!p.label) p.label = UI.utils.label(p);
pane.definition = p;
UI.panes.index[ps[i].uri] = p;
UI.panes.register(p, false); // no "Find all" button
}
}
return null; // Never be displayed itself
},
// View the object in user-friendly way
render: function(subject, myDocument) {
var kb = UI.store;
var ns = UI.ns;
var div = myDocument.createElement("div")
div.setAttribute('class', 'dataContentPane'); // @@
p = self.definition;
if (!p) throw "Dynamic pane should have a definition".
var template = kb.any(p, ns.link('template'))
// @@@ TBD
// Because of smushing etc, this will not be a copy of the original source
// We could instead either fetch and re-parse the source,
// or we could keep all the pre-smushed triples.
var sts = kb.statementsMatching(undefined, undefined, undefined, subject); // @@ slow with current store!
return div
}
};
// ENDS