Changeset 32871

Show
Ignore:
Timestamp:
07.03.2019 19:20:59 (2 weeks ago)
Author:
ak19
Message:

Need to reset init states to current states AFTER setArchivesMetadata has been successfully performed on all the list of changed metadata. Implementing Dr Bainbridge's suggested way of doing this, which is to set the entire editableInitStates array to editableCurrentStates. And similarly for ALL map editors: set ALL map-editors' savedOverlays to their current overlays. Tested for metadata and map-editors. Incremental change. Still need to add errorResponseFunction handling into setMeta methods before we can use that.

Location:
main/trunk/greenstone3/web/interfaces/default/js
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts.js

    r32854 r32871  
    154154            // But for now, we're doing this here *because* this is the procedure with regular metadata (works out changes, 
    155155            // then saves those changes as initStates BEFORE saveAndRebuild is called)           
    156             map_editor.savedOverlays = newMapData; 
     156            //map_editor.savedOverlays = newMapData; // happens after all setArchivesMeta calls have succeeded, just at the start of sendBuildRequest() in documentedit_scripts_util.js::saveAndRebuild() 
    157157        } 
    158158         
  • main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts_util.js

    r32857 r32871  
    345345    var sendBuildRequest = function() 
    346346    { 
     347        console.log("Replacing init states with current states"); 
     348        // Clean changes. We're here because setting meta for all meta changes was successful, so 
     349        // - update doc's metadata initial states to current: 
     350        editableInitStates = editableLastStates;         
     351        // - update doc's map editors' initial states to current: 
     352        var map_editors_array = Object.values(gsmap_store); 
     353        for(var i = 0; i < map_editors_array.length; i++) { 
     354            var map_editor = map_editors_array[i]; 
     355            map_editor.savedOverlays = JSON.stringify(ShapesUtil.overlayToJSON(map_editor.overlays)); 
     356        } 
     357         
     358         
    347359        var request = "["; 
    348360        for(var i = 0; i < _transactions.length; i++) 
     
    442454   
    443455  //Clean changes 
    444   editableInitStates = editableLastStates; 
     456  ////editableInitStates = editableLastStates; // moved into processChangesLoop(): when all changes have successfully been processed. 
     457        // Alternative is to set initState per metadata in changes array: after each setArchiveMetadata call for each individual meta change. 
     458        // But since our setMeta calls are always synchronous, happening in sequence, if one setArchivesMeta() call fails 
     459        // we'll not attempt subsequent ones or coll building at the end. 
    445460   
    446461    for(var i = 0; i < changes.length; i++)