Changeset 5715 for trunk/prototype/api/datalayer.js
- Timestamp:
- 03/13/12 18:23:02 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/api/datalayer.js
r5615 r5715 136 136 nestedLinks: {}, 137 137 concepts: {}, 138 notArray: {}, 138 139 listeners: {}, 139 140 encoders: {}, … … 388 389 if( data[i][link] ) 389 390 { 390 var isConcept= false;391 392 if( isConcept = this.isConcept( concept, link ) )391 var notArray2 = false; 392 393 if( notArray2 = this.hasOne( concept, link ) ) 393 394 data[i][link] = [ data[i][link] ]; 394 395 395 var _this = this ;396 var _this = this, dependency = this.isDependency( concept, link ); 396 397 397 398 $.each( data[i][link], function( ii, el ){ … … 404 405 //removido pois o mesmo esta gerando inconsistencia em tudo 405 406 // if( DataLayer.isConcept( links[link], nestedLinks[link] ) ) 406 if( isConcept)407 if( !DataLayer.hasOne( links[link], nestedLinks[link] ) ) 407 408 { 408 409 el[ nestedLinks[link] ] = el[ nestedLinks[link] ] || []; … … 413 414 414 415 if( isRef && ( !current[ key ] || !current[ key ][ link ] || 415 ( isConcept? current[ key ][ link ] !== el.id : !$.inArray( el.id, current[ key ][ link ] )) ) )416 (notArray2 ? current[ key ][ link ] !== el.id : !$.inArray( el.id, current[ key ][ link ] )) ) ) 416 417 { 417 418 updateSet[ links[link] ] = updateSet[ links[link] ] || []; … … 422 423 }); 423 424 424 if( isConcept)425 if( notArray2 ) 425 426 data[i][link] = data[i][link][0]; 426 427 } … … 489 490 continue; 490 491 491 if( isConcept = this.isConcept( concept, link ) )492 if( this.hasOne( concept, link ) ) 492 493 current[i][link] = [ current[i][link] ]; 493 494 … … 972 973 973 974 this.links[ concept ] = result['links'] || {}; 975 976 this.notArray[ concept ] = result['hasOne'] || {}; 974 977 975 978 this.nestedLinks[ concept ] = result['nestedLinks'] || {}; … … 985 988 }, 986 989 987 is Concept: function( concept, attr ){990 isDependency: function( concept, attr ){ 988 991 989 992 if( typeof this.concepts[concept] === "undefined" ) … … 993 996 994 997 return !!this.concepts[ concept ][ attr ]; 998 }, 999 1000 hasOne: function( concept, attr ){ 1001 1002 if( typeof this.notArray[concept] === "undefined" ) 1003 { 1004 this.links( concept ); 1005 } 1006 1007 return !!this.notArray[ concept ][ attr ]; 995 1008 }, 996 1009 … … 1112 1125 1113 1126 for( var key in base ) 1114 if( this.storage.filter( base[key], this.copy( filter )) )1127 if( this.storage.filter( base[key], filter ) ) 1115 1128 filtered[ filtered.length ] = key; 1116 1129 … … 1125 1138 1126 1139 1127 compare: function( operator, b ,t ){1140 compare: function( operator, base, test ){ 1128 1141 1129 var base = this.converterType(b);1130 var test = this.converterType(t);1142 base = this.converterType(base); 1143 test = this.converterType(test); 1131 1144 1132 1145 switch( operator ){ … … 1145 1158 case '<': return ( base > test ); 1146 1159 1147 default: return false;1160 default: return true; 1148 1161 } 1149 1162 … … 1164 1177 1165 1178 if( !filter || !result ) 1166 return DataLayer.copy( result || false );1167 1168 var keys = [];1169 1170 if( notArray = $.type( filter) === "string" )1171 keys = [ filter];1172 else if( $.type( filter) !== "array" )1173 keys = this.filter( result, filter.filter, filter.criteria );1179 return( result || false ); 1180 1181 var keys = DataLayer.copy( filter ); 1182 1183 if( notArray = $.type(keys) === "string" ) 1184 keys = [ keys ]; 1185 else if( $.type(keys) !== "array" ) 1186 keys = this.filter( result, keys.filter, keys.criteria ); 1174 1187 1175 1188 var res = []; … … 1178 1191 res[ res.length ] = result[keys[i]]; 1179 1192 1180 return DataLayer.copy( notArray ? res[0] || false : res.length ? res : false );1193 return( notArray ? res[0] || false : res.length ? res : false ); 1181 1194 }, 1182 1195 … … 1192 1205 get: function( key ){ 1193 1206 1194 return this.cache[key];1207 return DataLayer.copy( this.cache[key] ); 1195 1208 1196 1209 },
Note: See TracChangeset
for help on using the changeset viewer.