From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH widget-toolkit 1/2] location edit: make coordinates pastable
Date: Tue, 26 May 2026 14:37:08 +0200 [thread overview]
Message-ID: <20260526123716.2912640-1-d.csapak@proxmox.com> (raw)
in either the latitude or longitude field, and add a hint as such.
This drastically improves the usability when getting coordinates from
online map tools.
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/window/LocationEdit.js | 44 ++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/src/window/LocationEdit.js b/src/window/LocationEdit.js
index 4042086..bb92ff2 100644
--- a/src/window/LocationEdit.js
+++ b/src/window/LocationEdit.js
@@ -6,6 +6,39 @@ Ext.define('Proxmox.window.LocationEdit', {
autoLoad: true,
+ // make a bit wider for the hint field
+ width: 400,
+
+ controller: {
+ xclass: 'Ext.app.ViewController',
+
+ isValidCoordinate: function (lat, long) {
+ if (!Ext.isNumber(lat) || !Ext.isNumber(long)) {
+ return false;
+ }
+ return lat >= -90 && lat <= 90 && long >= -180 && long <= 180;
+ },
+
+ onPaste: function (_field, event) {
+ let me = this;
+ let data = event.getClipboardData();
+ if (Ext.isString(data)) {
+ let [lat, long] = data.split(',').map(Number);
+ if (me.isValidCoordinate(lat, long)) {
+ me.lookup('latitude').setValue(lat);
+ me.lookup('longitude').setValue(long);
+ event.preventDefault();
+ }
+ }
+ },
+
+ control: {
+ numberfield: {
+ paste: 'onPaste',
+ },
+ },
+ },
+
items: [
{
xtype: 'inputpanel',
@@ -41,17 +74,28 @@ Ext.define('Proxmox.window.LocationEdit', {
xtype: 'numberfield',
minimum: -90.0,
maximum: 90.0,
+ reference: 'latitude',
name: 'latitude',
decimalPrecision: 6,
fieldLabel: gettext('Latitude'),
+ enableKeyEvents: true,
},
{
xtype: 'numberfield',
minimum: -180.0,
maximum: 180.0,
+ reference: 'longitude',
name: 'longitude',
decimalPrecision: 6,
fieldLabel: gettext('Longitude'),
+ enableKeyEvents: true,
+ },
+ {
+ xtype: 'displayfield',
+ value: gettext(
+ 'You can paste text in format "Latitude, Longitude" in either field.',
+ ),
+ userCls: 'pmx-hint',
},
],
},
--
2.47.3
next reply other threads:[~2026-05-26 12:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 12:37 Dominik Csapak [this message]
2026-05-26 12:37 ` [PATCH widget-toolkit 2/2] location edit: add OpenStreetMap link also in the edit window Dominik Csapak
2026-05-26 14:29 ` [PATCH widget-toolkit 1/2] location edit: make coordinates pastable Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260526123716.2912640-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.