What I'm trying to do is:
- Display a list (array of strings) of Downtime reasons.
- User (via dashboard) selects the list using a dropdown
- User selects which member to edit using a dropdown
- User can update a list member using a Text Input
- When a list is selected, a file is read and the payload is written to both the DisplayArray, and GlobalArray.
The above works fine. My problem is that my working/display array, and the original are getting updated immediately so the highlighting doesn't work. Only works if I update 1 manually with an inject etc.
-
When the user updates a member, it should only update the DisplayArray so the member is highlighted yellow due to not matching.
-
After a Save and Load, they should match and background is white. I took away updating the original on Save trying to troubleshoot. This issue has eaten about as much time as I should have used on the project.
I'm not sure if I posted my flow correctly:
[
{
"id": "77e990dfb4b955d1",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "3f6beba68d91d549",
"type": "inject",
"z": "77e990dfb4b955d1",
"name": "d",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Display_MT01_Reasons[6]",
"payloadType": "flow",
"x": 470,
"y": 740,
"wires": [
[
"87e96ed2a74185e1"
]
]
},
{
"id": "87e96ed2a74185e1",
"type": "debug",
"z": "77e990dfb4b955d1",
"name": "dbg",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 630,
"y": 760,
"wires": []
},
{
"id": "9053fd2f71c148fc",
"type": "ui_button",
"z": "77e990dfb4b955d1",
"name": "M1 RL Save",
"group": "67d8728aa87a6a03",
"order": 2,
"width": "2",
"height": "1",
"passthru": false,
"label": "Save List",
"tooltip": "Save",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "true",
"payloadType": "bool",
"topic": "1",
"topicType": "str",
"x": 310,
"y": 280,
"wires": [
[]
]
},
{
"id": "e737423ca3890202",
"type": "ui_text_input",
"z": "77e990dfb4b955d1",
"name": "M1 R In",
"label": "Enter Correction:",
"tooltip": "Correct Reason Option Selected",
"group": "67d8728aa87a6a03",
"order": 5,
"width": 0,
"height": 0,
"passthru": false,
"mode": "text",
"delay": "0",
"topic": "payload",
"sendOnBlur": false,
"className": "",
"topicType": "msg",
"x": 300,
"y": 520,
"wires": [
[
"8b73b0c1d41c47e1"
]
]
},
{
"id": "2cf82da86946880b",
"type": "ui_dropdown",
"z": "77e990dfb4b955d1",
"name": "M1 S Sel",
"label": "Select Step",
"tooltip": "Step Selection",
"place": "Select option",
"group": "67d8728aa87a6a03",
"order": 3,
"width": 0,
"height": 0,
"passthru": false,
"multiple": false,
"options": [
{
"label": "Step 1",
"value": 1,
"type": "num"
},
{
"label": "Step 2",
"value": 2,
"type": "num"
},
{
"label": "Step 3",
"value": 3,
"type": "num"
},
{
"label": "Step 4",
"value": 4,
"type": "num"
},
{
"label": "Step 5",
"value": 5,
"type": "num"
},
{
"label": "Step 6",
"value": 6,
"type": "num"
},
{
"label": "Step 7",
"value": 7,
"type": "num"
},
{
"label": "Step 8",
"value": 8,
"type": "num"
},
{
"label": "Step 9",
"value": 9,
"type": "num"
},
{
"label": "Step 10",
"value": 10,
"type": "num"
},
{
"label": "Step 11",
"value": 11,
"type": "num"
},
{
"label": "Step 12",
"value": 12,
"type": "num"
},
{
"label": "Step 13",
"value": 13,
"type": "num"
},
{
"label": "Step 14",
"value": 14,
"type": "num"
},
{
"label": "Step 15",
"value": 15,
"type": "num"
},
{
"label": "Step 16",
"value": 16,
"type": "num"
},
{
"label": "Step 17",
"value": 17,
"type": "num"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"x": 320,
"y": 360,
"wires": [
[
"7f0adfeeb992c957"
]
]
},
{
"id": "e4e97e37ba64c47b",
"type": "ui_dropdown",
"z": "77e990dfb4b955d1",
"name": "M1 R Sel",
"label": "Select Reason",
"tooltip": "Reason Selection",
"place": "Select option",
"group": "67d8728aa87a6a03",
"order": 4,
"width": 0,
"height": 0,
"passthru": false,
"multiple": false,
"options": [
{
"label": "Reason 1",
"value": 1,
"type": "num"
},
{
"label": "Reason 2",
"value": 2,
"type": "num"
},
{
"label": "Reason 3",
"value": 3,
"type": "num"
},
{
"label": "Reason 4",
"value": 4,
"type": "num"
},
{
"label": "Reason 5",
"value": 5,
"type": "num"
},
{
"label": "Reason 6",
"value": 6,
"type": "num"
},
{
"label": "Reason 7",
"value": 7,
"type": "num"
},
{
"label": "Reason 8",
"value": 8,
"type": "num"
},
{
"label": "Reason 9",
"value": 9,
"type": "num"
},
{
"label": "Reason 10",
"value": 10,
"type": "num"
},
{
"label": "Reason 11",
"value": 11,
"type": "num"
},
{
"label": "Reason 12",
"value": 12,
"type": "num"
},
{
"label": "Reason 13",
"value": 13,
"type": "num"
},
{
"label": "Reason 14",
"value": 14,
"type": "num"
},
{
"label": "Reason 15",
"value": 15,
"type": "num"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"x": 300,
"y": 440,
"wires": [
[
"ec1c6b760fae4603"
]
]
},
{
"id": "619208528a09010f",
"type": "function",
"z": "77e990dfb4b955d1",
"name": "obj to Disp",
"func": "let Step=global.get(\"MT01_ReasonsStep\");\nlet ReadArray = \"MT01_Step\" + Step + \"_Reasons\";\nlet DisplayArray = \"Display_MT01_Reasons\";\n\nglobal.set(ReadArray, msg.payload);\nflow.set(DisplayArray, msg.payload);\n\nmsg.payload = msg.payload;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"OK\"});\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1070,
"y": 340,
"wires": [
[
"6eeb3b50a11c866d"
]
]
},
{
"id": "ec1c6b760fae4603",
"type": "change",
"z": "77e990dfb4b955d1",
"name": "RE PL",
"rules": [
{
"t": "set",
"p": "MT01_ReasonEdit",
"pt": "global",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 450,
"y": 440,
"wires": [
[
"36a733a16c94f8aa"
]
]
},
{
"id": "4ee4ac5b7960dfa8",
"type": "function",
"z": "77e990dfb4b955d1",
"name": "obj to File",
"func": "//Set Variables for Mixer Sequence Delay Reasons csv:\nlet n = msg.topic;\nlet Step = global.get(\"MT0\" + n + \"_ReasonsStep\");\nlet MSDR_FN = \"MT0\" + n +\"_Step\" + Step + \"_Reasons\";\nlet CorrectedReason = flow.get(\"Display_MT01_Reasons\");\n\n\n\nmsg.filename = \"D:\\\\PersistentTagValues\\\\MSD_Reasons\\\\MT0\" + n + \"\\\\\" + MSDR_FN + \".csv\";\nmsg.payload=CorrectedReason;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"OK\"});\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 460,
"y": 280,
"wires": [
[
"4c9a015b54f01175"
]
]
},
{
"id": "6c8ca6ca982f8da6",
"type": "file",
"z": "77e990dfb4b955d1",
"name": "Write Reasons",
"filename": "",
"appendNewline": false,
"createDir": true,
"overwriteFile": "true",
"encoding": "none",
"x": 740,
"y": 280,
"wires": [
[
"8752a7165e30e3b6"
]
]
},
{
"id": "e3be9852b9a060cf",
"type": "inject",
"z": "77e990dfb4b955d1",
"name": "1",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "MT01_Step1_Reasons[6]",
"payloadType": "global",
"x": 470,
"y": 780,
"wires": [
[
"87e96ed2a74185e1"
]
]
},
{
"id": "37bb4231d90c0e2f",
"type": "function",
"z": "77e990dfb4b955d1",
"name": "FNG",
"func": "//Set Variables for Mixer Sequence Delay Reasons csv:\nglobal.set(\"MT01_ReasonsStep\",msg.payload); // Set Step from Dropdown Selection\nlet Reasons_csv = \"MT01_Step\" + msg.payload + \"_Reasons\";\n\nmsg.filename = \"D:\\\\PersistentTagValues\\\\MSD_Reasons\\\\MT01\\\\\" + Reasons_csv + \".csv\";\n\nmsg.payload=msg.payload;\nnode.status({fill:\"blue\",shape:\"ring\",text:\"OK\"});\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 590,
"y": 360,
"wires": [
[
"600a1d8a75bd4cdd"
]
]
},
{
"id": "600a1d8a75bd4cdd",
"type": "file in",
"z": "77e990dfb4b955d1",
"name": "Load File to OBJ",
"filename": "",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 750,
"y": 360,
"wires": [
[
"dc5e61a0bc197797"
]
]
},
{
"id": "1aada00edf79804a",
"type": "inject",
"z": "77e990dfb4b955d1",
"name": "o",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "MT01_Reasons[5]",
"payloadType": "global",
"x": 470,
"y": 700,
"wires": [
[
"87e96ed2a74185e1"
]
]
},
{
"id": "f28fd95dda22e4cb",
"type": "inject",
"z": "77e990dfb4b955d1",
"name": "2",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "MT01_Step2_Reasons",
"payloadType": "global",
"x": 470,
"y": 820,
"wires": [
[
"87e96ed2a74185e1"
]
]
},
{
"id": "4c9a015b54f01175",
"type": "json",
"z": "77e990dfb4b955d1",
"name": "",
"property": "payload",
"action": "str",
"pretty": false,
"x": 590,
"y": 280,
"wires": [
[
"6c8ca6ca982f8da6"
]
]
},
{
"id": "dc5e61a0bc197797",
"type": "json",
"z": "77e990dfb4b955d1",
"name": "",
"property": "payload",
"action": "obj",
"pretty": false,
"x": 910,
"y": 360,
"wires": [
[
"619208528a09010f"
]
]
},
{
"id": "8b73b0c1d41c47e1",
"type": "function",
"z": "77e990dfb4b955d1",
"name": "M1-R-Edit",
"func": "//Set Variables for Mixer Sequence Delay Reasons csv:\nlet R = global.get(\"MT01_ReasonEdit\")\nlet TextInput = msg.topic;\nflow.set(\"Display_MT01_Reasons[\" + R + \"]\", TextInput);\n\nmsg.payload=\"\";\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"OK\"});\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 460,
"y": 520,
"wires": [
[
"dc2ee0c889bcd329"
]
]
},
{
"id": "7f0adfeeb992c957",
"type": "rbe",
"z": "77e990dfb4b955d1",
"name": "chg",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": false,
"property": "payload",
"topi": "topic",
"x": 450,
"y": 360,
"wires": [
[
"37bb4231d90c0e2f"
]
]
},
{
"id": "36a733a16c94f8aa",
"type": "debug",
"z": "77e990dfb4b955d1",
"name": "RSel dbg",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 600,
"y": 440,
"wires": []
},
{
"id": "6eeb3b50a11c866d",
"type": "debug",
"z": "77e990dfb4b955d1",
"name": "SSel dbg",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1220,
"y": 340,
"wires": []
},
{
"id": "8752a7165e30e3b6",
"type": "debug",
"z": "77e990dfb4b955d1",
"name": "Sv dbg",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 960,
"y": 260,
"wires": []
},
{
"id": "dc2ee0c889bcd329",
"type": "debug",
"z": "77e990dfb4b955d1",
"name": "IN dbg t",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "topic",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 600,
"y": 520,
"wires": []
},
{
"id": "b84bd3be120e2a1f",
"type": "inject",
"z": "77e990dfb4b955d1",
"name": "UpdateTables",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "1",
"payloadType": "num",
"x": 220,
"y": 240,
"wires": [
[
"229761a90f15aff6"
]
]
},
{
"id": "229761a90f15aff6",
"type": "function",
"z": "77e990dfb4b955d1",
"name": "M1 Reasons",
"func": "let Bowl=\"MT01\"; // Setup Setup Setup\nlet R_Count = 15;\nlet Step=global.get(\"MT01_ReasonsStep\");\nlet j = 0;\n\nconst RL_html = [];\nfor (j = 0; j < (R_Count+1); j++) {\n let StoredArray = global.get(Bowl + \"_Step\" + Step + \"_Reasons[\" + j + \"]\");\n let dsp = flow.get(\"Display_\" + Bowl + \"_Reasons[\" + j + \"]\");\n let HTML1 = \"<div style='background-color: \";\n let HTML2=\"\";\n if (StoredArray == dsp){\n HTML2 = \"white\";\n }else{\n HTML2 = \"yellow\"; \n }\n let HTML3 = \"; width:100%; color:black;'>\";\n let HTML4 = dsp;\n let HTML5 = \"</div>\"\n RL_html[j] = HTML1+HTML2+HTML3+HTML4+HTML5;\n}\n\nlet Table = [\n{\n\"Row\":1,\n\"Step\":Step,\n\"Text\":RL_html[1],\n},\n{\n\"Row\":2,\n\"Step\":Step,\n\"Text\":RL_html[2],\n},\n{\n\"Row\":3,\n\"Step\":Step,\n\"Text\":RL_html[3],\n},\n{\n\"Row\":4,\n\"Step\":Step,\n\"Text\":RL_html[4],\n},\n{\n\"Row\":5,\n\"Step\":Step,\n\"Text\":RL_html[5],\n},\n{\n\"Row\":6,\n\"Step\":Step,\n\"Text\":RL_html[6],\n},\n{\n\"Row\":7,\n\"Step\":Step,\n\"Text\":RL_html[7],\n},\n{\n\"Row\":8,\n\"Step\":Step,\n\"Text\":RL_html[8],\n},\n{\n\"Row\":9,\n\"Step\":Step,\n\"Text\":RL_html[9],\n},\n{\n\"Row\":10,\n\"Step\":Step,\n\"Text\":RL_html[10],\n},\n{\n\"Row\":11,\n\"Step\":Step,\n\"Text\":RL_html[11],\n},\n{\n\"Row\":12,\n\"Step\":Step,\n\"Text\":RL_html[12],\n},\n{\n\"Row\":13,\n\"Step\":Step,\n\"Text\":RL_html[13],\n},\n{\n\"Row\":14,\n\n\"Step\":Step,\n\"Text\":RL_html[14],\n},\n{\n\"Row\":15,\n\"Step\":Step,\n\"Text\":RL_html[15],\n}\n];\n\nmsg.payload=Table;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"OK - \" + j});\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 730,
"y": 80,
"wires": [
[
"67ce9a39c5c5952a"
]
]
},
{
"id": "67ce9a39c5c5952a",
"type": "ui_table",
"z": "77e990dfb4b955d1",
"group": "67d8728aa87a6a03",
"name": "MT01_Reasons",
"order": 1,
"width": "14",
"height": "9",
"columns": [
{
"field": "Row",
"title": "^",
"width": "1",
"align": "left",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "Step",
"title": "Step",
"width": "65",
"align": "right",
"formatter": "html",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "Text",
"title": "Reason",
"width": "500",
"align": "left",
"formatter": "html",
"formatterParams": {
"target": "_blank"
}
}
],
"outputs": 0,
"cts": false,
"x": 1000,
"y": 80,
"wires": []
},
{
"id": "67d8728aa87a6a03",
"type": "ui_group",
"name": "Reasons",
"tab": "6933cb9e.7444f4",
"order": 2,
"disp": true,
"width": "14",
"collapse": true,
"className": ""
},
{
"id": "6933cb9e.7444f4",
"type": "ui_tab",
"name": "MT01",
"icon": "dashboard",
"order": 2,
"disabled": false,
"hidden": false
}
]