Skip to content

Commit 8ee369e

Browse files
committed
#257 disable contentUpdated event in show only map
1 parent 4135cb4 commit 8ee369e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

app/helpers/gtt_map_helper.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ module GttMapHelper
55
def map_form_field(form, map, field: :geojson, bounds: nil, edit_mode: nil, upload: true, rotation: 0)
66
safe_join [
77
form.hidden_field(field, id: 'geom'),
8-
map_tag(map: map, bounds: bounds, edit: edit_mode, upload: upload, rotation: rotation)
8+
map_tag(map: map, bounds: bounds, edit: edit_mode, upload: upload, rotation: rotation, show: false)
99
]
1010
end
1111

1212
def map_tag(map: nil, layers: map&.layers,
1313
geom: map.json, bounds: map.bounds,
1414
edit: nil, popup: nil, upload: true,
15-
collapsed: false, rotation: map&.rotation)
15+
collapsed: false, rotation: map&.rotation,
16+
show: true)
1617

1718
data = {
1819
geom: geom.is_a?(String) ? geom : geom.to_json,
@@ -61,11 +62,13 @@ def map_tag(map: nil, layers: map&.layers,
6162
};
6263
observer.observe(document.body, config);
6364
}
64-
document.addEventListener('contentUpdated', function(){
65-
var target = document.getElementById('#{uid}');
66-
window.createGttClient(target);
67-
contentObserver();
68-
}, { once: true });
65+
if (!#{show}) {
66+
document.addEventListener('contentUpdated', function(){
67+
var target = document.getElementById('#{uid}');
68+
window.createGttClient(target);
69+
contentObserver();
70+
}, { once: true });
71+
}
6972
document.addEventListener('DOMContentLoaded', function(){
7073
var target = document.getElementById('#{uid}');
7174
window.createGttClient(target);

0 commit comments

Comments
 (0)