This commit is contained in:
@@ -57,12 +57,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
var MOCK_WIDGET_DISPLAY_TEMPLATE_JSON = @"
|
//check rights at some point here
|
||||||
{
|
|
||||||
""full"":[""widgetname"",""widgetserial"",""widgetdollaramount"",""widgetroles"",""widgetstartdate"",""widgetactive"",""username""],
|
|
||||||
""mini"":[""widgetname"",""widgetserial""]
|
|
||||||
}
|
|
||||||
";
|
|
||||||
|
|
||||||
long UserId = UserIdFromContext.Id(HttpContext.Items);
|
long UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||||
ApiPagedResponse pr = await DataListFetcher.GetResponse(listOptions.DataListKey, ct, Url, nameof(List), listOptions, MOCK_WIDGET_DISPLAY_TEMPLATE_JSON, UserId);
|
ApiPagedResponse pr = await DataListFetcher.GetResponse(listOptions.DataListKey, ct, Url, nameof(List), listOptions, MOCK_WIDGET_DISPLAY_TEMPLATE_JSON, UserId);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace AyaNova.DataList
|
|||||||
public AuthorizationRoles AllowedRoles { get; set; }
|
public AuthorizationRoles AllowedRoles { get; set; }
|
||||||
public AyaType DefaultListObjectType { get; set; }
|
public AyaType DefaultListObjectType { get; set; }
|
||||||
public string ListKey { get; set; }
|
public string ListKey { get; set; }
|
||||||
|
public string DefaultDataListDisplayTemplate { get; set; }
|
||||||
|
|
||||||
public string GenerateMINIListColumnsJSON()
|
public string GenerateMINIListColumnsJSON()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,23 +12,16 @@ namespace AyaNova.DataList
|
|||||||
{
|
{
|
||||||
internal static class DataListFetcher
|
internal static class DataListFetcher
|
||||||
{
|
{
|
||||||
internal static async Task<ApiPagedResponse> GetResponse(
|
internal static async Task<ApiPagedResponse> GetResponse(string DataListKey, AyContext ct, IUrlHelper Url,
|
||||||
string DataListKey, AyContext ct, IUrlHelper Url,
|
string routeName, ListOptions listOptions, long UserId)
|
||||||
string routeName, ListOptions listOptions, string JSONDataListTemplate, long UserId)
|
|
||||||
{
|
{
|
||||||
//TODO: Get template (MOCKED FOR NOW UNTIL PROOF OF CONCEPT)
|
|
||||||
// var MOCK_WIDGET_USER_EMAIL_DISPLAY_TEMPLATE_JSON = @"
|
|
||||||
// {
|
|
||||||
// ""full"":[""widgetname"",""username"",""emailaddress"",""widgetactive""],
|
|
||||||
// ""mini"":[""widgetname"",""username"",""emailaddress""]
|
|
||||||
// }
|
|
||||||
// ";
|
|
||||||
|
|
||||||
// var AyaObjectFields = AyaObjectFieldDefinitions.AyaObjectFields(AyaObjectFieldDefinitions.TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY);
|
// var AyaObjectFields = AyaObjectFieldDefinitions.AyaObjectFields(AyaObjectFieldDefinitions.TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY);
|
||||||
var DataList = DataListFactory.GetAyaDataList(DataListKey);
|
var DataList = DataListFactory.GetAyaDataList(DataListKey);
|
||||||
|
|
||||||
|
|
||||||
//TODO: PUt this in the template biz class ultimately and modify sqlselectbuilder to use it
|
//TODO: FETCH DATALISTTEMPLATE HERE OR USE DEFAULT IF FAULTY OR NOT FOUND
|
||||||
|
var JSONDataListTemplate = DataList.DefaultDataListDisplayTemplate;
|
||||||
|
|
||||||
//PARSE THE TEMPLATE INTO A STRING ARRAY
|
//PARSE THE TEMPLATE INTO A STRING ARRAY
|
||||||
//SO WE KNOW WHICH FIELDS TO RETURN FROM QUERY
|
//SO WE KNOW WHICH FIELDS TO RETURN FROM QUERY
|
||||||
@@ -45,16 +38,11 @@ namespace AyaNova.DataList
|
|||||||
templateFieldList = ((JArray)jtemplate["full"]).ToObject<string[]>();
|
templateFieldList = ((JArray)jtemplate["full"]).ToObject<string[]>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//BUILD THE QUERY
|
//BUILD THE QUERY
|
||||||
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
||||||
//TODO: Make this a function called from DataList
|
|
||||||
var qSelectColumns = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, JSONDataListTemplate, listOptions.Mini);
|
var qSelectColumns = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, JSONDataListTemplate, listOptions.Mini);
|
||||||
|
|
||||||
//FROM CLAUSE
|
//FROM CLAUSE
|
||||||
//this is where the full SQL statement needs to be made with JOINS etc
|
|
||||||
//TODO: Can this be moved away into the objectfields or new object
|
|
||||||
//var qFrom = "from awidget left outer join auser on (awidget.userid=auser.id) left outer join auseroptions on (auser.id=auseroptions.userid)";
|
|
||||||
var qFrom = DataList.SQLFrom;
|
var qFrom = DataList.SQLFrom;
|
||||||
|
|
||||||
//FILTERED?
|
//FILTERED?
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ namespace AyaNova.DataList
|
|||||||
//Default object type to open for rows of this list (use no object if no)
|
//Default object type to open for rows of this list (use no object if no)
|
||||||
AyaType DefaultListObjectType { get; set; }
|
AyaType DefaultListObjectType { get; set; }
|
||||||
|
|
||||||
|
//Default list display template if none found in db or is invalid, this ensures the data will flow even if people fuck up the templates somehow
|
||||||
|
string DefaultDataListDisplayTemplate { get; set; }
|
||||||
|
|
||||||
string GenerateMINIListColumnsJSON();
|
string GenerateMINIListColumnsJSON();
|
||||||
string GenerateListColumnsJSONFromTemplate(string template);
|
string GenerateListColumnsJSONFromTemplate(string template);
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ namespace AyaNova.DataList
|
|||||||
SQLFrom = "from awidget left outer join auser on (awidget.userid=auser.id) left outer join auseroptions on (auser.id=auseroptions.userid)";
|
SQLFrom = "from awidget left outer join auser on (awidget.userid=auser.id) left outer join auseroptions on (auser.id=auseroptions.userid)";
|
||||||
AllowedRoles = AuthorizationRoles.AllInternalStaff;//anyone but clients and subcontractors (just for test)
|
AllowedRoles = AuthorizationRoles.AllInternalStaff;//anyone but clients and subcontractors (just for test)
|
||||||
DefaultListObjectType = AyaType.Widget;
|
DefaultListObjectType = AyaType.Widget;
|
||||||
|
DefaultDataListDisplayTemplate = @"
|
||||||
|
{
|
||||||
|
""full"":[""widgetname"",""username"",""emailaddress"",""widgetactive""],
|
||||||
|
""mini"":[""widgetname"",""username"",""emailaddress""]
|
||||||
|
}
|
||||||
|
";
|
||||||
|
|
||||||
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
||||||
FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
|
||||||
@@ -54,6 +60,7 @@ namespace AyaNova.DataList
|
|||||||
SqlValueColumnName = "awidget.active",
|
SqlValueColumnName = "awidget.active",
|
||||||
UiFieldDataType = (int)AyaUiFieldDataType.Bool
|
UiFieldDataType = (int)AyaUiFieldDataType.Bool
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}//eoc
|
}//eoc
|
||||||
}//eons
|
}//eons
|
||||||
@@ -11,6 +11,12 @@ namespace AyaNova.DataList
|
|||||||
SQLFrom = "from awidget left outer join auser on (awidget.userid=auser.id)";
|
SQLFrom = "from awidget left outer join auser on (awidget.userid=auser.id)";
|
||||||
AllowedRoles = AuthorizationRoles.AllInternalStaff;//anyone but clients and subcontractors (just for test)
|
AllowedRoles = AuthorizationRoles.AllInternalStaff;//anyone but clients and subcontractors (just for test)
|
||||||
DefaultListObjectType = AyaType.Widget;
|
DefaultListObjectType = AyaType.Widget;
|
||||||
|
DefaultDataListDisplayTemplate = @"
|
||||||
|
{
|
||||||
|
""full"":[""widgetname"",""widgetserial"",""widgetdollaramount"",""widgetroles"",""widgetstartdate"",""widgetactive"",""username""],
|
||||||
|
""mini"":[""widgetname"",""widgetserial""]
|
||||||
|
}
|
||||||
|
";
|
||||||
|
|
||||||
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined (in this case User) table need to be specified completely
|
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined (in this case User) table need to be specified completely
|
||||||
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
||||||
|
|||||||
Reference in New Issue
Block a user