all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH widget-toolkit 1/2] location edit: make coordinates pastable
@ 2026-05-26 12:37 Dominik Csapak
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2026-05-26 12:37 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-26 14:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 12:37 [PATCH widget-toolkit 1/2] location edit: make coordinates pastable Dominik Csapak
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

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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal