From 824f9977499a92cd4c707e9a9644f397ff395944 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 1 Jul 2021 10:43:10 +0200 Subject: [PATCH] node: repos: fix add repo validator 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 --- src/node/APTRepositories.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js index baca834..050132d 100644 --- a/src/node/APTRepositories.js +++ b/src/node/APTRepositories.js @@ -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) { -- 2.39.2