This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -53,7 +53,7 @@
|
|||||||
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
||||||
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
||||||
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
|
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
|
||||||
"AYANOVA_SERVER_TEST_MODE": "true",
|
"AYANOVA_SERVER_TEST_MODE": "false",
|
||||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
|
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
|
||||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
|
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
|
||||||
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"
|
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"
|
||||||
|
|||||||
@@ -56,9 +56,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// So a tag query might be entered as "..zon some" which would match all tags LIKE 'zon' and template fields LIKE 'some'</param>
|
/// So a tag query might be entered as "..zon some" which would match all tags LIKE 'zon' and template fields LIKE 'some'</param>
|
||||||
/// <param name="inactive">Include inactive objects in the returned list </param>
|
/// <param name="inactive">Include inactive objects in the returned list </param>
|
||||||
/// <param name="preId">Return only one item (for pre-selected items on forms) </param>
|
/// <param name="preId">Return only one item (for pre-selected items on forms) </param>
|
||||||
|
/// <param name="variant">Some lists optionally take a variant string, e.g. User type "inside","outside" etc </param>
|
||||||
/// <returns>Filtered list</returns>
|
/// <returns>Filtered list</returns>
|
||||||
[HttpGet("list")]
|
[HttpGet("list")]
|
||||||
public async Task<IActionResult> GetList([FromQuery]AyaType ayaType, [FromQuery]string query, [FromQuery] bool inactive, [FromQuery]long? preId)
|
public async Task<IActionResult> GetList([FromQuery] AyaType ayaType, [FromQuery] string query, [FromQuery] bool inactive, [FromQuery] long? preId, [FromQuery] string variant)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
@@ -83,7 +84,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
if (preId == null)
|
if (preId == null)
|
||||||
preId = 0;
|
preId = 0;
|
||||||
var o = await biz.GetPickListAsync(PickList, query, inactive, (long)preId, log);
|
var o = await biz.GetPickListAsync(PickList, query, inactive, (long)preId, variant, log);
|
||||||
if (o == null)
|
if (o == null)
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
|
|||||||
7
server/AyaNova/PickList/IAyaPickListVariant.cs
Normal file
7
server/AyaNova/PickList/IAyaPickListVariant.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace AyaNova.PickList
|
||||||
|
{
|
||||||
|
internal interface IAyaPickListVariant
|
||||||
|
{
|
||||||
|
string GetVariantCriteria(string variant);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ namespace AyaNova.PickList
|
|||||||
internal static class PickListFetcher
|
internal static class PickListFetcher
|
||||||
{
|
{
|
||||||
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(IAyaPickList PickList, string autoCompleteQuery,
|
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(IAyaPickList PickList, string autoCompleteQuery,
|
||||||
string tagSpecificQuery, bool includeInactive, long preId, AyContext ct, ILogger log)
|
string tagSpecificQuery, bool includeInactive, long preId, string variant, AyContext ct, ILogger log)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Sort out effective Template
|
//Sort out effective Template
|
||||||
@@ -34,7 +34,7 @@ namespace AyaNova.PickList
|
|||||||
List<string> TemplateColumnNames = PickList.GetFieldListFromTemplate(jTemplate);
|
List<string> TemplateColumnNames = PickList.GetFieldListFromTemplate(jTemplate);
|
||||||
|
|
||||||
//BUILD THE QUERY
|
//BUILD THE QUERY
|
||||||
var q = PickListSqlBuilder.Build(PickList, TemplateColumnNames, autoCompleteQuery, tagSpecificQuery, includeInactive, preId);
|
var q = PickListSqlBuilder.Build(PickList, TemplateColumnNames, autoCompleteQuery, tagSpecificQuery, includeInactive, preId, variant);
|
||||||
|
|
||||||
//RETURN OBJECTS
|
//RETURN OBJECTS
|
||||||
var ret = new List<NameIdActiveItem>();
|
var ret = new List<NameIdActiveItem>();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace AyaNova.PickList
|
|||||||
const int MAXIMUM_RESULT_COUNT = 100;
|
const int MAXIMUM_RESULT_COUNT = 100;
|
||||||
|
|
||||||
//Build the query for a picklist request
|
//Build the query for a picklist request
|
||||||
internal static string Build(IAyaPickList pickList, List<string> templateColumnNames, string autoCompleteQuery, string tagSpecificQuery, bool IncludeInactive, long preId)
|
internal static string Build(IAyaPickList pickList, List<string> templateColumnNames, string autoCompleteQuery, string tagSpecificQuery, bool IncludeInactive, long preId, string variant)
|
||||||
{
|
{
|
||||||
|
|
||||||
//determine this in advance as it will be used in a loop later
|
//determine this in advance as it will be used in a loop later
|
||||||
@@ -44,6 +44,14 @@ namespace AyaNova.PickList
|
|||||||
string TagSpecificWhereFragment = string.Empty;
|
string TagSpecificWhereFragment = string.Empty;
|
||||||
string PredefinedOnlyWhereFragment = string.Empty;
|
string PredefinedOnlyWhereFragment = string.Empty;
|
||||||
|
|
||||||
|
string VariantWhereFragment = string.Empty;
|
||||||
|
bool HasVariantWhereFragment = false;
|
||||||
|
if (!string.IsNullOrWhiteSpace(variant) && pickList is IAyaPickListVariant)
|
||||||
|
{
|
||||||
|
VariantWhereFragment = ((IAyaPickListVariant)pickList).GetVariantCriteria(variant);
|
||||||
|
HasVariantWhereFragment = !string.IsNullOrWhiteSpace(VariantWhereFragment);
|
||||||
|
}
|
||||||
|
|
||||||
//PROCESS ROW ID "VALUE" COLUMN
|
//PROCESS ROW ID "VALUE" COLUMN
|
||||||
//
|
//
|
||||||
AyaPickListFieldDefinition rowIdColumn = pickList.ColumnDefinitions.FirstOrDefault(z => z.IsRowId == true);
|
AyaPickListFieldDefinition rowIdColumn = pickList.ColumnDefinitions.FirstOrDefault(z => z.IsRowId == true);
|
||||||
@@ -230,10 +238,15 @@ namespace AyaNova.PickList
|
|||||||
|
|
||||||
//WHERE
|
//WHERE
|
||||||
//there is a condition where there is no where (inactive=true and no query of any kind)
|
//there is a condition where there is no where (inactive=true and no query of any kind)
|
||||||
if (preId > 0 || lWhere.Count > 0 || HasTagSpecificQuery || IncludeInactive == false)
|
if (preId > 0 || lWhere.Count > 0 || HasTagSpecificQuery || HasVariantWhereFragment || IncludeInactive == false)
|
||||||
{
|
{
|
||||||
sb.Append(" where ");
|
sb.Append(" where ");
|
||||||
|
|
||||||
|
if (HasVariantWhereFragment)
|
||||||
|
{
|
||||||
|
sb.Append($"({VariantWhereFragment}) and ");
|
||||||
|
}
|
||||||
|
|
||||||
if (HasTagSpecificQuery)
|
if (HasTagSpecificQuery)
|
||||||
{
|
{
|
||||||
sb.Append(TagSpecificWhereFragment);
|
sb.Append(TagSpecificWhereFragment);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
namespace AyaNova.PickList
|
namespace AyaNova.PickList
|
||||||
{
|
{
|
||||||
internal class UserPickList : AyaPickList
|
internal class UserPickList : AyaPickList, IAyaPickListVariant
|
||||||
{
|
{
|
||||||
public UserPickList()
|
public UserPickList()
|
||||||
{
|
{
|
||||||
@@ -62,5 +62,17 @@ namespace AyaNova.PickList
|
|||||||
SqlValueColumnName = "auser.tags"
|
SqlValueColumnName = "auser.tags"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetVariantCriteria(string variant)
|
||||||
|
{
|
||||||
|
switch (variant)
|
||||||
|
{
|
||||||
|
case "inside":
|
||||||
|
return $"auser.usertype!={(int)UserType.Customer} and auser.usertype!={(int)UserType.HeadOffice}";
|
||||||
|
case "outside":
|
||||||
|
return $"auser.usertype={(int)UserType.Customer} or auser.usertype={(int)UserType.HeadOffice}";
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
}//eoc
|
}//eoc
|
||||||
}//eons
|
}//eons
|
||||||
@@ -70,7 +70,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
//get picklist
|
//get picklist
|
||||||
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive, long preId, ILogger log)
|
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive, long preId, string variant, ILogger log)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Crack and validate the query part set a broken rule if not valid and return null
|
//Crack and validate the query part set a broken rule if not valid and return null
|
||||||
@@ -134,7 +134,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
|
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
|
||||||
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, preId, ct, log);
|
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, preId,variant, ct, log);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user