From 71f8bf208dcb59ac566e227ad217842668b972cd Mon Sep 17 00:00:00 2001 From: Michael Levenick Date: Fri, 2 Aug 2019 07:07:53 -0500 Subject: [PATCH] Fixed an issue with preflight checks not working when a blank template was uploaded on the main tab, prior to any filled out templates being uploaded. --- The MUT/ViewController.swift | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/The MUT/ViewController.swift b/The MUT/ViewController.swift index 28b8464..2d37a2f 100644 --- a/The MUT/ViewController.swift +++ b/The MUT/ViewController.swift @@ -195,6 +195,8 @@ class ViewController: NSViewController, URLSessionDelegate, NSTableViewDelegate, } else if tabToGoTo == "scope" { self.scopePreFlightChecks() + } else { + self.initialPreFlightChecks() } } } @@ -610,6 +612,24 @@ class ViewController: NSViewController, URLSessionDelegate, NSTableViewDelegate, } } + func initialPreFlightChecks() { + // If the user has actually selected a CSV template, then move on + if txtCSV.stringValue != "" { + //get the CSV from the "Browse" button and parse it into an array + csvArray = CSVMan.readCSV(pathToCSV: self.globalPathToCSV.path!, delimiter: globalDelimiter!) + + if csvArray.count == 0 { + // If there are no rows in the CSV + _ = popMan.generalWarning(question: "Empty CSV Found", text: "It seems the CSV file you uploaded is malformed, or does not contain any data.\n\nPlease try a different CSV.") + } else if csvArray.count == 1 { + // If there is only 1 row in the CSV (header only) + _ = popMan.generalWarning(question: "No Data Found", text: "It seems the CSV file you uploaded does not contain any data outside of the header row.\n\nPlease select a CSV with updates for MUT to process.") + } + } else { + _ = popMan.generalWarning(question: "No CSV Found", text: "Please use the Browse button to find a CSV file on your system with updates that you would like MUT to process.") + } + } + func verifyCSV() { // Nuke the CSV array on every preflight so we don't get stuck with old data csvArray.removeAll()