FRC2713 / QRScout

A QR Code Based Scouting System for FRC
https://frc2713.github.io/QRScout/
MIT License
21 stars 70 forks source link

Required Fields #33

Closed apranger00 closed 8 months ago

apranger00 commented 8 months ago

Fields that are marked as "required": true in the config file are not always required when using the app.

tytremblay commented 8 months ago

@apranger00 could you share your qrscout config here? I'm unable to replicate

apranger00 commented 8 months ago
{
  "$schema": "../schema.json",
  "title": "QRScout",
  "page_title": "Crescendo",
  "sections": [
    {
      "name": "Prematch",
      "preserveDataOnReset": true,
      "fields": [
        {
          "title": "Scouter",
          "type": "select",
          "required": true,
          "code": "scout",
          "choices": {
            "Alex":    "Alex",
            "Austin":  "Austin",
            "Cody":    "Cody",
            "Conner":  "Conner",
            "Edi":     "Edi",
            "Grayson": "Grayson",
            "James":   "James",
            "Jayden":  "Jayden",
            "Jerica":  "Jerica",
            "Luke":    "Luke",
            "Adam":    "Adam",
            "Mike":    "Mike",
            "Pranger": "Pranger",
            "Jersey":  "Jersey",
            "Other":   "Other"
          },
          "defaultValue": "N_A"
        },
        {
          "title": "Match Number",
          "type": "number",
          "min": 1,
          "required": true,
          "code": "matchNumber"
        },
        {
          "title": "Team",
          "type": "select",
          "required": true,
          "code": "team_num",
          "choices": {
            "45":   "45-TechnoKats",
            "71":   "71-Hammond",
            "292":  "292-Panther",
            "447":  "447-Roboto",
            "1018":  "1018-Pike",
            "1024": "1024-KilABytes",
            "1555": "1555-CryoFrost",
            "1646": "1646-Jeff",
            "1720": "1720-PhyXTGears",
            "1741": "1741-Red Alert",
            "2867": "2867-ElkLogics",
            "2171": "2171-RoboDogs",
            "3147": "3147-Munster",
            "3487": "3487-Red Pride",
            "3494": "3494-Quads",
            "3559": "3559-Thundercats",
            "4272": "4272-Mavs",
            "4580": "4580-Conductors",
            "4926": "4926-GalacTech",
            "4982": "4982-Olympus",
            "5010": "5010-Tiger",
            "5188": "5188-Area 5188",
            "6498": "6498-Castle",
            "7198": "7198-Twin Lakes",
            "7454": "7454-Huskies",
            "7457": "7457-SuPURDUEper",
            "7617": "7167-Blazers",
            "7657": "7657-ThunderBots",
            "8103": "8103-Knight",
            "8116": "8116-Hatchet",
            "8430": "8430-Hatch Batch",
            "8564": "8564-Disco Ducks",
            "8742": "8742-Argyll",
            "9453": "9453-Wildcats",
            "9491": "9491-Silver Creek"
          },
          "defaultValue": "9999"
        }
      ]
    },
    {
      "name": "Autonomous",
      "fields": [
        {
          "code": "a_amp",
          "title": "Amp Scored (A)",
          "type": "counter",
          "defaultValue": 0,
          "min": 0,
          "required": false
        },
        {
          "code": "a_sp",
          "title": "Speaker Scored (A)",
          "type": "counter",
          "defaultValue": 0,
          "min": 0,
          "required": false
        }
      ]
    },
    {
      "name": "Teleop",
      "fields": [
        {
          "code": "t_amp",
          "title": "Amp Scored (T)",
          "type": "counter",
          "defaultValue": 0,
          "min": 0,
          "required": false
        },
        {
          "code": "t_sp",
          "title": "Speaker Scored (T)",
          "type": "counter",
          "defaultValue": 0,
          "min": 0,
          "required": false
        }
      ]
    },
    {
      "name": "Endgame",
      "fields": [
        {
          "code": "trap",
          "title": "Notes in Trap?",
          "type": "counter",
          "defaultValue": 0,
          "required": false
        },
        {
          "title": "Onstage",
          "type": "select",
          "required": true,
          "code": "stage",
          "choices": {
            "2":   "Successful Climb",
            "1":   "Attempted but Failed Climb",
            "0":  "No Attempt"
          },
          "defaultValue": "0"
        }
      ]
    },
    {
      "name": "Postmatch",
      "fields": [
        {
          "code": "or",
          "title": "Driver Rank",
          "type": "select",
          "required": true,
          "choices": {
            "3": "1 (High)",
            "2": "2",
            "1": "3 (Low)"
          },
          "defaultValue": "2"
        },
        {
          "title": "Special Circumstances",
          "type": "select",
          "required": true,
          "code": "special",
          "choices": {
            "RIP":    "Died",
            "TIP":    "Tipped",
            "OW":     "Significant damage",
            "NOSHOW": "No Show",
            "OMG":    "Other (Tell Captain)",
            "NOTE":   "Note stuck in robot",
            "NONE":   "none"
          },
          "defaultValue": "None"
        }
      ]
    }
  ]
}
tytremblay commented 8 months ago

Ah. We check whether a required field has been satisfied by checking if the field is null, undefined, or the empty string "". This is because we can't require fields to change from their default value (what if a robot scores 0 notes and the default value for that field is 0?)

In your config, scouter has a default value of N_A , and match has a default value of 9999. If you change those both to be default values of "" , then the required behavior should behave as you expect.

apranger00 commented 8 months ago

Solved! This took care of it. Thanks for the help.