From 8de7ec18095937193f3b028e9d389c0b86d4648f Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Thu, 10 Nov 2022 07:52:52 +0100 Subject: [PATCH] A warning, what the current value is, is now displayed if a disallowed value is entered Close #21 --- public/assets/js/csvxmlV2.js | 2 +- public/assets/js/csvxmlV2.min.js | 2 +- public/index.htm | 4 ++-- scripts/compile.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/assets/js/csvxmlV2.js b/public/assets/js/csvxmlV2.js index bcd2145..4fe404a 100644 --- a/public/assets/js/csvxmlV2.js +++ b/public/assets/js/csvxmlV2.js @@ -170,7 +170,7 @@ class CsvxmlValidator { continue; } - this.errors.controlledLists.push("Disallowed value used for column " + fieldName + " at line " + lineCounter + " (Allowed values are: " + Object.values(allowedValues).join(", ") + ")"); + this.errors.controlledLists.push("Disallowed value used for column " + fieldName + " at line " + lineCounter + " (Allowed values are: " + Object.values(allowedValues).join(", ") + "; current value is " + line[fieldName] + ")"); } lineCounter++; } diff --git a/public/assets/js/csvxmlV2.min.js b/public/assets/js/csvxmlV2.min.js index aa7c9ff..868ba60 100644 --- a/public/assets/js/csvxmlV2.min.js +++ b/public/assets/js/csvxmlV2.min.js @@ -17,7 +17,7 @@ invNoEncountered.push(line.inventory_number);lineCounter++;}} checkDependentColumns(){const headers=Object.keys(this.toValidate[0]);for(let header of headers){if(this.fieldList[header]===undefined||this.fieldList[header].dependsOn===undefined||this.fieldList[header].dependsOn===null)continue;let dependencies=this.fieldList[header].dependsOn;for(let dep of dependencies){if(headers.includes(dep)===false){this.errors.dependentColumns.push("Dependency issue at column "+header+": Corresponding column "+dep+" is missing");}}}} checkControlledLists(){let lineCounter=1;for(let line of this.toValidate){for(let fieldName in line){if(this.fieldList[fieldName]===undefined){console.log("Undefined but requested field "+fieldName);continue;} let allowedValues=this.fieldList[fieldName].allowedValues;if(allowedValues===undefined||allowedValues===null)continue;if(Object.values(allowedValues).length===0||Object.values(allowedValues).includes(line[fieldName])){continue;} -this.errors.controlledLists.push("Disallowed value used for column "+fieldName+" at line "+lineCounter+" (Allowed values are: "+Object.values(allowedValues).join(", ")+")");} +this.errors.controlledLists.push("Disallowed value used for column "+fieldName+" at line "+lineCounter+" (Allowed values are: "+Object.values(allowedValues).join(", ")+"; current value is "+line[fieldName]+")");} lineCounter++;}} checkMainImageResource(){} isValid(){for(let errorClass in this.errors){if(this.errors[errorClass].length!==0)return false;} diff --git a/public/index.htm b/public/index.htm index 5ec70f8..246a8a8 100644 --- a/public/index.htm +++ b/public/index.htm @@ -4,7 +4,7 @@ - + @@ -27,7 +27,7 @@ - + \ No newline at end of file diff --git a/scripts/compile.php b/scripts/compile.php index 0cc71a2..f917bc4 100644 --- a/scripts/compile.php +++ b/scripts/compile.php @@ -76,7 +76,7 @@ function generateAppShell():string { - + @@ -99,7 +99,7 @@ function generateAppShell():string { - + ';