spatial coverage delete option and point/box toggle
1. The option to delete the spatial coverage  should be available whenever there is saved spatial coverage. But that seems to be not the case sometimes. In the screenshot below we have the option to delete temporal coverage but the same option is not available for spatial coverage.

![image](https://github.com/hydroshare/hydroshare/assets/2523434/01b4a298-16ab-4873-ba4e-f611a78dcd62)

2. If the resource already has box type spatial coverage, and I select the point coverage, the box does not get cleared from the map. 
![image](https://github.com/hydroshare/hydroshare/assets/2523434/7446bdc0-cb17-47c1-ab66-36568a4ed01f)

_Originally posted by @pkdash in https://github.com/hydroshare/hydroshare/issues/5109#issuecomment-1642200976_
            
diff --git a/hs_core/views/__init__.py b/hs_core/views/__init__.py
index f76f63ba5..387e50b71 100755
--- a/hs_core/views/__init__.py
+++ b/hs_core/views/__init__.py
@@ -354,6 +354,9 @@ def add_files_to_resource(request, shortkey, *args, **kwargs):
         msg = {"validation_error": str(ex)}
         return JsonResponse(msg, status=500)
 
+    aggregations_pre = [aggr for aggr in resource.logical_files]
+    aggr_count_pre = len(aggregations_pre)
+
     try:
         hydroshare.utils.resource_file_add_process(
             resource=resource,
@@ -369,6 +372,9 @@ def add_files_to_resource(request, shortkey, *args, **kwargs):
         msg = {"validation_error": str(ex)}
         return JsonResponse(msg, status=500)
 
+    aggregations_post = [aggr for aggr in resource.logical_files]
+    aggr_count_post = len(aggregations_post)
+
     res_public_status = "public" if resource.raccess.public else "not public"
     res_discoverable_status = (
         "discoverable" if resource.raccess.discoverable else "not discoverable"
@@ -397,6 +403,7 @@ def add_files_to_resource(request, shortkey, *args, **kwargs):
     response_data = {
         "res_public_status": res_public_status,
         "res_discoverable_status": res_discoverable_status,
+        "number_new_aggregations": aggr_count_post - aggr_count_pre,
         "metadata_status": metadata_status,
         "show_meta_status": show_meta_status,
     }
@@ -662,6 +669,7 @@ def add_metadata_element(request, shortkey, element_name, *args, **kwargs):
             else:
                 ajax_response_data = {
                     "status": "success",
+                    "element_type": getattr(element, 'type', None),
                     "element_name": element_name,
                     "spatial_coverage": get_coverage_data_dict(res),
                     "temporal_coverage": get_coverage_data_dict(res, "temporal"),
diff --git a/hs_core/views/resource_folder_hierarchy.py b/hs_core/views/resource_folder_hierarchy.py
index f5768102b..636d85a26 100755
--- a/hs_core/views/resource_folder_hierarchy.py
+++ b/hs_core/views/resource_folder_hierarchy.py
@@ -20,7 +20,7 @@ from hs_core.views import utils as view_utils
 
 from hs_core.views.utils import authorize, ACTION_TO_AUTHORIZE, zip_folder, unzip_file, \
     create_folder, remove_folder, move_or_rename_file_or_folder, move_to_folder, \
-    rename_file_or_folder, get_coverage_data_dict, irods_path_is_directory, \
+    rename_file_or_folder, irods_path_is_directory, \
     add_reference_url_to_resource, edit_reference_url_in_resource, zip_by_aggregation_file
 
 from hs_file_types.models import FileSetLogicalFile, ModelInstanceLogicalFile, ModelProgramLogicalFile
@@ -219,10 +219,6 @@ def data_store_structure(request):
                      'aggregations': aggregations,
                      'can_be_public': resource.can_be_public_or_discoverable}
 
-    if resource.resource_type == "CompositeResource":
-        return_object['spatial_coverage'] = get_coverage_data_dict(resource)
-        return_object['temporal_coverage'] = get_coverage_data_dict(resource,
-                                                                    coverage_type='temporal')
     return HttpResponse(
         json.dumps(return_object),
         content_type="application/json"
diff --git a/theme/static/js/hs_file_browser.js b/theme/static/js/hs_file_browser.js
index 197bd3363..ee17300f8 100644
--- a/theme/static/js/hs_file_browser.js
+++ b/theme/static/js/hs_file_browser.js
@@ -1778,7 +1778,7 @@ function warnExternalContent(shortId) {
 function onUploadSuccess(file, response) {
     // uploaded files can affect metadata in composite resource.
     // Use the json data returned from backend to update UI
-    if (RES_TYPE === 'Resource') {
+    if (RES_TYPE === 'Resource' && response.number_new_aggregations > 0) {
         updateResourceUI();
     }
     showCompletedMessage(response);
diff --git a/theme/static/js/resourceLandingAjax.js b/theme/static/js/resourceLandingAjax.js
index 91676e845..7c058d463 100755
--- a/theme/static/js/resourceLandingAjax.js
+++ b/theme/static/js/resourceLandingAjax.js
@@ -196,7 +196,8 @@ function metadata_update_ajax_submit(form_id){
                 if ((json_response.element_name.toLowerCase() === 'site' && resourceType === 'Time Series') ||
                     ((json_response.element_name.toLowerCase() === 'coverage' ||
                     json_response.element_name.toLowerCase() === 'site') && resourceType === 'Resource')){
-                    if (json_response.hasOwnProperty('temporal_coverage')){
+                    const element_type = json_response.element_type?.toLowerCase() || '';
+                    if (element_type === 'period' && json_response.hasOwnProperty('temporal_coverage')){
                         var temporalCoverage = json_response.temporal_coverage;
                         updateResourceTemporalCoverage(temporalCoverage);
                         // show/hide delete option for resource temporal coverage
@@ -210,7 +211,7 @@ function metadata_update_ajax_submit(form_id){
                         }
                     }
 
-                    if (json_response.hasOwnProperty('spatial_coverage')) {
+                    if (['box', 'point'].includes(element_type) && json_response.hasOwnProperty('spatial_coverage')) {
                         var spatialCoverage = json_response.spatial_coverage;
                         updateResourceSpatialCoverage(spatialCoverage);
                         if(resourceType === 'Resource' && json_response.has_logical_spatial_coverage) {
@@ -867,16 +868,6 @@ function get_irods_folder_struct_ajax_submit(res_id, store_path) {
             $(".selection-menu").hide();
             $("#flag-uploading").remove();
             $("#fb-files-container, #fb-files-container").css("cursor", "default");
-
-            if (mode === "edit" && result.hasOwnProperty('spatial_coverage')){
-                var spatialCoverage = result.spatial_coverage;
-                updateResourceSpatialCoverage(spatialCoverage);
-            }
-
-            if (mode == "edit" && result.hasOwnProperty('temporal_coverage')){
-                var temporalCoverage = result.temporal_coverage;
-                updateResourceTemporalCoverage(temporalCoverage);
-            }
         },
         error: function(xhr, errmsg, err){
             $(".selection-menu").hide();
['hs_core/views/resource_folder_hierarchy.py', 'hs_core/views/__init__.py', 'theme/static/js/hs_file_browser.js', 'theme/static/js/resourceLandingAjax.js']