Changeset 37780 for main/trunk/greenstone3/web/interfaces/default
- Timestamp:
- 2023-06-18T15:02:23+12:00 (12 months ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default/js
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts.js
r36027 r37780 115 115 } 116 116 117 var gsmap_store = {}; 118 var gps_metadata_name = "GPS.mapOverlay"; 119 120 // Called by documentedit_scripts_util.js when saving and rebuilding. 121 // This function should return all the doc sections' map overlay data so that 122 // setArchivesMetadata can be called for each and the entire collection rebuilt with the changes 123 function getDocMapsEditDataForSaving(collName) { 124 var map_editors_array = Object.values(gsmap_store); 125 var modifiedMaps = []; // the array that is the return value: an array of only all the modified maps 126 127 128 for(var i = 0; i < map_editors_array.length; i++) { 129 var map_editor = map_editors_array[i]; 130 var oldMapData = map_editor.savedOverlays; // stringified JSON shape 131 var newMapData = JSON.stringify(ShapesUtil.overlayToJSON(map_editor.overlays)); // stringified JSON shape too 132 133 // We only consider a map editor's map data to have been modified in the following cases: 134 // - if oldMapData is null, new mapData should not be empty array 135 // - OR oldMapData had some value and it's not the same as newMapData 136 if(!oldMapData && newMapData !== "[]" || oldMapData && oldMapData !== newMapData) { 137 var nodeID = map_editors_array[i].id; 138 //console.log("old vs new mapdata for nodeID " + nodeID); 139 //console.log("OLD: " + oldMapData); 140 //console.log("NEW: " + newMapData); 141 142 modifiedMaps.push({ 143 collection: collName, 144 docID: nodeID, 145 name:gps_metadata_name, 146 metapos: 0, 147 value:newMapData 148 }); 149 150 //map_editor.savedOverlays = newMapData; 151 // Saving the new overlay values as the old ones, for the state after saving and rebuilding is done, 152 // now happens after all setArchivesMeta)_ calls have succeeded, 153 // which is just at the start of sendBuildRequest() in documentedit_scripts_util.js::saveAndRebuild() 154 } 155 156 } 157 158 return modifiedMaps; 159 } 160 161 162 function addEditMapGPSLink(cell) { 163 cell = $(cell); 164 var id = cell.attr("id").substring(6); 165 //console.log(id); 166 var mapGPScontainer = gs.jqGet("map-and-controls-" + id); 167 var row = cell.parent(); 168 var newCell = $("<td>", { 169 "style": "font-size:0.7em; padding:0px 10px", 170 "class": "editMapGPSButton" 171 }); 172 var linkSpan = $("<span>", { 173 "class": "ui-state-default ui-corner-all", 174 "style": "padding: 2px; float:left;" 175 }); 176 177 var linkLabel = $("<span>" + gs.text.de.edit_map_gps + "</span>"); 178 var linkIcon = $("<span>", { 179 "class": "ui-icon ui-icon-folder-collapsed" 180 }); 181 newCell.linkIcon = linkIcon; 182 newCell.linkLabel = linkLabel; 183 184 var uList = $("<ul>", { 185 "style": "outline: 0 none; margin:0px; padding:0px;" 186 }); 187 var labelItem = $("<li>", { 188 "style": "float:left; list-style:none outside none;" 189 }); 190 var iconItem = $("<li>", { 191 "style": "float:left; list-style:none outside none;" 192 }); 193 194 uList.append(iconItem); 195 uList.append(labelItem); 196 labelItem.append(linkLabel); 197 iconItem.append(linkIcon); 198 199 var mapEditor = new MapEditor(id); 200 gsmap_store["map-" + id] = mapEditor; 201 202 var newLink = $("<a>", { 203 "href": "javascript:;" 204 }); 205 newLink.on("click", function () { 206 //console.log(" Show/Hide Map Editor "); 207 var clicked_mapEditor = gsmap_store["map-" + id]; 208 209 if (clicked_mapEditor.map == null) { 210 clicked_mapEditor.initMapEditorControls(); 211 clicked_mapEditor.initMapEditor(); 212 } 213 if (mapGPScontainer.css("display") == "none") { 214 linkLabel.html(gs.text.de.hide_map_gps); 215 linkIcon.attr("class", "ui-icon ui-icon-folder-open"); 216 mapGPScontainer.css("display", "block"); 217 } else { 218 linkLabel.html(gs.text.de.edit_map_gps); 219 linkIcon.attr("class", "ui-icon ui-icon-folder-collapsed"); 220 mapGPScontainer.css("display", "none"); 221 222 } 223 }); 224 225 newLink.append(uList); 226 linkSpan.append(newLink); 227 newCell.append(linkSpan); 228 row.append(newCell); 229 230 mapGPScontainer.css("display", "none"); 231 232 } 117 233 118 234 119 function setEditingFeaturesVisible(visible) { … … 278 163 } 279 164 280 function readyPageForEditing( mapGPSEditingAllowed) {165 function readyPageForEditing() { 281 166 282 167 if ($("#metadataSetList").length) { … … 355 240 for (var i = 0; i < titleDivs.length; i++) { 356 241 addEditMetadataLink(titleDivs[i]); 357 if (mapGPSEditingAllowed) { 242 243 if (gs.variables.isMapGPSEditingAllowed = "1") { 358 244 addEditMapGPSLink(titleDivs[i]); 359 245 }
Note:
See TracChangeset
for help on using the changeset viewer.