Skip to content

Commit

Permalink
#257 disable contentUpdated event in show only map
Browse files Browse the repository at this point in the history
  • Loading branch information
smellman committed Oct 9, 2023
1 parent 4135cb4 commit 8ee369e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions app/helpers/gtt_map_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ module GttMapHelper
def map_form_field(form, map, field: :geojson, bounds: nil, edit_mode: nil, upload: true, rotation: 0)
safe_join [
form.hidden_field(field, id: 'geom'),
map_tag(map: map, bounds: bounds, edit: edit_mode, upload: upload, rotation: rotation)
map_tag(map: map, bounds: bounds, edit: edit_mode, upload: upload, rotation: rotation, show: false)
]
end

def map_tag(map: nil, layers: map&.layers,
geom: map.json, bounds: map.bounds,
edit: nil, popup: nil, upload: true,
collapsed: false, rotation: map&.rotation)
collapsed: false, rotation: map&.rotation,
show: true)

data = {
geom: geom.is_a?(String) ? geom : geom.to_json,
Expand Down Expand Up @@ -61,11 +62,13 @@ def map_tag(map: nil, layers: map&.layers,
};
observer.observe(document.body, config);
}
document.addEventListener('contentUpdated', function(){
var target = document.getElementById('#{uid}');
window.createGttClient(target);
contentObserver();
}, { once: true });
if (!#{show}) {
document.addEventListener('contentUpdated', function(){
var target = document.getElementById('#{uid}');
window.createGttClient(target);
contentObserver();
}, { once: true });
}
document.addEventListener('DOMContentLoaded', function(){
var target = document.getElementById('#{uid}');
window.createGttClient(target);
Expand Down

0 comments on commit 8ee369e

Please sign in to comment.