Skip to content

Commit 952a096

Browse files
authored
Merge pull request #56 from smellman/feature/fix-50
fixes #50, #51, #52
2 parents 7cbb0ea + 49d953e commit 952a096

File tree

3 files changed

+20
-66
lines changed

3 files changed

+20
-66
lines changed

app/helpers/gtt_map_helper.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ def map_tag(map: nil, layers: map&.layers,
3333
safe_join [
3434
content_tag(:div, "", data: data, id: uid, class: 'ol-map'),
3535
javascript_tag("
36-
$(document).ready(function(){
37-
/*
38-
App.init({
39-
target: $('##{uid}')[0]
40-
});
41-
*/
36+
document.addEventListener('DOMContentLoaded', function(){
4237
var target = document.getElementById('#{uid}');
4338
window.createGttClient(target);
4439
});

src/components/gtt-client.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ export class GttClient {
193193
this.vector.set('displayInLayerSwitcher', false)
194194
this.layerArray.push(this.vector)
195195
this.map.addLayer(this.vector)
196-
console.log(this.layerArray)
197196

198197
// Render project boundary if bounds are available
199198
if (this.contents.bounds && this.contents.bounds !== null) {
@@ -298,21 +297,23 @@ export class GttClient {
298297
// Because Redmine filter functions are applied later, the Window onload
299298
// event provides a workaround to have filters loaded before executing
300299
// the following code
301-
if (document.querySelectorAll('tr#tr_bbox').length > 0) {
302-
this.filters.location = true
303-
}
304-
if (document.querySelectorAll('tr#tr_distance').length > 0) {
305-
this.filters.distance = true
306-
}
307-
const legend = document.querySelector('fieldset#location legend') as HTMLLegendElement
308-
if (legend) {
309-
legend.addEventListener('click', (evt) => {
310-
const element = evt.currentTarget as HTMLLegendElement
311-
this.toggleAndLoadMap(element)
312-
})
313-
}
314-
this.zoomToExtent()
315-
this.map.on('moveend', this.updateFilter.bind(this))
300+
window.addEventListener('load', () => {
301+
if (document.querySelectorAll('tr#tr_bbox').length > 0) {
302+
this.filters.location = true
303+
}
304+
if (document.querySelectorAll('tr#tr_distance').length > 0) {
305+
this.filters.distance = true
306+
}
307+
const legend = document.querySelector('fieldset#location legend') as HTMLLegendElement
308+
if (legend) {
309+
legend.addEventListener('click', (evt) => {
310+
const element = evt.currentTarget as HTMLLegendElement
311+
this.toggleAndLoadMap(element)
312+
})
313+
}
314+
this.zoomToExtent()
315+
this.map.on('moveend', this.updateFilter.bind(this))
316+
})
316317

317318
// To fix an issue with empty map after changing the tracker type
318319
document.querySelectorAll('select#issue_tracker_id').forEach(element => {
@@ -475,7 +476,7 @@ export class GttClient {
475476
const url = popup_contents.href.replace(/\[(.+?)\]/g, feature.get('id'))
476477
content.push(`<a href="${url}">Edit</a>`)
477478

478-
popup.show(getCenter(feature.getGeometry().getExtent()), content as any)
479+
popup.show(feature.getGeometry().getFirstCoordinate(), content as any)
479480
})
480481

481482
select.getFeatures().on(['remove'], _ => {
@@ -1179,6 +1180,7 @@ export class GttClient {
11791180
this.maps.forEach(function (m) {
11801181
m.updateSize()
11811182
})
1183+
this.zoomToExtent()
11821184
}
11831185

11841186

src/stylesheets/app.scss

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,6 @@
2424
background-color: rgba(40, 40, 40, 1);
2525
}
2626

27-
.ol-popup {
28-
position: absolute;
29-
background-color: white;
30-
-webkit-filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2));
31-
filter: drop-shadow(0 1px 4px rgba(0,0,0,0.2));
32-
padding: 7px;
33-
border-radius: 10px;
34-
border: 1px solid #cccccc;
35-
bottom: 12px;
36-
left: -50px;
37-
min-width: 120px;
38-
}
39-
.ol-popup:after, .ol-popup:before {
40-
top: 100%;
41-
border: solid transparent;
42-
content: " ";
43-
height: 0;
44-
width: 0;
45-
position: absolute;
46-
pointer-events: none;
47-
}
48-
.ol-popup:after {
49-
border-top-color: white;
50-
border-width: 10px;
51-
left: 48px;
52-
margin-left: -10px;
53-
}
54-
.ol-popup:before {
55-
border-top-color: #cccccc;
56-
border-width: 11px;
57-
left: 48px;
58-
margin-left: -11px;
59-
}
60-
.ol-popup-closer {
61-
text-decoration: none;
62-
position: absolute;
63-
top: 2px;
64-
right: 8px;
65-
}
66-
.ol-popup-closer:after {
67-
content: "";
68-
}
69-
7027
#admin-menu a.gtt {
7128
background-image: url(../images/map.png);
7229
}

0 commit comments

Comments
 (0)