Ignore:
Timestamp:
06/19/12 23:40:56 (12 years ago)
Author:
natan
Message:

Ticket #2845 - Atualizacao da API na busca de mensagens - Correcao do problema nas paginacoes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/expressoServiceImap/prototype/modules/attach_message/common.js

    r6510 r6545  
    44months = ['Jan','Feb','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec']; 
    55current_folder = 'INBOX'; 
     6current_count = DataLayer.get( 'message', { criteria: { count: true, properties: {context:{folder:current_folder}} } }, true ); 
    67 
    78DataLayer.codec( 'folder', 'tree', { 
     
    5657 
    5758      encoder: function( data, crit ){ 
    58  
    59             if( !crit.criteria.properties.context.folder.indexOf( 'local_messages/' ) ) 
     59         
     60            crit = crit.criteria; 
     61 
     62            if( !crit.properties.context.folder.indexOf( 'local_messages/' ) ) 
    6063            { 
    61                 var msgs = expresso_local_messages.get_local_range_msgs( crit.criteria.properties.context.folder.replace(dots, "/").replace("local_messages/", ""), 
     64                var msgs = expresso_local_messages.get_local_range_msgs( crit.properties.context.folder.replace(dots, "/").replace("local_messages/", ""), 
    6265                                                                          crit.offset + 1, crit.limit, "SORTARRIVAL", crit.orderDesc, "ALL", 1, 1 ); 
    6366 
     
    7578                } 
    7679 
    77                 return( {"rows": msgs,  
    78                           "records": msgs.length, 
    79                           "page": crit.page,  
    80                           "total": Math.ceil( msgs.num_msgs / crit.limit )} ); 
     80                data = msgs; 
    8181            } 
    8282 
    83             return( data ); 
     83            return( {"rows": data,  
     84                      "records": data.num_msgs || current_count, 
     85                      "page": crit.offset / crit.limit + 1,  
     86                      "total": Math.ceil( data.num_msgs || current_count / crit.limit )} ); 
    8487      }, 
    8588      criteria: function( crit ){ 
    8689 
    87             return { criteria: { properties: {context:{folder: current_folder || 'INBOX'}}, offset: crit.rows * ( crit.page - 1 ), limit: crit.rows, orderDesc: crit.sord == "desc" } }; 
     90            return { criteria: { properties: {context:{folder: current_folder || 'INBOX'}}, offset: crit.rows * ( crit.page - 1 ), limit: crit.rows, orderDesc: crit.sord == "desc", currentCount: current_count } }; 
    8891 
    8992      } 
Note: See TracChangeset for help on using the changeset viewer.