Skip to content

Commit 0474ed7

Browse files
committed
Merge branch 'dev' of https://github.com/terminusdb/terminus-client into dev
2 parents eede3d3 + 825df47 commit 0474ed7

File tree

4 files changed

+175
-72
lines changed

4 files changed

+175
-72
lines changed

lib/dispatchRequest.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ function DispatchRequest(url, action, payload, local_auth, remote_auth = null) {
8585
case CONST.READ_DATABASE:
8686
case CONST.READ_ORGANIZATION:
8787
case CONST.CONNECT:
88-
case CONST.CLASS_FRAME:
8988
case CONST.GET_CSV:
9089
if (payload) {
9190
const ext = UTILS.URIEncodePayload(payload)

lib/viewer/documentFrame.js

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,6 @@ DocumentFrame.prototype.db = function(dburl){
2424
return this;
2525
}
2626

27-
DocumentFrame.prototype.load = function(url, cls){
28-
if(url) {
29-
if(url.substring(0,4) == "doc:"){
30-
url = url.substring(4);
31-
}
32-
if(this.config.load_schema()){
33-
return this.loadComplete(url, cls)
34-
}
35-
else {
36-
return this.loadDocument(url);
37-
}
38-
}
39-
if(cls){
40-
return this.loadSchema(cls);
41-
}
42-
//return Promise.reject
43-
}
44-
4527
/**
4628
* @param {String} url - loads the document frame from the document API in frame form
4729
* - loads the frame encapsulates more meta-data in the json and reduces the number of api calls we need to make
@@ -90,28 +72,36 @@ DocumentFrame.prototype.loadJSON = function(json, type){
9072
console.error("Either docid or clid must be set before load is called")
9173
}
9274

93-
DocumentFrame.prototype.loadDataFrames = function(dataframes, cls, classframes){
75+
DocumentFrame.prototype.loadData = function(jsonld, cls, classframes){
9476
if(!cls){
9577
if(this.document) cls = this.document.cls;
9678
else {
97-
if(dataframes && dataframes.length && dataframes[0] && dataframes[0].domain){
98-
cls = dataframes[0].domain;
79+
if(jsonld && jsonld["@type"]){
80+
cls = jsonld["@type"];
9981
}
10082
}
10183
}
10284
if(cls){
10385
if(!this.document){
104-
this.document = new ObjectFrame(cls, dataframes, classframes);
86+
alert("Yo")
87+
this.document = new ObjectFrame(cls, jsonld, classframes);
10588
}
10689
else {
107-
this.document.loadDataFrames(dataframes);
108-
}
90+
alert("Yo2")
91+
this.document.loadJSONLDDocument(jsonld);
92+
}
93+
alert(this.document.subjid)
10994
}
11095
else {
11196
console.log("Missing Class" + " " + "Failed to add dataframes due to missing class");
11297
}
11398
}
11499

100+
DocumentFrame.prototype.load = function(classframes, doc){
101+
this.document = new ObjectFrame(doc["@type"], doc, classframes)
102+
}
103+
104+
115105
DocumentFrame.prototype.loadSchemaFrames = function(classframes, cls){
116106
if(!cls){
117107
if(classframes && classframes.length && classframes[0] && classframes[0].domain){
@@ -135,6 +125,29 @@ DocumentFrame.prototype.loadSchemaFrames = function(classframes, cls){
135125
}
136126
}
137127

128+
DocumentFrame.prototype.filterFrame = function(loadRenderer){
129+
var myfilt = function(frame, rule){
130+
if(typeof rule.render() != "undefined"){
131+
frame.render = rule.render();
132+
}
133+
else {
134+
if(rule.renderer()){
135+
var renderer = loadRenderer(rule.renderer(), frame, rule.args);
136+
}
137+
if(renderer){
138+
frame.render = function(fframe){
139+
return renderer(fframe);
140+
}
141+
}
142+
}
143+
if(rule.compare()){
144+
frame.compare = rule.compare();
145+
}
146+
}
147+
this.applyRules(false, false, myfilt);
148+
}
149+
150+
138151
/*
139152
* adds render and compare functions to object frames
140153
*/

lib/viewer/frameConfig.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const Config = require('./viewConfig.js');
32
const FrameRule = require('./frameRule.js');
43
const DocumentFrame = require('./documentFrame.js');

0 commit comments

Comments
 (0)