Ignore:
Timestamp:
2019-03-02T19:41:08+13:00 (5 years ago)
Author:
ak19
Message:

Save and rebuild works with map, but as with save shortcut key on map editor, the metamode ends up as accumulate still in doc.xml. Some other issues (not related to saveandrebuild) need fixing up like a popup about unsaved changes appearing even after save and rebuild has finished and possibly more things).

File:
1 edited

Legend:

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

    r32837 r32838  
    117117
    118118var gsmap_store = {};
     119var gps_metadata_name = "GPS.mapOverlay";
    119120
    120121// Called by documentedit_scripts_util.js when saving and rebuilding.
    121122// This function should return all the doc sections' map overlay data so that
    122123// setArchivesMetadata can be called for each and the entire collection rebuilt with the changes
    123 function getDocMapsEditDataForSaving() {
     124function getDocMapsEditDataForSaving(collName) {
    124125    var map_editors_array = Object.values(gsmap_store);
    125126    var modifiedMaps = []; // the array that is the return value: an array of only all the modified maps
    126127   
    127     // get collection name
    128     var coll = gs.cgiParams.c;
    129 
    130128   
    131129    for(var i = 0; i < map_editors_array.length; i++) {
    132130        var map_editor = map_editors_array[i];
    133         var oldMapData = map_editor.savedOverlays;
    134         var newMapData = JSON.stringify(ShapesUtil.overlayToJSON(map_editor.overlays));
     131        var oldMapData = map_editor.savedOverlays; // stringified JSON shape
     132        var newMapData = JSON.stringify(ShapesUtil.overlayToJSON(map_editor.overlays)); // stringified JSON shape too
    135133       
    136         if(oldMapData !== newMapData) {
     134        // We only consider a map editor's map data to have been modified in the following cases:
     135        // - if oldMapData is null, new mapData should not be empty array
     136        // - OR oldMapData had some value and it's not the same as newMapData
     137        if(!oldMapData && newMapData !== "[]" /*|| oldMapData && oldMapData !== newMapData*/) {
     138            var nodeID = map_editors_array[i].id;
     139            console.log("old vs new mapdata for nodeID " + nodeID);
     140            console.log(oldMapData);
     141            console.log(newMapData);
    137142           
    138             var nodeID = map_editors_array[i].id;
    139             var val = map_editors_array[i].overlays;
    140143            modifiedMaps.push({
    141                 collection: coll,
     144                collection: collName,
    142145                docID: nodeID,
    143                 name:"GSP.mapOverlay",
    144                 pos: 0,
     146                name:gps_metadata_name,
     147                metapos: 0,
    145148                value:newMapData               
    146149            });
Note: See TracChangeset for help on using the changeset viewer.