Skip to content

Commit ba1ca77

Browse files
adding errors
1 parent 8d9a9d6 commit ba1ca77

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

lib/viewer/documentFrame.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,38 @@ DocumentFrame.prototype.filterFrame = function(loadRenderer){
141141
frame.compare = rule.compare();
142142
}
143143
if(rule.errors()){
144-
frame.errors = rule.errors();
145-
}
144+
frame.errors = frame.errors ? frame.errors.concat(rule.errors()) : rule.errors();
145+
}
146+
else if(rule.errors() === false) delete frame.errors
146147
}
147148
this.applyRules(false, false, myfilt);
148149
}
149150

151+
DocumentFrame.prototype.setErrors = function(errors){
152+
this.clearErrors()
153+
let frameconf = TerminusClient.View.document()
154+
for(var i = 0; i<errors.length; i++){
155+
addRuleForVio(frameconf, errors[i])
156+
}
157+
this.applyRules(false, frameconf);
158+
}
159+
160+
DocumentFrame.prototype.clearErrors = function(){
161+
frameconf.all().errors(false)
162+
this.applyRules(false, frameconf)
163+
}
164+
165+
function addRuleForVio(docview, error){
166+
let prop = (error['api:property'] ? error['api:property']["@value"] : false)
167+
let subj = (error['api:subject'] ? error['api:subject']["@value"] : false)
168+
let val = (error['api:value'] ? error['api:value']["@value"] : false)
169+
let type = (error['api:type'] ? error['api:type']["@value"] : false)
170+
if(type && val){ //api:BadCast
171+
frameconf.data().value(val).range(type).errors([error])
172+
}
173+
}
150174

151-
/*
175+
/*"
152176
* adds render and compare functions to object frames
153177
*/
154178
DocumentFrame.prototype.applyRules = function(doc, config, mymatch){

lib/viewer/objectFrame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ PropertyFrame.prototype.fillFromSchema = function (newid) {
657657
this.values = values;
658658
}
659659
else if (this.isClassChoice()) {
660-
const clss = this.cframe.getClassChoices();
660+
const clss = this.cframe.getClassChoices();
661661
if (clss && clss.length) {
662662
const empty = this.cframe.createEmptyChoice(clss[0], FrameHelper.genBNID(FrameHelper.urlFragment(clss[0])+ "_"));
663663
empty.parent = this;

0 commit comments

Comments
 (0)