From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 1113E1FF146 for ; Tue, 26 May 2026 14:37:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 65EF61DA65; Tue, 26 May 2026 14:37:20 +0200 (CEST) From: Dominik Csapak 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 Message-ID: <20260526123716.2912640-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.050 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: NFBNOXOQJPW34A4BH5KDHF5R54AOI6J6 X-Message-ID-Hash: NFBNOXOQJPW34A4BH5KDHF5R54AOI6J6 X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: Dominik Csapak --- 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