Changeset 941

Show
Ignore:
Timestamp:
08/27/08 13:18:12 (3 months ago)
Author:
elemoine
Message:

make the offline manager compatible with the new Open Layers? and Map Fish? code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/editing/FeatureOfflineManager.js

    r930 r941  
    1919 
    2020/** 
    21  * @requires OpenLayers/Protocol/SQL.js 
     21 * @requires OpenLayers/Protocol/SQL/Gears.js 
    2222 * @requires core/Offline.js 
    2323 */ 
     
    8383    /** 
    8484     * Method: download 
     85     * For a given layer, read the data from the remote server and write it 
     86     * in the offline storage. 
    8587     * 
    8688     * Parameters: 
     
    129131    /** 
    130132     * Method: upload 
     133     * For a given layer, read the data from the offline storage and write 
     134     * it to the remove server.  
    131135     * 
    132136     * Parameters: 
     
    150154        var protocol = this.switchLayerProtocol(id); 
    151155 
    152         var count = 0; 
    153156        function cleanup() { 
    154             if (count <= 0) { 
    155                 this.switchCurrentLayerProtocol(id, protocol); 
    156                 mapfish.Offline.transitionTaskDone(taskId); 
    157             } 
    158         } 
     157            this.switchCurrentLayerProtocol(id, protocol); 
     158            mapfish.Offline.transitionTaskDone(taskId); 
     159        } 
     160 
    159161        function callback(resp) { 
    160162            if (resp.code != OpenLayers.Protocol.Response.SUCCESS) { 
     
    162164                    'failed to commit features to server'); 
    163165            } 
    164             count--; 
    165             cleanup.call(this); 
    166         } 
    167  
    168         count = protocol.commit(resp.features, { 
     166        } 
     167 
     168        // write data to remote server 
     169        resp = protocol.commit(resp.features, { 
    169170            'create': {'callback': callback, 'scope': this}, 
    170171            'update': {'callback': callback, 'scope': this}, 
    171             'delete': {'callback': callback, 'scope': this} 
    172         }); 
    173  
    174         cleanup.call(this); 
     172            'delete': {'callback': callback, 'scope': this}, 
     173            'callback': cleanup, 
     174            'scope': this 
     175        }); 
     176 
     177        if (resp.length <= 0) { 
     178            cleanup.call(this); 
     179        } 
    175180    }, 
    176181 
     
    225230        return new OpenLayers.Filter.Spatial({ 
    226231            type: OpenLayers.Filter.Spatial.BBOX, 
    227             value: new OpenLayers.Geometry.Rectangle( 
    228                 bounds.left, 
    229                 bounds.bottom, 
    230                 bounds.right - bounds.left, 
    231                 bounds.top - bounds.bottom 
    232             ) 
     232            value: bounds 
    233233        }); 
    234234    }, 
     
    266266        return mapfish.Protocol.SQL.factory({ 
    267267            tableName: id, 
    268             options: {'delete': {'dontDelete': true}
     268            options: {'dontDelete': true
    269269        }); 
    270270    }