Skip to content

Commit 06a3a5a

Browse files
fixing frame stuff
1 parent 738af3f commit 06a3a5a

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

lib/viewer/documentFrame.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ DocumentFrame.prototype.filterFrame = function(loadRenderer){
143143
if(rule.compare()){
144144
frame.compare = rule.compare();
145145
}
146+
if(rule.errors()){
147+
frame.errors = rule.errors();
148+
}
146149
}
147150
this.applyRules(false, false, myfilt);
148151
}
@@ -159,7 +162,7 @@ DocumentFrame.prototype.applyRules = function(doc, config, mymatch){
159162
config.setFrameDisplayOptions(frame, rule);
160163
if(mymatch) mymatch(frame, rule);
161164
};
162-
doc.filter(config.rules, onmatch);
165+
doc.mfilter(config.rules, onmatch);
163166
}
164167

165168
module.exports = DocumentFrame ;

lib/viewer/frameConfig.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ DocumentRule.prototype.header = function(m){
237237
return this;
238238
}
239239

240+
241+
DocumentRule.prototype.errors = function(errs){
242+
if(!errs) return this.rule.errors;
243+
this.rule.errors = errs;
244+
return this;
245+
}
246+
247+
240248
DocumentRule.prototype.headerStyle = function(m){
241249
if(!m) return this.rule.headerStyle;
242250
this.rule.headerStyle = m;
@@ -444,7 +452,10 @@ DocumentRule.prototype.prettyPrint = function(){
444452
if(typeof this.args() != "undefined"){
445453
str += ".args(" + JSON.stringify(this.args()) + ")";
446454
}
447-
if(typeof this.showEmpty() != "undefined"){
455+
if(typeof this.errors() != "undefined"){
456+
str += ".errors(" + JSON.stringify(this.errors()) + ")";
457+
}
458+
if(typeof this.showEmpty() != "undefined"){
448459
str += ".showEmpty(" + this.show_empty() + ")";
449460
}
450461
if(typeof this.dataviewer() != "undefined"){

lib/viewer/objectFrame.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,15 @@ ObjectFrame.prototype.clear = function () {
217217
/*
218218
* Filters the frame and its children
219219
*/
220-
ObjectFrame.prototype.filter = function (rules, onmatch) {
220+
ObjectFrame.prototype.mfilter = function (rules, onmatch) {
221221
var hits = new FrameRule().testRules(rules, this, onmatch);
222222
for (const prop of Object.keys(this.properties)) {
223-
this.properties[prop].filter(rules, onmatch);
223+
if(!this.properties[prop].mfilter){
224+
console.log(prop, this.properties[prop])
225+
}
226+
else {
227+
this.properties[prop].mfilter(rules, onmatch);
228+
}
224229
}
225230
return this;
226231
};
@@ -420,20 +425,21 @@ ObjectFrame.prototype.removePropertyValue = function (prop, value, index) {
420425
};
421426

422427
ObjectFrame.prototype.error = function (msg) {
423-
console.error(msg);
424-
};
428+
if(!this.errors) this.errors = []
429+
this.errors.push({"type": "Internal Object Frame Error", msg})
430+
}
425431

426432
ObjectFrame.prototype.extract = function(){
427433
var extracts = {};
428434
for(var prop in this.properties){
429-
if(!Array.isArray(this.properties[prop])) this.properties[prop] = [this.properties[prop]]
430-
for(var i = 0; i<this.properties[prop].length; i++){
431-
var extracted = this.properties[prop][i].extract();
435+
//if(!Array.isArray(this.properties[prop])) this.properties[prop] = [this.properties[prop]]
436+
//for(var i = 0; i<this.properties[prop].length; i++){
437+
var extracted = this.properties[prop].extract();
432438
if(!FrameHelper.empty(extracted)){
433439
if(typeof extracts[prop] == "undefined") extracts[prop] = [];
434440
extracts[prop] = extracts[prop].concat(extracted);
435441
}
436-
}
442+
//}
437443
if(extracts[prop] && extracts[prop].length == 1) extracts[prop] = extracts[prop][0]
438444
}
439445
if(FrameHelper.empty(extracts) && this.parent){
@@ -817,10 +823,10 @@ PropertyFrame.prototype.createEmpty = function(){
817823
}
818824
}
819825

820-
PropertyFrame.prototype.filter = function (rules, onmatch) {
826+
PropertyFrame.prototype.mfilter = function (rules, onmatch) {
821827
var hits = new FrameRule().testRules(rules, this, onmatch);
822828
for (var i = 0; i<this.values.length; i++){
823-
this.values[i].filter(rules, onmatch);
829+
this.values[i].mfilter(rules, onmatch);
824830
}
825831
return this;
826832
}
@@ -941,7 +947,7 @@ DataFrame.prototype.copy = function (newid) {
941947
return copy;
942948
};
943949

944-
DataFrame.prototype.filter = function (rules, onmatch) {
950+
DataFrame.prototype.mfilter = function (rules, onmatch) {
945951
var hits = new FrameRule().testRules(rules, this, onmatch);
946952
return this;
947953
};
@@ -1036,7 +1042,9 @@ ObjectFrame.prototype.getComment = DataFrame.prototype.getComment;
10361042

10371043

10381044
DataFrame.prototype.error = function (msg) {
1039-
if (msg) this.err = msg;
1045+
if (msg) this.err = msg;
1046+
if(!this.errors) this.errors = []
1047+
this.errors.push({"type": "Internal Data Frame Error", msg})
10401048
return this.err;
10411049
};
10421050

0 commit comments

Comments
 (0)