From 3ef0d18fcb16931a0c93d91ae6fbf8edda09ecc9 Mon Sep 17 00:00:00 2001 From: Aijana Schumann Date: Wed, 7 Oct 2020 16:36:59 +0200 Subject: ConfigApp bugfix Fix interface list is not visible Issue-ID: CCSDK-2880 Signed-off-by: Aijana Schumann Change-Id: I090a298a925ada52eda603c8a24cf6d577a7b5e6 --- .../configurationApp/src/actions/deviceActions.ts | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'sdnr/wt/odlux/apps/configurationApp/src/actions') diff --git a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts index 790d2515c..83134fc92 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts @@ -182,13 +182,25 @@ const resolveViewDescription = (defaultNS: string | null, vPath: string, view: V // check if-feature | when | and resolve all references. view = { ...view }; view.elements = Object.keys(view.elements).reduce<{ [name: string]: ViewElement }>((acc, cur) => { - const elm = view.elements[cur]; + const resolveHistory : ViewElement[] = []; + let elm = view.elements[cur]; const key = defaultNS && cur.replace(new RegExp(`^${defaultNS}:`, "i"),"") || cur; - if (isViewElementReference(elm)) { - acc[key] = { ...(elm.ref(vPath) || elm), id: key }; - } else { - acc[key] = { ...elm, id: key }; - } + while (isViewElementReference(elm)) { + const result = (elm.ref(vPath)); + if (result) { + const [referencedElement, referencedPath] = result; + if (resolveHistory.some(hist => hist === referencedElement)) { + console.error(`Circle reference found at: ${vPath}`, resolveHistory); + break; + } + elm = referencedElement; + vPath = referencedPath; + resolveHistory.push(elm); + } + } + + acc[key] = { ...elm, id: key }; + return acc; }, {}); return view; -- cgit 1.2.3-korg