]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
node: repos: fix add repo validator
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 1 Jul 2021 08:43:10 +0000 (10:43 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 1 Jul 2021 08:43:12 +0000 (10:43 +0200)
isValid is a boolean not a callback, so won't really work and just
set the state once.

Use the `validator` and first call into the parents helper, then do
our logic and return a string  with an explanation in the expected
invalid case.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/node/APTRepositories.js

index baca834e3d0f168279202224f3b5cba3d276e73d..050132dfae6b29f21331351e131cdde258e18bd4 100644 (file)
@@ -60,21 +60,24 @@ Ext.define('Proxmox.window.APTRepositoryAdd', {
            name: 'handle',
            allowBlank: false,
            comboItems: me.repoInfo.map(info => [info.handle, info.name]),
-           isValid: function() {
-               const handle = this.value;
+           validator: function(renderedValue) {
+               let handle = this.value;
+               // we cannot use this.callParent in instantiations
+               let valid = Proxmox.form.KVComboBox.prototype.validator.call(this, renderedValue);
 
-               if (!handle) {
+               if (!valid || !handle) {
                    return false;
                }
 
                const info = me.repoInfo.find(elem => elem.handle === handle);
-
                if (!info) {
                    return false;
                }
 
-               // not yet configured
-               return info.status === undefined || info.status === null;
+               if (!info.status) {
+                   return Ext.String.format(gettext('{0} is already configured'), renderedValue);
+               }
+               return valid;
            },
            listeners: {
                change: function(f, value) {