BNA8/.resources/85fdad206285471676eaa3e381865808c0ffe32e3af15491dbff603fa05420e6

42 lines
1.1 KiB
Plaintext

def handleTagHighlight(view, currentValue):
tag_priority = currentValue.value
# --- CASE 1: Remove all highlights by applying CLEAR class ---
if not tag_priority or str(tag_priority).upper() == "CLEAR":
for child in view.rootContainer.getChildren()[0].getChildren():
try:
child.props.style.classes = ""
except:
pass
return False
parts = str(tag_priority).split("||")
tag = parts[0]
splitedTag = tag.split("/")
deviceName = splitedTag[-1]
components = view.rootContainer.getChildren()[0].getChildren()
priority = parts[1]
foundMatch = False
# clear all highlights and apply new one when found
for child in components:
params = child.props.get("params", {})
tagProps = params.get("tagProps", {})
tagsList = list(tagProps)
if len(tagsList) == 0:
continue
child.props.style.classes = ""
tagPath = tagsList[0]
# system.perspective.print(tagPath)
if tag == tagPath:
child.props.style["classes"] = "Highlight/Pulse-" + priority
foundMatch = True
return foundMatch