From: "Dominic Jäger" <d.jaeger@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 4/4] ui: remote edit: Change asterisk color
Date: Tue, 19 Jan 2021 12:09:15 +0100 [thread overview]
Message-ID: <20210119110915.18864-5-d.jaeger@proxmox.com> (raw)
In-Reply-To: <20210119110915.18864-1-d.jaeger@proxmox.com>
The asterisk symbolises required input. Therefore,
1. Color it red
2. Display an error quicktip on it
if and only if the error is about missing input.
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
---
If somebody has a shorter idea, I'm all ears.
www/Utils.js | 15 +++++++++++++++
www/window/RemoteEdit.js | 22 +++++++++++++++++++---
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/www/Utils.js b/www/Utils.js
index 14b58a25..1af8cddc 100644
--- a/www/Utils.js
+++ b/www/Utils.js
@@ -11,6 +11,21 @@ Ext.define('PBS.Utils', {
dataStorePrefix: 'DataStore-',
+ getAsteriskTemplate: function() {
+ return new Ext.XTemplate(`<span id={id}-asterisk> *</span>`);
+ },
+
+ changeAsteriskColor: function(asterisk, error) {
+ let color = error.match(/required/) ? "red" : undefined;
+ let qtip = error.match(/required/) ? error : undefined;
+ asterisk.set({
+ 'data-errorqtip': qtip,
+ style: {
+ color: color,
+ },
+ });
+ },
+
cryptmap: [
'none',
'mixed',
diff --git a/www/window/RemoteEdit.js b/www/window/RemoteEdit.js
index 7fb3a952..ce9a49b4 100644
--- a/www/window/RemoteEdit.js
+++ b/www/window/RemoteEdit.js
@@ -35,7 +35,7 @@ Ext.define('PBS.window.RemoteEdit', {
fieldLabel: gettext('Remote'),
renderer: Ext.htmlEncode,
allowBlank: false,
- afterLabelTextTpl: " *",
+ afterLabelTextTpl: PBS.Utils.getAsteriskTemplate(),
minLength: 4,
cbind: {
editable: '{isCreate}',
@@ -45,11 +45,17 @@ Ext.define('PBS.window.RemoteEdit', {
tag: 'div',
'data-qtip': gettext('A unique name to identify this remote.'),
},
+ listeners: {
+ errorchange: function(labelable, error) {
+ let asterisk = Ext.get(`${labelable.ownerCt.id}-asterisk`);
+ PBS.Utils.changeAsteriskColor(asterisk, error);
+ },
+ },
},
{
xtype: 'proxmoxtextfield',
allowBlank: false,
- afterLabelTextTpl: " *",
+ afterLabelTextTpl: PBS.Utils.getAsteriskTemplate(),
name: 'hostport',
submitValue: false,
vtype: 'HostPort',
@@ -82,6 +88,10 @@ Ext.define('PBS.window.RemoteEdit', {
field.up('inputpanel').down('field[name=host]').setValue(host);
field.up('inputpanel').down('field[name=port]').setValue(port);
},
+ errorchange: function(labelable, error) {
+ let asterisk = Ext.get(`${labelable.id}-asterisk`);
+ PBS.Utils.changeAsteriskColor(asterisk, error);
+ },
},
},
{
@@ -103,7 +113,7 @@ Ext.define('PBS.window.RemoteEdit', {
{
xtype: 'proxmoxtextfield',
allowBlank: false,
- afterLabelTextTpl: " *",
+ afterLabelTextTpl: PBS.Utils.getAsteriskTemplate(),
name: 'auth-id',
fieldLabel: gettext('Auth ID'),
msgTarget: 'side',
@@ -111,6 +121,12 @@ Ext.define('PBS.window.RemoteEdit', {
tag: 'div',
'data-qtip': gettext('For example: admin@pbs.'),
},
+ listeners: {
+ errorchange: function(labelable, error) {
+ let asterisk = Ext.get(`${labelable.id}-asterisk`);
+ PBS.Utils.changeAsteriskColor(asterisk, error);
+ },
+ },
},
{
xtype: 'textfield',
--
2.20.1
next prev parent reply other threads:[~2021-01-19 11:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 11:09 [pbs-devel] [PATCH proxmox-backup 0/4] remote edit: error message ideas Dominic Jäger
2021-01-19 11:09 ` [pbs-devel] [PATCH proxmox-backup 1/4] ui: remote edit: Add tooltips Dominic Jäger
2021-01-19 11:09 ` [pbs-devel] [PATCH proxmox-backup 2/4] ui: remote edit: Add asterisks Dominic Jäger
2021-01-19 11:09 ` [pbs-devel] [PATCH proxmox-backup 3/4] ui: remote edit: Error as symbol to the right Dominic Jäger
2021-01-19 11:09 ` Dominic Jäger [this message]
2021-01-26 10:34 ` [pbs-devel] [PATCH proxmox-backup 0/4] remote edit: error message ideas Dominik Csapak
2021-01-27 10:55 ` Dominic Jäger
2021-01-27 13:57 ` Dominik Csapak
2021-01-27 14:39 ` 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=20210119110915.18864-5-d.jaeger@proxmox.com \
--to=d.jaeger@proxmox.com \
--cc=pbs-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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal