Skip to content

Commit f01e226

Browse files
authored
Merge pull request #48 from gtt-project/main
Merge main to develop
2 parents a746f18 + 5a7b9b6 commit f01e226

File tree

6 files changed

+104
-77
lines changed

6 files changed

+104
-77
lines changed

app/views/issues/index/_map.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<% if @project and @project.module_enabled?(:gtt) %>
22

33
<fieldset id="location" class="collapsible collapsed">
4-
<legend><%= l(:field_location) %></legend>
4+
<legend class="icon icon-collapsed"><%= l(:field_location) %></legend>
55

66
<%= map_tag map: @project.map, geom: (Issue.array_to_geojson(@issues, include_properties: { only: %i(id subject tracker_id status_id) }) if @issues), popup: { href: '/issues/[id]' } %>
77
</fieldset>

assets/javascripts/app.js

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ var App = (function ($, publ) {
8888
);
8989
}
9090

91+
// Fix FireFox unloaded font issue
92+
publ.reloadFontSymbol();
93+
9194
// TODO: this is only necessary because setting the initial form value
9295
// through the template causes encoding problems
9396
publ.updateForm(features);
@@ -183,6 +186,10 @@ var App = (function ($, publ) {
183186
})
184187
})
185188
});
189+
// Fix empty map issue
190+
map.once('postrender', function(event) {
191+
publ.zoomToExtent(true);
192+
});
186193

187194
// Add Toolbar
188195
toolbar = new ol.control.Bar();
@@ -196,7 +203,7 @@ var App = (function ($, publ) {
196203

197204
// Control button
198205
var maximizeCtrl = new ol.control.Button({
199-
html: '<i class="icon-maximize" ></i>',
206+
html: '<i class="gtt-icon-maximize" ></i>',
200207
title: "Maximize",
201208
handleClick: function () {
202209
publ.zoomToExtent(true);
@@ -338,7 +345,7 @@ var App = (function ($, publ) {
338345
}
339346
return color;
340347
};
341-
348+
342349
publ.getFontColor = function (feature) {
343350
color = "#FFFFFF"
344351
return color;
@@ -602,7 +609,7 @@ var App = (function ($, publ) {
602609

603610
// Control button
604611
var geolocationCtrl = new ol.control.Toggle({
605-
html: '<i class="icon-compass" ></i>',
612+
html: '<i class="gtt-icon-compass" ></i>',
606613
title: "Geolocation",
607614
active: false,
608615
onToggle: function (active) {
@@ -717,7 +724,7 @@ var App = (function ($, publ) {
717724
var value = getObjectPathValue(item, defaults.geocoder.place_search_result_value_path);
718725
if (display && value != null) {
719726
$("div#places").append('<input type="radio" name="places" value="' + value + '">'
720-
+ display
727+
+ display
721728
+'<br>')
722729
}
723730
})
@@ -739,7 +746,7 @@ var App = (function ($, publ) {
739746

740747
// Control button
741748
var geocodingCtrl = new ol.control.Toggle({
742-
html: '<i class="icon-info" ></i>',
749+
html: '<i class="gtt-icon-info" ></i>',
743750
title: "Geocoding",
744751
className: "ctl-geocoding",
745752
onToggle: function (active) {
@@ -821,7 +828,7 @@ var App = (function ($, publ) {
821828
});
822829

823830
var control = new ol.control.Toggle({
824-
html: '<i class="icon-' + type.toLowerCase() + '" ></i>',
831+
html: '<i class="gtt-icon-' + type.toLowerCase() + '" ></i>',
825832
title: type,
826833
interaction: draw
827834
});
@@ -830,7 +837,7 @@ var App = (function ($, publ) {
830837

831838
// Upload button
832839
editbar.addControl(new ol.control.Button({
833-
html: '<i class="icon-book" ></i>',
840+
html: '<i class="gtt-icon-book" ></i>',
834841
title: 'Upload GeoJSON',
835842
handleClick: function () {
836843
var data = prompt("Please paste a GeoJSON geometry here");
@@ -939,7 +946,7 @@ var App = (function ($, publ) {
939946
if (match && match.length === 2) {
940947
districtInput.val(match[1]);
941948
foundDistrict = true;
942-
}
949+
}
943950
}
944951
}
945952
}
@@ -1005,6 +1012,38 @@ var App = (function ($, publ) {
10051012
return url;
10061013
};
10071014

1015+
publ.reloadFontSymbol = function () {
1016+
if ('fonts' in document) {
1017+
document.fonts.addEventListener('loadingdone', function(e) {
1018+
var loaded = false;
1019+
e.fontfaces.forEach(function(f) {
1020+
if (f.family === '"mcr-icons"' || f.family === '"fontmaki"') {
1021+
loaded = true;
1022+
}
1023+
});
1024+
if (loaded) {
1025+
maps.forEach(function(m) {
1026+
var layers = m.getLayers();
1027+
layers.forEach(function(layer) {
1028+
if (layer.type === "VECTOR" &&
1029+
layer.getKeys().indexOf("title") >= 0 &&
1030+
layer.get("title") === "Features") {
1031+
var features = layer.getSource().getFeatures();
1032+
if (features.length >= 0) {
1033+
var geom = features[0].getGeometry();
1034+
if (geom.getType() == "Point") {
1035+
console.log("Reloading Features layer");
1036+
layer.changed();
1037+
}
1038+
}
1039+
}
1040+
});
1041+
});
1042+
}
1043+
});
1044+
}
1045+
};
1046+
10081047
function getCookie(cname) {
10091048
var name = cname + "=";
10101049
var ca = document.cookie.split(';');
@@ -1023,6 +1062,7 @@ var App = (function ($, publ) {
10231062
function toggleAndLoadMap(el) {
10241063
var fieldset = $(el).parents('fieldset').first();
10251064
fieldset.toggleClass('collapsed');
1065+
fieldset.children('legend').toggleClass('icon-expended icon-collapsed');
10261066
fieldset.children('div').toggle();
10271067
maps.forEach(function (m) {
10281068
m.updateSize();
@@ -1057,8 +1097,8 @@ var App = (function ($, publ) {
10571097
};
10581098

10591099
path = stringToPath(path);
1060-
var current = obj;
1061-
for (var i = 0; i < path.length; i++) {
1100+
var current = obj;
1101+
for (var i = 0; i < path.length; i++) {
10621102
if (!current[path[i]]) {
10631103
return def;
10641104
}

assets/stylesheets/fonts.css

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
11
/* Generated by Glyphter (http://www.glyphter.com) on Thu Jan 19 2017*/
22
@font-face {
33
font-family: 'Redmine';
4-
src: url('../fonts/Redmine.eot');
5-
src: url('../fonts/Redmine.eot?#iefix') format('embedded-opentype'),
6-
url('../fonts/Redmine.woff') format('woff'),
7-
url('../fonts/Redmine.ttf') format('truetype'),
8-
url('../fonts/Redmine.svg#Redmine') format('svg');
4+
src: url('../fonts/Redmine.woff') format('woff'),
5+
url('../fonts/Redmine.ttf') format('truetype');
96
font-weight: normal;
107
font-style: normal;
118
}
12-
[class*='icon-']:before{
9+
[class^='gtt-icon-']:before{
1310
display: inline-block;
14-
font-family: 'Redmine';
15-
font-style: normal;
16-
font-weight: normal;
17-
line-height: 1;
18-
-webkit-font-smoothing: antialiased;
19-
-moz-osx-font-smoothing: grayscale
11+
font-family: 'Redmine';
12+
font-style: normal;
13+
font-weight: normal;
14+
line-height: 1em;
15+
font-variant: normal;
16+
text-transform: none;
17+
-webkit-font-smoothing: antialiased;
18+
-moz-osx-font-smoothing: grayscale;
2019
}
21-
.icon-point:before{content:'\0041';}
22-
.icon-linestring:before{content:'\0042';}
23-
.icon-polygon:before{content:'\0043';}
24-
.icon-shutter:before{content:'\0044';}
25-
.icon-camera:before{content:'\0045';}
26-
.icon-book:before{content:'\0046';}
27-
.icon-download:before{content:'\0047';}
28-
.icon-upload:before{content:'\0048';}
29-
.icon-home:before{content:'\0049';}
30-
.icon-layer:before{content:'\004a';}
31-
.icon-info:before{content:'\004b';}
32-
.icon-compass:before{content:'\004c';}
33-
.icon-move:before{content:'\004d';}
34-
.icon-maximize:before{content:'\004e';}
35-
.icon-trash:before{content:'\004f';}
36-
.icon-target:before{content:'\0050';}
37-
.icon-modify:before{content:'\0051';}
20+
21+
.gtt-icon-point:before{content:'\0041';}
22+
.gtt-icon-linestring:before{content:'\0042';}
23+
.gtt-icon-polygon:before{content:'\0043';}
24+
.gtt-icon-shutter:before{content:'\0044';}
25+
.gtt-icon-camera:before{content:'\0045';}
26+
.gtt-icon-book:before{content:'\0046';}
27+
.gtt-icon-download:before{content:'\0047';}
28+
.gtt-icon-upload:before{content:'\0048';}
29+
.gtt-icon-home:before{content:'\0049';}
30+
.gtt-icon-layer:before{content:'\004a';}
31+
.gtt-icon-info:before{content:'\004b';}
32+
.gtt-icon-compass:before{content:'\004c';}
33+
.gtt-icon-move:before{content:'\004d';}
34+
.gtt-icon-maximize:before{content:'\004e';}
35+
.gtt-icon-trash:before{content:'\004f';}
36+
.gtt-icon-target:before{content:'\0050';}
37+
.gtt-icon-modify:before{content:'\0051';}
3838

3939
@font-face {
4040
font-family: "mcr-icons";
41-
src: url("../fonts/mcr-icons.eot?b88144ffa3049f78bfa19b5159b89f09?#iefix") format("embedded-opentype"),
42-
url("../fonts/mcr-icons.woff2?b88144ffa3049f78bfa19b5159b89f09") format("woff2"),
43-
url("../fonts/mcr-icons.woff?b88144ffa3049f78bfa19b5159b89f09") format("woff"),
44-
url("../fonts/mcr-icons.ttf?b88144ffa3049f78bfa19b5159b89f09") format("truetype"),
45-
url("../fonts/mcr-icons.svg?b88144ffa3049f78bfa19b5159b89f09#mcr-icons") format("svg");
41+
src: url("../fonts/mcr-icons.woff2") format("woff2"),
42+
url("../fonts/mcr-icons.woff") format("woff"),
43+
url("../fonts/mcr-icons.ttf") format("truetype");
4644
}
4745

4846
[class^="mcr-icon-"]:before, i[class*=" mcr-icon-"]:before {
@@ -51,7 +49,7 @@ url("../fonts/mcr-icons.svg?b88144ffa3049f78bfa19b5159b89f09#mcr-icons") format(
5149
font-weight: normal !important;
5250
font-variant: normal;
5351
text-transform: none;
54-
line-height: 1;
52+
line-height: 1em;
5553
-webkit-font-smoothing: antialiased;
5654
-moz-osx-font-smoothing: grayscale;
5755
}
@@ -103,11 +101,8 @@ url("../fonts/mcr-icons.svg?b88144ffa3049f78bfa19b5159b89f09#mcr-icons") format(
103101
*/
104102
@font-face {
105103
font-family: 'fontmaki';
106-
src: url('../fonts/fontmaki.eot?66752613');
107-
src: url('../fonts/fontmaki.eot?66752613#iefix') format('embedded-opentype'),
108-
url('../fonts/fontmaki.woff?66752613') format('woff'),
109-
url('../fonts/fontmaki.ttf?66752613') format('truetype'),
110-
url('../fonts/fontmaki.svg?66752613#fontmaki') format('svg');
104+
src: url('../fonts/fontmaki.woff') format('woff'),
105+
url('../fonts/fontmaki.ttf') format('truetype');
111106
font-weight: normal;
112107
font-style: normal;
113108
}
@@ -121,42 +116,42 @@ url("../fonts/mcr-icons.svg?b88144ffa3049f78bfa19b5159b89f09#mcr-icons") format(
121116
}
122117
}
123118
*/
124-
119+
125120
[class^="maki-"]:before, [class*=" maki-"]:before {
126121
font-family: "fontmaki";
127122
font-style: normal;
128123
font-weight: normal;
129-
speak: none;
130-
124+
/* speak: none; */
125+
131126
display: inline-block;
132127
text-decoration: inherit;
133128
width: 1em;
134129
margin-right: .2em;
135130
text-align: center;
136131
/* opacity: .8; */
137-
132+
138133
/* For safety - reset parent styles, that can break glyph codes*/
139134
font-variant: normal;
140135
text-transform: none;
141-
136+
142137
/* fix buttons height, for twitter bootstrap */
143138
line-height: 1em;
144-
139+
145140
/* Animation center compensation - margins should be symmetric */
146141
/* remove if not needed */
147142
margin-left: .2em;
148-
143+
149144
/* you can be more comfortable with increased icons size */
150145
/* font-size: 120%; */
151-
146+
152147
/* Font smoothing. That was taken from TWBS */
153148
-webkit-font-smoothing: antialiased;
154149
-moz-osx-font-smoothing: grayscale;
155-
150+
156151
/* Uncomment for 3D effect */
157152
/* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
158153
}
159-
154+
160155
.maki-bicycle:before { content: '\e800'; } /* '' */
161156
.maki-building:before { content: '\e801'; } /* '' */
162157
.maki-bus:before { content: '\e802'; } /* '' */

init.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
author_url 'https://github.com/georepublic'
77
url 'https://github.com/gtt-project/redmine_gtt'
88
description 'Adds location-based task management and maps'
9-
version '2.0.2'
9+
version '2.1.0'
1010

11-
requires_redmine :version_or_higher => '3.4.0'
11+
requires_redmine :version_or_higher => '4.0.0'
1212

1313
project_module :gtt do
1414
permission :manage_gtt_settings, {

lib/redmine_gtt/hooks/view_layouts_base_html_head_hook.rb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,16 @@ class ViewLayoutsBaseHtmlHeadHook < Redmine::Hook::ViewListener
66

77
def view_layouts_base_html_head(context={})
88
tags = [];
9-
tags << tag(:link, :rel => "preload", :as => "font", :type => "application/vnd.ms-fontobject",
10-
:href => "/plugin_assets/redmine_gtt/fonts/mcr-icons.eot?75e7536f7f839b0f143e30ad8d0da92d?#iefi", :crossorigin => "anonymous" )
119
tags << tag(:link, :rel => "preload", :as => "font", :type => "font/woff2",
12-
:href => "/plugin_assets/redmine_gtt/fonts/mcr-icons.woff2?75e7536f7f839b0f143e30ad8d0da92d", :crossorigin => "anonymous" )
10+
:href => "/plugin_assets/redmine_gtt/fonts/mcr-icons.woff2", :crossorigin => "anonymous" )
1311
tags << tag(:link, :rel => "preload", :as => "font", :type => "font/woff",
14-
:href => "/plugin_assets/redmine_gtt/fonts/mcr-icons.woff?75e7536f7f839b0f143e30ad8d0da92d", :crossorigin => "anonymous" )
12+
:href => "/plugin_assets/redmine_gtt/fonts/mcr-icons.woff", :crossorigin => "anonymous" )
1513
tags << tag(:link, :rel => "preload", :as => "font", :type => "font/ttf",
16-
:href => "/plugin_assets/redmine_gtt/fonts/mcr-icons.ttf?75e7536f7f839b0f143e30ad8d0da92d", :crossorigin => "anonymous" )
17-
tags << tag(:link, :rel => "preload", :as => "font", :type => "image/svg+xml",
18-
:href => "/plugin_assets/redmine_gtt/fonts/mcr-icons.svg?75e7536f7f839b0f143e30ad8d0da92d#mcr-icons", :crossorigin => "anonymous" )
19-
tags << tag(:link, :rel => "preload", :as => "font", :type => "application/vnd.ms-fontobject",
20-
:href => "/plugin_assets/redmine_gtt/fonts/fontmaki.eot?66752613#iefix'", :crossorigin => "anonymous" )
14+
:href => "/plugin_assets/redmine_gtt/fonts/mcr-icons.ttf", :crossorigin => "anonymous" )
2115
tags << tag(:link, :rel => "preload", :as => "font", :type => "font/woff",
22-
:href => "/plugin_assets/redmine_gtt/fonts/fontmaki.woff?66752613", :crossorigin => "anonymous" )
16+
:href => "/plugin_assets/redmine_gtt/fonts/fontmaki.woff", :crossorigin => "anonymous" )
2317
tags << tag(:link, :rel => "preload", :as => "font", :type => "font/ttf",
24-
:href => "/plugin_assets/redmine_gtt/fonts/fontmaki.ttf?66752613", :crossorigin => "anonymous" )
25-
tags << tag(:link, :rel => "preload", :as => "font", :type => "image/svg+xml",
26-
:href => "/plugin_assets/redmine_gtt/fonts/fontmaki.svg?66752613#fontmaki", :crossorigin => "anonymous" )
18+
:href => "/plugin_assets/redmine_gtt/fonts/fontmaki.ttf", :crossorigin => "anonymous" )
2719

2820
tags << stylesheet_link_tag("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css")
2921
tags << stylesheet_link_tag("fonts.css", :plugin => "redmine_gtt", :media => "all")

lib/redmine_gtt/patches/geojson_attribute.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def geojson
7272
# doing a single select for each issue
7373
def geodata_for_print
7474
if row = self.class.where(id: id).where.not(geom: nil).
75-
pluck(Arel.sql("ST_AsGeoJson(ST_Transform(geom, 3857)) as geojson, ST_Transform(ST_Centroid(geom), 3857) as center")).
75+
pluck(Arel.sql("ST_AsGeoJson(ST_Transform(geom, 3857), 9, 0) as geojson, ST_Transform(ST_Centroid(geom), 3857) as center")).
7676
first
7777
json, center = *row
7878
{

0 commit comments

Comments
 (0)