From 7edae911dcc0d4e2a28b96d8a363431b2d0f68a7 Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Thu, 1 Apr 2021 18:00:00 +0000 Subject: [PATCH] Select parts of trackname in export dialog for easier overwriting Users might want to assign custom tracknames, which requires deleting the default name either entirely or parts of it. By pre-selecting parts of the trackname, users can start typing right away after opening the dialog. `Ctrl+A` to select everything is still possible, but keeping the distance in the filename by default comes in handy, e.g. when using a file manager not displaying the track length. NB: Might need adaptation once trackname validation becomes less strict, i.e. currently "(" and "->" as specified in the message catalog are replaced with ' - ' by the validator before being inserted into the dialog. Test Plan: - Open "Export" dialog ("Location - Other Location - 2km") - Open "Export" dialog for roundtrip ("Location - 1km") - In both cases the complete trackname except for the distance information (including separator) should be selected. - No unwanted behaviour even if Nominatim is slow or down. --- js/control/Export.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/control/Export.js b/js/control/Export.js index 3740c8b..e66d87a 100644 --- a/js/control/Export.js +++ b/js/control/Export.js @@ -71,6 +71,10 @@ BR.Export = L.Class.extend({ } }, + _selectTrackname: function () { + trackname.setSelectionRange(0, trackname.value.lastIndexOf(' - ')); + }, + _generateTrackname: function () { var trackname = this.trackname; this._getCityAtPosition( @@ -103,6 +107,8 @@ BR.Export = L.Class.extend({ trackname.value = trackname.value.replace(/[>)]/g, '').replace(/ \(/g, ' - '); this._validationMessage(); } + + this._selectTrackname(); }, this) ); }, this)