From 46006a3c466bf93bd2f3745aef2f13303843d5a7 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 19 Aug 2021 12:20:13 +0800 Subject: [PATCH] fix missing fields/meta data --- Roo/data/JsonReader.js | 24 ++++++++++++++++-------- roojs-bootstrap-debug.js | 28 ++++++++++++++++++---------- roojs-bootstrap.js | 7 ++++--- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Roo/data/JsonReader.js b/Roo/data/JsonReader.js index 98c8ce888c..e325149adf 100644 --- a/Roo/data/JsonReader.js +++ b/Roo/data/JsonReader.js @@ -187,19 +187,27 @@ Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, { } var records = []; for(var i = 0; i < c; i++){ - var n = root[i]; + var n = root[i]; var values = {}; var id = this.getId(n); for(var j = 0; j < fl; j++){ f = fi[j]; - var v = this.ef[j](n); - if (!f.convert) { - Roo.log('missing convert for ' + f.name); - Roo.log(f); - continue; - } - values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue); + var v = this.ef[j](n); + if (!f.convert) { + Roo.log('missing convert for ' + f.name); + Roo.log(f); + continue; + } + values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue); } + if (!Record) { + return { + raw : { errorMsg : "JSON Reader Error: fields or metadata not available to create Record" }, + success : false, + records : [], + totalRecords : 0 + }; + } var record = new Record(values, id); record.json = n; records[i] = record; diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index eb8c55881d..15aecbb023 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -6546,7 +6546,7 @@ Roo.extend(Roo.bootstrap.nav.Item, Roo.bootstrap.Component, { this.href === false || this.href === '#' ){ - Roo.log("NavItem - prevent Default?"); + //Roo.log("NavItem - prevent Default?"); e.preventDefault(); } @@ -16655,19 +16655,27 @@ Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, { } var records = []; for(var i = 0; i < c; i++){ - var n = root[i]; + var n = root[i]; var values = {}; var id = this.getId(n); for(var j = 0; j < fl; j++){ f = fi[j]; - var v = this.ef[j](n); - if (!f.convert) { - Roo.log('missing convert for ' + f.name); - Roo.log(f); - continue; - } - values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue); - } + var v = this.ef[j](n); + if (!f.convert) { + Roo.log('missing convert for ' + f.name); + Roo.log(f); + continue; + } + values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue); + } + if (!Record) { + return { + raw : { errorMsg : "JSON Reader Error: fields or metadata not available to create Record" }, + success : false, + records : [], + totalRecords : 0 + }; + } var record = new Record(values, id); record.json = n; records[i] = record; diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index f8253afbb0..32e8f08ec2 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -279,8 +279,8 @@ if(this.href){A.href=this.href;}if(this.fa){A.html=' '+A.cn[0].html+'';}else if(this.glyphicon){A.cn[0].html=' '+A.cn[0].html;}else{A.cn[0].cls+=" nav-html"; }if(this.menu){A.cn[0].html+=" ";}if(this.badge!==''){A.cn[0].html+=' '+this.badge+'';}}return A;},onRender:function(ct,A){if(Roo.bootstrap.version==4&&ct.dom.type!='ul'){this.tag='div'; }var B=Roo.bootstrap.nav.Item.superclass.onRender.call(this,ct,A);this.navLink=this.el.select('.nav-link',true).first();this.htmlEl=this.el.hasClass('nav-html')?this.el:this.el.select('.nav-html',true).first();return B;},initEvents:function(){if(typeof(this.menu)!='undefined'){this.menu.parentType=this.xtype; -this.menu.triggerEl=this.el;this.menu=this.addxtype(Roo.apply({},this.menu));}this.el.on('click',this.onClick,this);this.parent().register(this);},onClick:function(e){if(e.getTarget('.dropdown-menu-item')){return;}if(this.preventDefault||this.href===false||this.href==='#'){Roo.log("NavItem - prevent Default?"); -e.preventDefault();}if(this.disabled){return;}var tg=Roo.bootstrap.TabGroup.get(this.navId);if(tg&&tg.transition){Roo.log("waiting for the transitionend");return;}if(this.fireEvent('click',this,e)===false){return;};if(this.tagtype=='span'){return;}var A=this.el.select('a',true).first(); +this.menu.triggerEl=this.el;this.menu=this.addxtype(Roo.apply({},this.menu));}this.el.on('click',this.onClick,this);this.parent().register(this);},onClick:function(e){if(e.getTarget('.dropdown-menu-item')){return;}if(this.preventDefault||this.href===false||this.href==='#'){e.preventDefault(); +}if(this.disabled){return;}var tg=Roo.bootstrap.TabGroup.get(this.navId);if(tg&&tg.transition){Roo.log("waiting for the transitionend");return;}if(this.fireEvent('click',this,e)===false){return;};if(this.tagtype=='span'){return;}var A=this.el.select('a',true).first(); if(A&&this.animateRef&&this.href.indexOf('#')>-1){if(A.dom.href.split("#")[0]!=document.location.toString().split("#")[0]){return;}Roo.log("NavItem - prevent Default?");e.preventDefault();this.scrollToElement(e);}var p=this.parent();if(['tabs','pills'].indexOf(p.type)!==-1&&p.pilltype){if(typeof(p.setActiveItem)!=='undefined'){p.setActiveItem(this); }}if(p.parentType=='NavHeaderbar'&&!this.menu){p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');}},isActive:function(){return this.active},setActive:function(A,B,C){if(this.active&&!A&&this.navId){this.was_active=true;var nv=Roo.bootstrap.nav.Group.get(this.navId); if(nv){nv.clearWasActive(this);}}this.active=A;if(!A){this.el.removeClass('active');this.navLink?this.navLink.removeClass('active'):false;}else if(!this.el.hasClass('active')){this.el.addClass('active');if(Roo.bootstrap.version==4&&this.navLink){this.navLink.addClass('active'); @@ -697,7 +697,8 @@ return Roo.emptyFn;};}(),readRecords:function(o){this.o=o;var s=this.meta,A=this }this.getRoot=s.root?this.getJsonAccessor(s.root):function(p){return p;};if(s.id){var g=this.getJsonAccessor(s.id);this.getId=function(I){var r=g(I);return (r===undefined||r==="")?null:r;};}else{this.getId=function(){return null;};}this.ef=[];for(var jj=0; jj