Skip to content

Commit 14542c2

Browse files
authored
Merge pull request #170 from gtt-project/ftr/material-icons
Material icons
2 parents 0c0e3ad + 013e1ca commit 14542c2

17 files changed

+2577
-715
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"homepage": "https://github.com/gtt-project/redmine_gtt#readme",
2222
"dependencies": {
2323
"@juggle/resize-observer": "^3.3.1",
24-
"font-awesome": "^4.7.0",
24+
"@material-design-icons/font": "^0.11.8",
2525
"geojson": "^0.5.0",
2626
"ol": "^6.14.1",
2727
"ol-ext": "^3.2.22"

src/components/gtt-client.ts

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ export class GttClient {
212212
this.layerArray.forEach( (l:Layer) => {
213213
if( l.get("baseLayer") ) {
214214
this.map.addLayer(l)
215-
}
216-
}
215+
}
216+
}
217217
)
218218

219219
var containsOverlay = false;
@@ -222,8 +222,8 @@ export class GttClient {
222222
if( !l.get("baseLayer") ) {
223223
this.map.addLayer(l)
224224
containsOverlay = true
225-
}
226-
}
225+
}
226+
}
227227
)
228228
}
229229

@@ -312,7 +312,7 @@ export class GttClient {
312312

313313
// Control button
314314
const maximizeCtrl = new Button({
315-
html: '<i class="gtt-icon-maximize" ></i>',
315+
html: '<i class="material-icons" >zoom_out_map</i>',
316316
title: "Maximize",
317317
handleClick: () => {
318318
this.zoomToExtent(true);
@@ -398,7 +398,7 @@ export class GttClient {
398398
else {
399399
this.map.addControl(new LayerPopup())
400400
}
401-
401+
402402

403403
// Because Redmine filter functions are applied later, the Window onload
404404
// event provides a workaround to have filters loaded before executing
@@ -461,8 +461,21 @@ export class GttClient {
461461
this.updateForm([evt.feature], true)
462462
})
463463

464+
// Material design icon
465+
let mdi = 'place'
466+
467+
switch (type.toLowerCase()) {
468+
case 'linestring':
469+
mdi = 'polyline'
470+
break;
471+
472+
case 'polygon':
473+
mdi = 'format_shapes'
474+
break;
475+
}
476+
464477
const control = new Toggle({
465-
html: `<i class="gtt-icon-${type.toLowerCase()}" ></i>`,
478+
html: `<i class="material-icons" >${mdi}</i>`,
466479
title: type,
467480
interaction: draw,
468481
active: (idx === 0)
@@ -473,7 +486,7 @@ export class GttClient {
473486
// Upload button
474487
if (this.contents.upload === "true") {
475488
editbar.addControl(new Button({
476-
html: '<i class="gtt-icon-book" ></i>',
489+
html: '<i class="material-icons">file_upload</i>',
477490
title: 'Upload GeoJSON',
478491
handleClick: () => {
479492
const data = prompt("Please paste a GeoJSON geometry here")
@@ -496,7 +509,7 @@ export class GttClient {
496509
setPopover() {
497510
const popup = new Popup({
498511
popupClass: 'default',
499-
closeBox: true,
512+
closeBox: false,
500513
onclose: () => {},
501514
positioning: 'auto',
502515
anim: true
@@ -522,7 +535,7 @@ export class GttClient {
522535
const url = popup_contents.href.replace(/\[(.+?)\]/g, feature.get('id'))
523536
content.push(`<a href="${url}">Edit</a>`)
524537

525-
popup.show(feature.getGeometry().getFirstCoordinate(), content.join(' '))
538+
popup.show(feature.getGeometry().getFirstCoordinate(), content.join('') as any)
526539
})
527540

528541
select.getFeatures().on(['remove'], _ => {
@@ -682,7 +695,7 @@ export class GttClient {
682695
}
683696

684697
getSymbol(feature: Feature<Geometry>) {
685-
let symbol = 'mcr-icon-write'
698+
let symbol = 'home'
686699

687700
const plugin_settings = JSON.parse(this.defaults.pluginSettings)
688701
const issue_tracker = document.querySelector('#issue_tracker_id') as HTMLInputElement
@@ -905,13 +918,13 @@ export class GttClient {
905918
this.geolocations.push(geolocation)
906919

907920
geolocation.on('change', (evt) => {
908-
console.log({
909-
accuracy: geolocation.getAccuracy(),
910-
altitude: geolocation.getAltitude(),
911-
altitudeAccuracy: geolocation.getAltitudeAccuracy(),
912-
heading: geolocation.getHeading(),
913-
speed: geolocation.getSpeed()
914-
})
921+
// console.log({
922+
// accuracy: geolocation.getAccuracy(),
923+
// altitude: geolocation.getAltitude(),
924+
// altitudeAccuracy: geolocation.getAltitudeAccuracy(),
925+
// heading: geolocation.getHeading(),
926+
// speed: geolocation.getSpeed()
927+
// })
915928
})
916929
geolocation.on('error', (error) => {
917930
// TBD
@@ -957,7 +970,7 @@ export class GttClient {
957970

958971
// Control button
959972
const geolocationCtrl = new Toggle({
960-
html: '<i class="gtt-icon-compass" ></i>',
973+
html: '<i class="material-icons">my_location</i>',
961974
title: "Geolocation",
962975
active: false,
963976
onToggle: (active: boolean) => {
@@ -1146,7 +1159,7 @@ export class GttClient {
11461159

11471160
// Control button
11481161
const geocodingCtrl = new Toggle({
1149-
html: '<i class="gtt-icon-search" ></i>',
1162+
html: '<i class="material-icons">manage_search</i>',
11501163
title: "Geocoding",
11511164
className: "ctl-geocoding",
11521165
onToggle: (active: boolean) => {
@@ -1232,7 +1245,7 @@ export class GttClient {
12321245
return feature.getGeometry().getType() === "Point"
12331246
})
12341247
if (pointIndex >= 0) {
1235-
console.log("Reloading Features layer")
1248+
// console.log("Reloading Features layer")
12361249
layer.changed()
12371250
}
12381251
}

src/components/gtt-setting.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ export const gtt_setting = ():void => {
1414
for (let i in glyph) {
1515
if (glyph[i].font == font) {
1616
const selected = selectedValue === i
17-
element.append(new Option(i, i, selected, selected))
17+
const words = i.split('_')
18+
const text = words.map((word) => {
19+
return word[0].toUpperCase() + word.substring(1)
20+
}).join(" ")
21+
element.append(new Option(text, i, selected, selected))
1822
if (selected) {
19-
element.nextElementSibling.className = "fa " + i
23+
element.nextElementSibling.className = "material-icons"
24+
element.nextElementSibling.textContent = i
2025
}
2126
}
2227
}
@@ -26,7 +31,8 @@ export const gtt_setting = ():void => {
2631
element.addEventListener('change', (ev) => {
2732
const currentTarget = ev.currentTarget as HTMLSelectElement
2833
const trackerId = currentTarget.id
29-
document.querySelector(`#icon_${trackerId}`).className = "fa " + currentTarget.value
34+
document.querySelector(`#icon_${trackerId}`).className = "material-icons"
35+
document.querySelector(`#icon_${trackerId}`).textContent = currentTarget.value
3036
})
3137
})
3238
}

0 commit comments

Comments
 (0)