This commit is contained in:
@@ -281,14 +281,12 @@ namespace AyaNova.Biz
|
||||
|
||||
//Accept a json template
|
||||
//return a column list suitable for api list return
|
||||
public static string GenerateListColumnsJSONFromTemplate(AyaType defaultLinkType, string ObjectKey, string template)
|
||||
public static string GenerateListColumnsJSONFromTemplate(AyaType defaultLinkType, List<AyaObjectFieldDefinition> objectFields, string template)
|
||||
{
|
||||
//parse the template
|
||||
var jtemplate = JObject.Parse(template);
|
||||
|
||||
//get the fields list
|
||||
var fields = AyaObjectFields(ObjectKey);
|
||||
|
||||
|
||||
//convert to strings (https://stackoverflow.com/a/33836599/8939)
|
||||
var fullFields = ((JArray)jtemplate["full"]).ToObject<string[]>();
|
||||
|
||||
@@ -301,7 +299,7 @@ namespace AyaNova.Biz
|
||||
|
||||
foreach (string s in fullFields)
|
||||
{
|
||||
AyaObjectFieldDefinition o = fields.FirstOrDefault(x => x.FieldKey == s);
|
||||
AyaObjectFieldDefinition o = objectFields.FirstOrDefault(x => x.FieldKey == s);
|
||||
#if (DEBUG)
|
||||
//Developers little helper
|
||||
if (o == null)
|
||||
|
||||
@@ -13,15 +13,13 @@ namespace AyaNova.Biz
|
||||
{
|
||||
|
||||
//Build the SELECT portion of a list query based on the template, mini or full and the object key in question
|
||||
public static string Build(string objectKey, string template, bool mini)
|
||||
public static string Build( List<AyaObjectFieldDefinition> objectFieldsList, string template, bool mini)
|
||||
{
|
||||
|
||||
//parse the template
|
||||
var jtemplate = JObject.Parse(template);
|
||||
|
||||
//get the fields list
|
||||
var objectFieldsList = AyaObjectFieldDefinitions.AyaObjectFields(objectKey);
|
||||
|
||||
|
||||
//convert to strings array (https://stackoverflow.com/a/33836599/8939)
|
||||
string[] templateFieldList;
|
||||
if (mini)
|
||||
|
||||
@@ -413,7 +413,8 @@ namespace AyaNova.Biz
|
||||
""mini"":[""widgetname"",""username"",""emailaddress""]
|
||||
}
|
||||
";
|
||||
var AyaObjectFieldsKey = AyaObjectFieldDefinitions.TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY;
|
||||
|
||||
var AyaObjectFields = AyaObjectFieldDefinitions.AyaObjectFields(AyaObjectFieldDefinitions.TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY);
|
||||
|
||||
//BUILD THE QUERY
|
||||
/*
|
||||
@@ -425,7 +426,7 @@ namespace AyaNova.Biz
|
||||
*/
|
||||
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
||||
//"select clm,clm,clm"
|
||||
var qSelectColumns = SqlSelectBuilder.Build(AyaObjectFieldsKey, MOCK_WIDGET_USER_EMAIL_DISPLAY_TEMPLATE_JSON, listOptions.Mini);
|
||||
var qSelectColumns = SqlSelectBuilder.Build(AyaObjectFields, MOCK_WIDGET_USER_EMAIL_DISPLAY_TEMPLATE_JSON, listOptions.Mini);
|
||||
|
||||
//FROM CLAUSE
|
||||
//this is where the full SQL statement needs to be made with JOINS etc
|
||||
@@ -440,7 +441,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == listOptions.DataFilterId);
|
||||
//WHERE CLAUSE - FILTER
|
||||
qWhere = SqlFilterCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, AyaObjectFieldDefinitions.AyaObjectFields(AyaObjectFieldsKey), UserId);
|
||||
qWhere = SqlFilterCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, AyaObjectFields, UserId);
|
||||
//ORDER BY CLAUSE - SORT
|
||||
//BUILD ORDER BY AND APPEND IT
|
||||
qOrderBy = SqlFilterOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
||||
@@ -470,7 +471,7 @@ namespace AyaNova.Biz
|
||||
//todo: need exact rowcount so can set up array on each row
|
||||
//need to know which index of each row is going to need the id of the next row
|
||||
|
||||
List<List<AyaFieldData>> rows= new List<List<AyaFieldData>>();
|
||||
List<List<AyaFieldData>> rows = new List<List<AyaFieldData>>();
|
||||
long totalRecordCount = 0;
|
||||
|
||||
//RUN THE QUERY
|
||||
@@ -505,10 +506,10 @@ namespace AyaNova.Biz
|
||||
//with a optional ID that is set to json not serialize if null?
|
||||
//https://www.newtonsoft.com/json/help/html/JsonPropertyPropertyLevelSetting.htm
|
||||
|
||||
|
||||
|
||||
|
||||
//rows:{[ {},{v:"Green mechanics",id:32},{v:"...notes..."},{v:"42",id:42}, ...thousands more etc.... ]}
|
||||
|
||||
|
||||
//If mini format all desired columns in order into the single mini return display (and set the only other return field which is ID)
|
||||
|
||||
//If wide then format the fields in order chosen (grid sort and filter template has already done that part above)
|
||||
@@ -529,7 +530,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
else
|
||||
{
|
||||
ColumnsJSON = AyaObjectFieldDefinitions.GenerateListColumnsJSONFromTemplate(AyaType.Widget, AyaObjectFieldsKey, MOCK_WIDGET_USER_EMAIL_DISPLAY_TEMPLATE_JSON);
|
||||
ColumnsJSON = AyaObjectFieldDefinitions.GenerateListColumnsJSONFromTemplate(AyaType.Widget, AyaObjectFields, MOCK_WIDGET_USER_EMAIL_DISPLAY_TEMPLATE_JSON);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user