Skip to content

Commit 616cc3f

Browse files
committed
Sets value trough input field
Signed-off-by: Daniel Kastl <[email protected]>
1 parent 64f2a8a commit 616cc3f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

app/views/projects/settings/_gtt.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</p>
1515
<p>
1616
<%= content_tag(:label, l(:gtt_map_rotate_label)) %>
17-
<%= number_field_tag('gtt_configuration[map_rotation]', @project.map_rotation, min: 0, max: 359, size: 10, readonly: true ) %>
17+
<%= number_field_tag('gtt_configuration[map_rotation]', @project.map_rotation, min: 0, max: 359, size: 10 ) %>
1818
<br /><em><%= t :gtt_map_rotate_info_html %></em>
1919
</p>
2020
</div>

src/components/gtt-client.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,19 +335,20 @@ export class GttClient {
335335
this.toolbar.addControl(maximizeCtrl)
336336

337337
// Map rotation
338-
const rotation_field = document.querySelector('#gtt_configuration_map_rotation') as HTMLElement
338+
const rotation_field = document.querySelector('#gtt_configuration_map_rotation') as HTMLInputElement
339339
if (rotation_field !== null) {
340340
this.map.getView().on('change:rotation', (evt) => {
341-
rotation_field.setAttribute(
342-
'value',
343-
String(Math.round(radiansToDegrees(evt.target.getRotation())))
344-
)
341+
rotation_field.value = String(Math.round(radiansToDegrees(evt.target.getRotation())))
345342
})
346343

347-
// TODO: remove readonly flag from field and update map on input
348-
// rotation_field.addEventListener("oninput", (evt) => {
349-
// console.log(evt)
350-
// })
344+
rotation_field.addEventListener("input", (evt) => {
345+
const { target } = evt;
346+
if (!(target instanceof HTMLInputElement)) {
347+
return;
348+
}
349+
const value = target.value;
350+
this.map.getView().setRotation(degreesToRadians(parseInt(value)))
351+
})
351352
}
352353

353354
if (this.contents.edit) {

0 commit comments

Comments
 (0)