From 21e4a946cd24b8a03ea577352f0271ebf7669ffa Mon Sep 17 00:00:00 2001 From: Michael DÜrre Date: Thu, 8 Apr 2021 07:27:18 +0200 Subject: update odlux for notification change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update due new notification protocol Issue-ID: CCSDK-3253 Signed-off-by: Michael DÜrre Change-Id: Iad65459fdc18603cd1ddbd97bb2211308744bd8b --- .../apps/configurationApp/src/yang/yangParser.ts | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'sdnr/wt/odlux/apps/configurationApp/src/yang') diff --git a/sdnr/wt/odlux/apps/configurationApp/src/yang/yangParser.ts b/sdnr/wt/odlux/apps/configurationApp/src/yang/yangParser.ts index c5cb8fb4c..2d38976d5 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/yang/yangParser.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/yang/yangParser.ts @@ -278,6 +278,7 @@ export class YangParser { name: "root", language: "en-US", canEdit: false, + config: true, parentView: "0", title: "root", elements: {}, @@ -544,6 +545,28 @@ export class YangParser { console.warn(error.message); } }); + + // resolve readOnly + const resolveReadOnly = (view: ViewSpecification, parentConfig: boolean) => { + + // update view config + view.config = view.config && parentConfig; + + Object.keys(view.elements).forEach((key) => { + const elm = view.elements[key]; + + // update element config + elm.config = elm.config && view.config; + + // update all sub-elements of objects + if (elm.uiType === "object") { + resolveReadOnly(this.views[+elm.viewId], elm.config); + } + + }) + } + + const dump = resolveReadOnly(this.views[0], true); }; private _nextId = 1; @@ -686,7 +709,7 @@ export class YangParser { module: context.name || module.name || '', uiType: "object", viewId: currentView.id, - config: config + config: currentView.config, }); acc.push(currentView, ...subViews); return acc; @@ -717,7 +740,7 @@ export class YangParser { uiType: "object", viewId: currentView.id, key: key, - config: elmConfig + config: elmConfig && currentView.config, }); acc.push(currentView, ...subViews); return acc; @@ -876,6 +899,7 @@ export class YangParser { title: statement.arg != null ? statement.arg : undefined, language: "en-us", canEdit: false, + config: config, ifFeature: ifFeature, when: whenCondition, elements: elements.reduce<{ [name: string]: ViewElement }>((acc, cur) => { @@ -921,7 +945,7 @@ export class YangParser { const elm = groupingViewSpec.elements[key]; // a useRef on root level need a namespace viewSpec.elements[parentId === 0 ? `${module.name}:${key}` : key] = { - ...groupingViewSpec.elements[key], + ...elm, when: elm.when ? `(${groupingViewSpec.when}) and (${elm.when})` : groupingViewSpec.when, ifFeature: elm.ifFeature ? `(${groupingViewSpec.ifFeature}) and (${elm.ifFeature})` : groupingViewSpec.ifFeature, }; -- cgit 1.2.3-korg