Changeset 5908


Ignore:
Timestamp:
04/10/12 17:47:50 (12 years ago)
Author:
natan
Message:

Ticket #2603 - Corrigir a camada de sincronizacao - Correcao no remove do cache do cliente

Location:
trunk/prototype/api
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/api/controller.php

    r5905 r5908  
    602602 
    603603            if( isset( self::$fallbackHandlers[ $code ] ) ) 
    604                 return self::$fallbackHandlers[ $code ]( $exception ); 
     604                { 
     605                        $fn = self::$fallbackHandlers[ $code ]; 
     606                        return $fn( $exception ); 
     607                } 
    605608 
    606609            error_log( $exception->getMessage() ); 
  • trunk/prototype/api/datalayer.js

    r5724 r5908  
    460460     
    461461    remove: function( concept, id, oneSide ){ 
    462        
     462         
     463        if( arguments.length === 2 && typeof id === "boolean" ) 
     464        { 
     465                oneSide = id; 
     466                id = false; 
     467    } 
     468 
    463469        var bothSides = (typeof oneSide === "undefined"), 
    464470 
     
    472478            current.id = id; 
    473479 
    474         if( notArray = ( $.type( current ) !== "array" ) ) 
     480        if( id ) 
    475481            current = [ current ]; 
    476482 
    477         for( var i = 0; i < current.length; i++ ) 
     483        $.each( current, function(i, o) 
    478484        { 
    479485            var currentId = ids[ ids.length ] = current[i].id; 
    480486 
    481487            if( bothSides ) 
    482               this.report( concept, currentId, false ); 
     488              DataLayer.report( concept, currentId, false ); 
    483489 
    484490            if( bothSides || !oneSide ) 
    485               this.del( concept, currentId ); 
     491              DataLayer.del( concept, currentId ); 
    486492 
    487493            for( var link in links ) 
    488494            { 
    489                 if( !current[i][link] ) 
    490                     continue; 
    491  
    492                 if( this.hasOne( concept, link ) ) 
    493                     current[i][link] = [ current[i][link] ]; 
    494  
    495                 $.each( current[i][link], function( ii, el ){ 
    496  
    497                         el = DataLayer.storage.cache[links[link]][el]; 
    498  
    499                         if( notArrayNested = ( $.type( el[ nestedLinks[link] ] ) !== "array" ) ) 
    500                             el[ nestedLinks[link] ] = [ el[nestedLinks[link]] ]; 
    501  
    502                         el[ nestedLinks[link] ] = $.grep( el[ nestedLinks[link] ], function( nested, iii ){ 
    503                             return ( currentId !== nested ); 
     495                        if( !current[i][link] ) 
     496                                continue; 
     497 
     498                        if( this.hasOne( concept, link ) ) 
     499                                current[i][link] = [ current[i][link] ]; 
     500 
     501                        $.each( current[i][link], function( ii, el ){ 
     502 
     503                                el = DataLayer.storage.cache[links[link]][el]; 
     504 
     505                                if( notArrayNested = ( $.type( el[ nestedLinks[link] ] ) !== "array" ) ) 
     506                                        el[ nestedLinks[link] ] = [ el[nestedLinks[link]] ]; 
     507 
     508                                el[ nestedLinks[link] ] = $.grep( el[ nestedLinks[link] ], function( nested, iii ){ 
     509                                        return ( currentId !== nested ); 
     510                                }); 
     511 
     512                                if( notArrayNested ) 
     513                                        el[ nestedLinks[link] ] = el[ nestedLinks[link] ][0] || false; 
     514                                if(!el[ nestedLinks[link] ] || !el[ nestedLinks[link] ].length) 
     515                                        delete el[ nestedLinks[link] ]; 
    504516                        }); 
    505  
    506                         if( notArrayNested ) 
    507                             el[ nestedLinks[link] ] = el[ nestedLinks[link] ][0] || false; 
    508                         if(!el[ nestedLinks[link] ] || !el[ nestedLinks[link] ].length) 
    509                                 delete el[ nestedLinks[link] ]; 
    510                 }); 
    511517            } 
    512         } 
     518        }); 
    513519 
    514520        if( oneSide ) 
Note: See TracChangeset for help on using the changeset viewer.