This commit is contained in:
2020-01-17 19:07:20 +00:00
parent b98cee06cc
commit 548c894e35
2 changed files with 58 additions and 14 deletions

View File

@@ -222,29 +222,68 @@ namespace AyaNova.Biz
case TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY:
#region WIDGET_USER_EMAIL_ADDRESS_LIST_KEY
/*
Select awidget.id as widgetid, awidget.name as widgetname, auser.name as username, auser.id as userid, auseroptions.emailaddress
Select awidget.id as df, awidget.id as widgetid, awidget.name as widgetname, auser.name as username, auser.id as userid, auseroptions.emailaddress
from awidget
left outer join auser on (awidget.userid=auser.id)
left outer join auseroptions on (auser.id=auseroptions.userid)
public string Key { get; set; }
public string PropertyName { get; set; }
public bool Hideable { get; set; }
public bool SharedLTKey { get; set; }
public bool Custom { get; set; }
public bool Filterable { get; set; }
public bool Sortable { get; set; }
public int UiFieldDataType { get; set; }
public string EnumType { get; set; }
public int AyObjectType { get; set; }
//For query building
//This is the equivalent of the v7 SqlColumnNameAttribute
public string SqlIdColumn { get; set; }
public string SqlDisplayColumn { get; set; }
*/
//THIS is strictly a list object, not for forms so it doesn't need hideable set to any as that's a customization thing
l.Add(new ObjectField { Key = "df", AyObjectType = (int)AyaType.Widget });
//Property name is what the client looks for in the object to display
// and also what the return list generator uses to read in the column to deal with
//so property name is really displayasname and is always unique so actually it's really the unique key identifier, not KEY which is the ltkey
//sqlidcolumn and sqldisplaycolumn are actually sqlselectid and sqlselectdisplay
// - they could be a fragment with an alias i.e. sqlselectid="awidget.id as widgetid"
//need a separate property for the id column name to fetch
// for example:
/* Example of correct implementation
PropertyName="widgetname" (this is the unique key for this field and what the template and builders should be using)
ltkey="WidgetName" (this is not necessarily unique per list, for example it could be "active" or "notes" in the UI (in a report for example) more than once in cases )
sqlidcolumn="widgetid"
sqldisplaycolumn="widgetname"
ayobjecttype=ayatype.widget
UiFieldDataType=AyaUiFieldDataType.Text
Hideable=false (this is required for the edit forms, not the list template because it will warn if no fields are visible and doesn't require any particular field to be visible, just one of them)
SharedLTKEY= (DEPRECATE, NO IDEA, NOT REALLY required, probably thought I needed it for localized text editing maybe?)
Custom (this is used by the form customization at the client end and maybe other shit, keep for now)
filterable (required for CLIENT UI datafilter builder)
*/
l.Add(new ObjectField { Key = "df", AyObjectType = (int)AyaType.Widget, SqlIdColumn="awidget.id as df" });
l.Add(new ObjectField
{
Key = "WidgetName",
PropertyName = "widgetname",//same as sql display column so no need to specify both
PropertyName = "widgetname",
UiFieldDataType = (int)AyaUiFieldDataType.Text,
AyObjectType = (int)AyaType.Widget,
SqlIdColumn = "widgetid"
SqlIdColumn = "awidget.id as widgetid",
SqlDisplayColumn="awidget.name as widgetname"
});
l.Add(new ObjectField
{
Key = "User",
PropertyName = "username",//same as sql display column so no need to specify both
PropertyName = "username",
UiFieldDataType = (int)AyaUiFieldDataType.Text,
AyObjectType = (int)AyaType.User,
SqlIdColumn = "userid"
SqlIdColumn = "userid",
SqlDisplayColumn="auser.name as username"
});
l.Add(new ObjectField { Key = "UserEmailAddress", PropertyName = "emailaddress", UiFieldDataType = (int)AyaUiFieldDataType.EmailAddress});
break;

View File

@@ -408,11 +408,8 @@ namespace AyaNova.Biz
#region TestGetWidgetUserEmailList
internal async Task<ApiPagedResponse> TestGetWidgetUserEmailList(IUrlHelper Url, string routeName, ListOptions listOptions)
{
//TODO: Get template (MOCKED FOR NOW UNTIL PROOF OF CONCEPT)
var MOCK_WIDGET_DISPLAY_TEMPLATE_JSON = @"
var MOCK_WIDGET_USER_EMAIL_DISPLAY_TEMPLATE_JSON = @"
{
""full"":[""WidgetName"",""User"",""UserEmailAddress""],
""mini"":[""WidgetName"",""User"",""UserEmailAddress""]
@@ -420,12 +417,20 @@ namespace AyaNova.Biz
";
//BUILD THE QUERY
/*
Select awidget.id as df, awidget.id as widgetid, awidget.name as widgetname, auser.name as username, auser.id as userid, auseroptions.emailaddress
from awidget
left outer join auser on (awidget.userid=auser.id)
left outer join auseroptions on (auser.id=auseroptions.userid)
*/
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
//"select clm,clm,clm"
var qSelectColumns = SqlSelectBuilder.Build(ObjectFields.WIDGET_KEY, MOCK_WIDGET_DISPLAY_TEMPLATE_JSON, listOptions.Mini);
var qSelectColumns = SqlSelectBuilder.Build(ObjectFields.WIDGET_KEY, MOCK_WIDGET_USER_EMAIL_DISPLAY_TEMPLATE_JSON, listOptions.Mini);
var qFrom = "FROM AWIDGET";
//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)";
//FILTERED?
DataFilter TheFilter = null;
@@ -521,7 +526,7 @@ namespace AyaNova.Biz
}
else
{
ColumnsJSON = ObjectFields.GenerateListColumnsJSONFromTemplate(AyaType.Widget, ObjectFields.WIDGET_KEY, MOCK_WIDGET_DISPLAY_TEMPLATE_JSON);
ColumnsJSON = ObjectFields.GenerateListColumnsJSONFromTemplate(AyaType.Widget, ObjectFields.WIDGET_KEY, MOCK_WIDGET_USER_EMAIL_DISPLAY_TEMPLATE_JSON);
}
//TODO: BUILD THE RETURN LIST OF DATA ITEMS