From cdfca271d3d6823dfa0b41be94e34a9ff47e3163 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 16 Mar 2020 22:43:26 +0000 Subject: [PATCH] --- server/AyaNova/PickList/PickListSqlBuilder.cs | 7 +++---- server/AyaNova/biz/PickListBiz.cs | 20 +++++++++++++++++-- server/AyaNova/resource/de.json | 3 ++- server/AyaNova/resource/en.json | 3 ++- server/AyaNova/resource/es.json | 3 ++- server/AyaNova/resource/fr.json | 3 ++- 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/server/AyaNova/PickList/PickListSqlBuilder.cs b/server/AyaNova/PickList/PickListSqlBuilder.cs index 669956b6..b061323f 100644 --- a/server/AyaNova/PickList/PickListSqlBuilder.cs +++ b/server/AyaNova/PickList/PickListSqlBuilder.cs @@ -18,20 +18,19 @@ namespace AyaNova.PickList internal static string Build(IAyaPickList pickList, List templateColumnNames, string autoCompleteQuery, string tagSpecificQuery, bool IncludeInactive) { - //determine this in advance as it will be used in a loop later bool HasAutoCompleteQuery = !string.IsNullOrWhiteSpace(autoCompleteQuery); bool HasTagSpecificQuery = !string.IsNullOrWhiteSpace(tagSpecificQuery); - //lists to collect the clauses so to avoid comma fuckery + //Variables to collect the data needed to create the actual clauses later List lSelect = new List(); - string ActiveWhereFragment = string.Empty; List lWhere = new List(); List lOrderBy = new List(); + string PlIdSelectFragment = string.Empty; string ActiveSelectFragment = string.Empty; - + string ActiveWhereFragment = string.Empty; //PROCESS ROW ID "VALUE" COLUMN // diff --git a/server/AyaNova/biz/PickListBiz.cs b/server/AyaNova/biz/PickListBiz.cs index 6fb7e81e..ad9b6263 100644 --- a/server/AyaNova/biz/PickListBiz.cs +++ b/server/AyaNova/biz/PickListBiz.cs @@ -58,11 +58,27 @@ namespace AyaNova.Biz //get picklist internal async Task> GetPickListAsync(AyaType ayaType, string query, bool inactive, AuthorizationRoles userRoles) { + + var PickList = PickListFactory.GetAyaPickList(ayaType); + + //was the name not found as a pick list? + if (PickList == null) + { + //not a user error so no need to localize + AddError(ApiErrorCode.NOT_FOUND, "ayaType", $"PickList for type \"{ayaType}\" specified does not exist"); + return null; + + } + + + //Crack and validate the query part set a broken rule if not valid and return null //else do the query string TagSpecificQuery = null; string AutoCompleteQuery = null; + + //Here need to handle scenario of badly formed query so user knows they did it wrong and doesn't just assume it's not there //determine if this is a tag query @@ -75,7 +91,7 @@ namespace AyaNova.Biz var querySegments = AutoCompleteQuery.Split(' '); if (querySegments.Length > 2) { - AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:PickListQueryInvalid"); + AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:ErrorPickListQueryInvalid"); return null; } // users may type several spaces in a regular query, so ignore that and only use the first two segments @@ -91,7 +107,7 @@ namespace AyaNova.Biz } else { - AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:PickListQueryInvalid"); + AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:ErrorPickListQueryInvalid"); return null; } diff --git a/server/AyaNova/resource/de.json b/server/AyaNova/resource/de.json index ac403294..3e0c849c 100644 --- a/server/AyaNova/resource/de.json +++ b/server/AyaNova/resource/de.json @@ -1632,5 +1632,6 @@ "OldPassword": "Altes Kennwort", "NewPassword": "Neues Kennwort", "ConfirmPassword": "Kennwort bestätigen", - "ErrorNoMatch":"Werte stimmen nicht überein" + "ErrorNoMatch":"Werte stimmen nicht überein", + "ErrorPickListQueryInvalid":"Die eingegebene Abfrage ist ungültig - siehe PickList-Dokumentation" } diff --git a/server/AyaNova/resource/en.json b/server/AyaNova/resource/en.json index b20aef16..f7885b24 100644 --- a/server/AyaNova/resource/en.json +++ b/server/AyaNova/resource/en.json @@ -1633,7 +1633,8 @@ "OldPassword": "Old password", "NewPassword": "New password", "ConfirmPassword": "Confirm password", - "ErrorNoMatch":"Values don't match" + "ErrorNoMatch":"Values don't match", + "ErrorPickListQueryInvalid":"Query entered is not valid - see PickList documentation" diff --git a/server/AyaNova/resource/es.json b/server/AyaNova/resource/es.json index 60964e3c..dda0f790 100644 --- a/server/AyaNova/resource/es.json +++ b/server/AyaNova/resource/es.json @@ -1632,7 +1632,8 @@ "OldPassword": "Contraseña anterior", "NewPassword": "Nueva contraseña", "ConfirmPassword": "Confirmar contraseña", - "ErrorNoMatch":"Los valores no coinciden" + "ErrorNoMatch":"Los valores no coinciden", + "ErrorPickListQueryInvalid":"La consulta ingresada no es válida; consulte la documentación de PickList" } \ No newline at end of file diff --git a/server/AyaNova/resource/fr.json b/server/AyaNova/resource/fr.json index 38e86989..08d7ae32 100644 --- a/server/AyaNova/resource/fr.json +++ b/server/AyaNova/resource/fr.json @@ -1631,7 +1631,8 @@ "OldPassword": "Ancien mot de passe", "NewPassword": "Nouveau mot de passe", "ConfirmPassword": "Confirmer le mot de passe", - "ErrorNoMatch":"Les valeurs ne correspondent pas" + "ErrorNoMatch":"Les valeurs ne correspondent pas", + "ErrorPickListQueryInvalid":"La requête saisie n'est pas valide - voir la documentation PickList" }