From 30f977db40ddef513f91ba7dbc2b6227296c92d4 Mon Sep 17 00:00:00 2001 From: Nuno Aguiar Date: Thu, 10 Aug 2023 15:25:44 +0100 Subject: [PATCH] nInput_EndPoints: support for attrTemplate using chUrls/chPorts --- config/objects/nInput_EndPoints.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/config/objects/nInput_EndPoints.js b/config/objects/nInput_EndPoints.js index c603afb..9817a46 100644 --- a/config/objects/nInput_EndPoints.js +++ b/config/objects/nInput_EndPoints.js @@ -107,7 +107,9 @@ nInput_EndPoints.prototype.input = function(scope, args) { if (isDef(this.params.chUrls)) { $ch(this.params.chUrls).forEach((k, v) => { var attr; - if (isUnDef(this.params.attribute)) { + // For legacy compatibility + if (isDef(this.params.attribute)) this.params.attrTemplate = this.params.attribute + if (isUnDef(this.params.attrTemplate)) { if (isDef(k.key)) attr = k.key; if (isString(k)) attr = k; if (isDef(k.attribute)) attr = k.attribute; @@ -115,11 +117,12 @@ nInput_EndPoints.prototype.input = function(scope, args) { if (isDef(k.attribute)) attr = k.attribute else - attr = this.params.attribute + attr = this.params.attrTemplate } if (isDef(attr)) { - ret[templify(attr, k)] = this.testURL(v); + if (isUnDef(ret[templify(attr, k)])) ret[templify(attr, k)] = [] + ret[templify(attr, k)].push(this.testURL(v)) } }); } @@ -134,7 +137,9 @@ nInput_EndPoints.prototype.input = function(scope, args) { if (isDef(this.params.chPorts)) { $ch(this.params.chPorts).forEach((k, v) => { var attr; - if (isUnDef(this.params.attribute)) { + // For legacy compatibility + if (isDef(this.params.attribute)) this.params.attrTemplate = this.params.attribute + if (isUnDef(this.params.attrTemplate)) { if (isDef(k.key)) attr = k.key; if (isString(k)) attr = k; if (isDef(k.attribute)) attr = k.attribute; @@ -142,13 +147,14 @@ nInput_EndPoints.prototype.input = function(scope, args) { if (isDef(k.attribute)) attr = k.attribute else - attr = this.params.attribute + attr = this.params.attrTemplate } if (isDef(attr)) { - ret[templify(attr, k)] = this.testPort(v); + if (isUnDef(ret[templify(attr, k)])) ret[templify(attr, k)] = [] + ret[templify(attr, k)].push(this.testPort(v)) } - }); + }) } return ret;