Hi!
I'm struggling with hiding a group in the node-red dashboard. I want to hide the Finish Cocktail group if there are less than 2 ingredients in the table. I debugged the node, it sends the command to hide, but nothing happens. This is the code that decides if the group should be hidden or shown. It works but the group is always shown.
Any ideas?
var ingcnt = 0; // ingredient count
var nc = global.get("nc"); // cocktail object
if(nc == null)msg.payload = {group:{hide:["Finish_Cocktail"]}}; // hide group if the object doesn't exist
else
{
for(var i = 0;i<8;i++) // count ingredients
{
if(nc.id[i] !='')ingcnt++;
}
if(ingcnt > 1) // show Finish Cocktail group if there are at least 2 ingredients
{
msg.payload = {group:{show:["Finish_Cocktail"]}};
}
else
{
msg.payload = {group:{hide:["Finish_Cocktail"]}}; // if there are less then 2 ingredients hide the group
}
}
return msg;