From a7258e22c8fce58b79dcec682c7470f753788905 Mon Sep 17 00:00:00 2001 From: Rich Watson Date: Fri, 10 Jan 2025 06:53:46 -0500 Subject: [PATCH] Adding dynamic Required field handling from JSON --- resources/js/scoutingPASS.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/resources/js/scoutingPASS.js b/resources/js/scoutingPASS.js index 89b58aad0..cad46ccd2 100644 --- a/resources/js/scoutingPASS.js +++ b/resources/js/scoutingPASS.js @@ -21,9 +21,8 @@ var options = { quietZoneColor: '#FFFFFF' }; -// Must be filled in: e=event, m=match#, l=level(q,qf,sf,f), t=team#, r=robot(r1,r2,b1..), s=scouter -//var requiredFields = ["e", "m", "l", "t", "r", "s", "as"]; -var requiredFields = ["e", "m", "l", "r", "s", "as"]; +// Built from the JSON +var requiredFields = []; //["e", "m", "l", "r", "s", "as"]; function addTimer(table, idx, name, data) { var row = table.insertRow(idx); @@ -665,6 +664,12 @@ function addElement(table, idx, data) { return idx } +function buildRequiredElementList(element) { + if (element.required == "true") { + requiredFields.push(element.code); + } +} + function configure() { try { var mydata = JSON.parse(config_data); @@ -725,6 +730,7 @@ function configure() { var idx = 0; pmc.forEach(element => { idx = addElement(pmt, idx, element); + buildRequiredElementList(element); }); // Configure auton screen